Replacing a value of a node with CDATA (as is)

Hi All,
How do I replace the value of a node such that it's CDATA format is preserved and not re-encoded. Currently, when I do similar to the following:
replace value of node doc(doc_name)/parent/node with "<![CDATA[[the data]]]>"
the less than and greater than signs are replaced with &lt ; and &gt ; respectively, losing its CDATA section status.
How do I replace the value such that within the resulting XML it is exactly "<![CDATA[[the data]]]>" and not "&lt ;[CDATA[]the data]]&gt ;" ?
Thanks in advance
Cecil
Edited by: user5969022 on Jan 8, 2009 9:41 PM
Edited by: user5969022 on Jan 8, 2009 9:42 PM
Edited by: user5969022 on Jan 8, 2009 9:44 PM
Edited by: user5969022 on Jan 8, 2009 9:45 PM

John,
I am aware that it's synatic sugar. However, I actually need it to look that way. Thing is after edits, the resulting XML will be read by a component (that I have no access to change) which requires that node to have CDATA (as is) as it's value.
Anymore ideas; Anyone?
Instead of replacing the value (ie. replace value of node doc()...), I replaced the node (ie. replace node doc()...) with something similar to: <node>CDATA-section</node>. However, as expected only the data within the CDATA section gets persisted.
In this case could I turn something off or on such that xmldb leaves the CDATA-section as is? e.g. http://www.xquery.com/tips_and_tricks/including_CDATA_in_results.html
Thanks,
Cecil

Similar Messages

  • Unable to add value to model node with cardinality 0..n

    Hi All,
       Im working with Webdynpro Java.i have an issue here.i have a input field item named customer and a drop down box item location.when i give customer and location as inputs,a WSDL (named Equipment WSDL) is called.the result is a  drop down list containing equipments id
    i took a custom node location with cardinaliy 0..n.i gave static values as input for location.i need to set the location values to model node location.when i m giving a single value to custom node location,that static value is not accepted by model node location(in WSDL) whose cardinality is 0..n.
    Please suugest a solution for this issue
    With Regards,
    Ushasri.

    HI Ushashri,
    What do you mean by 'static value is not accepted by model node location'
    how you have done the mapping
    send me the hierarchy of rfc and ur value node
    With Regards
    Naidu

  • Hardcode values of the node with cardinality 0..n

    Good day!
    I need to hardcode a list of element to the node with cardinality 0..n.
    Node has two attributes.
    How can I fill the node with a few element in the input mapping? I know I can do it with a single element by separating values by comma. Is it possible to fill the node?

    Hello.
    I've the same problem. Can you say how to set list of values for a structure?
    For example, we've node FIELD containing two attributes:  ID and NAME.
    FIELD is a node with cardinality 0..*. How to set at least two elements to the node?
    Your example works only for simple attributes with cardinality 0..*, but it doesn't work for structures.
    Best Regards,
    Timur Semenchuk.

  • How to replace blank values in DATE field with 00000000

    Hi
    I have a DSO with Date field in which there are blank values. I want to replace the blank values in the DSO for date field with 00000000. Because of this blank values in the DSO the report is giving an ORA error.
    How do we replace the blank values in the DSO for historical data and also the new loads?
    Please advise.
    Thank you.
    Regards,
    Pavan.

    Hi Suman,
    I'm trying to run a query built on a DSO. The DSO has a field 'Start Date'. This Start Date InfoObject has a reference Char as 0DATE.
    This Start Field has blank values due to which I'm getting the ORA-01722 error. I came across many threads with same topic of discussion. As mentioned in one of the Threads I have written a program to update 'Start Date' with 00000000. The code wriiten is "UPDATE /BIC/AZ_MONINV00 SET /BIC/ZSTR_DTE = '00000000' where /BIC/ZSTR_DTE = ' '.
    Now when I see the data in the active data table of DSO the blank value is replaced with '00000000'.
    But If I right click on the DSO click on display data the 'Start Date' field is blank. And now the Query also gets executed without any error. But in the output of the query the 'Start Date' Field has "#" values.
    Can anyone suggest on how to remove these "#" values in the report?

  • How to set values to the structure containing a node with cardinality 0..n

    Hello.
    I 'm trying to set values for the node with cardinality 0..n. The node type is "Fields".
    <xsd:complexType name="Field">
       <xsd:sequence>
          <xsd:element name="fieldCode" type="xsd:string"></xsd:element>
          <xsd:element name="displayValue" type="xsd:string" minOccurs="0"></xsd:element>
       </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Fields">
       <xsd:sequence>
          <xsd:element name="field" type="tns:Field" minOccurs="0" maxOccurs="unbounded"></xsd:element>
       </xsd:sequence>
    </xsd:complexType>
    I  need to set several values for the element "fieldCode" but it has cardinality 0..1 and BPM does not allow it but I did not find any option about how to set values for the structure of type "Fields". Could you help me?
    Best regards,
    Timur Semenchuk

    Hi Marcus,
    If there is no way you could change the cardinality of the node, and thus it can contain 0..n items, I think you should create-and-add a new element programmatically.
    Since the collection can contain zero elements, I would add a 'new' button, which upon clicking adds one new element via:
    IYourNodeElement yourNodeElem = wdContext.nodeYourNode().createYourNodeElement();
    wdContext.nodeYourNode().addElement(yourNodeElem);
    Hope this explains a bit!
    Best,
    Robin van het Hof

  • Replacing the value in a list

    All,
    A quick question. How do we replace the value of role attribute with some other value?  When I try to set it, the new role is just getting appended.  I wanted to remove the olde role and set the new role.  I know I can remove the roles by setting .  is there any thing similar to replace as well?
    Thanks,
    BIju.

    Actually Biju, is exactly what you need - it is replace, not remove.
    = Add and is the default behavior, as you've seen
    = Delete and will clear all values for the attribute
    = Replace - it will delete all existing values and add whatever values follow the like:
    <newrolename>
    Edited by: Geoff Curtis on Jul 10, 2009 1:04 PM

  • Problem replacing Null nodes with real values in XML documents...

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    Our friends in Java land are insisting on passing data between Java and PL/SQL using fairly small XML documents (don't ask). I then need to extract the input parameter values and pass them, on to the stored procedures that actually do the work. These return a result which needs to be returned to the java layer in the output XML document.
    Here is a cut down version of the input XML...
    <ParameterList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Parameter>
    <Id>1</Id>
    <Result xsi:nil="true"/>
    </Parameter>
    <Parameter>
    <Id>2</Id>
    <Result xsi:nil="true"/>
    </Parameter>
    </ParameterList>
    and this is an example of what I am expected to return...
    <ParameterList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Parameter>
    <Id>1</Id>
    *<Result>SUCCESS</Result>*
    </Parameter>
    <Parameter>
    <Id>2</Id>
    *<Result>WARNING</Result>*
    </Parameter>
    </ParameterList>
    i.e. I am expected to replace the value of the Result node with a string indicating the succes or otherwise of the underlying PL/SQL process.
    I am extracting the input values using the DBMS_XMLDOM functions and naively assumed that DBMS_XMLDOM.SETNODEVALUE could be used to update the value in the Result node - It didn't work so I resorted to reading the documentation which revealed that it will not work for a null node.
    Am I going to have to use XSLT to generate the output XML from the Input and incorprate the result? Or is there a simpler way?
    I have used XSLT in Oracle before and still have the nervous tick...

    Thanks A Non,
    With your suggestion and a bit of help from the w3schools.com xml dom tutorial I eventually managed to work out how to do this.
    Here is the code (with all my debug stuff in so it looks worse than it is...)
    create or replace
    PROCEDURE ExtractXMLValues (p_inXml IN CLOB ) IS
    l_string VARCHAR2(4000);
    l_value VARCHAR2(4000);
    l_DOM_doc dbms_xmldom.DOMDocument;
    l_DOM_node dbms_xmldom.DOMNode;
    l_new_DOM_node dbms_xmldom.DOMNode;
    l_new_element dbms_xmldom.DOMElement;
    l_new_DOM_nodevalue dbms_xmldom.DOMNode;
    l_value_Node dbms_xmldom.DOMNode;
    l_parameter_Node dbms_xmldom.DOMNode;
    --l_DOM_nodelist    dbms_xmldom.DOMNodeList;
    l_Result_DOM_node dbms_xmldom.DOMNode;
    BEGIN
    l_DOM_doc := dbms_xmldom.newDomDocument(p_inXml);
    l_DOM_node := dbms_xmldom.makeNode(l_DOM_doc);
    dbms_xmldom.writeToBuffer(l_DOM_node, l_string);
    dbms_output.put_line('1 ' || l_string);
    l_parameter_node := dbms_xslprocessor.selectSingleNode(l_DOM_node,'//Parameter');
    -- get the current values in the XML document for Id and Result
    l_Result_DOM_node := dbms_xslprocessor.selectSingleNode(l_DOM_node,'//Id');
    l_value_Node := dbms_xmldom.getFirstChild(l_Result_DOM_node);
    l_value := dbms_xmldom.getnodevalue(l_value_Node);
    dbms_xmldom.writeToBuffer(l_Result_DOM_node, l_string);
    dbms_output.put_line('2 ' || l_string || ' : ' || l_value);
    l_Result_DOM_node := dbms_xslprocessor.selectSingleNode(l_DOM_node,'//Result');
    l_value_Node := dbms_xmldom.getFirstChild(l_Result_DOM_node);
    l_value := dbms_xmldom.getnodevalue(l_value_Node);
    dbms_xmldom.writeToBuffer(l_Result_DOM_node, l_string);
    dbms_output.put_line('3 ' || l_string || ' : ' || l_value);
    -- create new Result node
    l_new_DOM_node      := dbms_xmldom.makenode(dbms_xmldom.createElement(l_DOM_doc, 'Result'));
    dbms_xmldom.writeToBuffer(l_new_DOM_node, l_string);
    dbms_output.put_line('4 New node : ' || l_string);
    -- create a value for it
    l_new_DOM_nodevalue := dbms_xmldom.makenode(dbms_xmldom.createtextnode(l_DOM_doc, 'SUCCESS'));
    dbms_xmldom.writeToBuffer(l_new_DOM_nodevalue, l_string);
    dbms_output.put_line('5 New node value : ' || l_string);
    -- add the value to the new Result node
    l_new_DOM_nodevalue := dbms_xmldom.appendchild(l_new_DOM_node,  l_new_DOM_nodevalue);
    dbms_xmldom.writeToBuffer(l_new_DOM_node, l_string);
    dbms_output.put_line('6 New node : ' || l_string);
    -- replace the old node with the new one
    l_Result_DOM_node := dbms_xmldom.replaceChild(l_parameter_node, l_new_DOM_node, l_Result_DOM_node);
    dbms_xmldom.writeToBuffer(l_parameter_node, l_string);
    dbms_output.put_line('6 parameter node : ' || l_string);
    dbms_xmldom.writeToBuffer(l_DOM_node, l_string);
    dbms_output.put_line('7 Updated document ' || l_string);
    dbms_xmldom.freeDocument(l_DOM_doc);
    END ExtractXMLValues;
    and the output...
    1 <ParameterList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Parameter>
    <Id>1</Id>
    <Result xsi:nil="true"/>
    </Parameter>
    </ParameterList>
    2 <Id>1</Id> : 1
    3 <Result xsi:nil="true"/> :
    4 New node : <Result/>
    5 New node value : SUCCESS
    6 New node : <Result>SUCCESS</Result>
    6 parameter node : <Parameter>
    <Id>1</Id>
    <Result>SUCCESS</Result>
    </Parameter>
    7 Updated document <ParameterList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Parameter>
    <Id>1</Id>
    *<Result>SUCCESS</Result>*
    </Parameter>
    </ParameterList>
    One question, why do the dbms_xmldom functions return the Old value? I was expecting the returned value to be the updated node.
    Edited by: Lone voice on May 14, 2009 11:24 AM

  • XSLT Mapping - replacing attribute value of a specific node

    Hi,
    I want to replace the value of an attribute for a specific node. Can you please tell me how this can be achieved using XSLT coding?
    The input file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
         <EnvelopeVersion>2.0</EnvelopeVersion>
         <Header>
              <MessageDetails>
                   <Class>IR-PAYE-MOV</Class>
                   <Qualifier>request</Qualifier>
                   <Function>submit</Function>
                   <CorrelationID/>
                   <Transformation>XML</Transformation>
                   <GatewayTimestamp/>
              </MessageDetails>
              <SenderDetails>
                   <IDAuthentication>
                        <SenderID>isv142</SenderID>
                        <Authentication>
                             <Method>MD5</Method>
                             <Value>1L2xFE8WqHHI5iVMGhixAg==</Value>
                        </Authentication>
                   </IDAuthentication>
              </SenderDetails>
         </Header>
         <GovTalkDetails>
              <Keys>
                   <Key Type="TaxOfficeNumber">123</Key>
                   <Key Type="TaxOfficeReference">MD345</Key>
              </Keys>
              <ChannelRouting>
                   <Channel>
                        <URI>0142</URI>
                   </Channel>
              </ChannelRouting>
         </GovTalkDetails>
         <Body>
              <IRenvelope xmlns="http://www.govtalk.gov.uk/taxation/PAYE/MOV/09-10/1">
                   <IRheader>
                        <Keys>
                             <Key Type="TaxOfficeNumber">123</Key>
                             <Key Type="TaxOfficeReference">MD345</Key>
                        </Keys>
                        <PeriodEnd>2009-09-29</PeriodEnd>
                        <DefaultCurrency>GBP</DefaultCurrency>
                        <IRmark Type="generic">03Bfkipk6UDWSXLj77ObBVoK894=</IRmark>
                        <Sender>Company</Sender>
                   </IRheader>
                   <InYearMovements>
                        <EmployerName>form p60</EmployerName>
                        <P46 Statement="A">
                             <Name>
                                  <Fore>Smith</Fore>
                                  <Sur>John</Sur>
                             </Name>
                             <Address>
                                  <Line>Sterling Residency</Line>
                                  <Line>Gehde</Line>
                                  <Line>Hedge End</Line>
                                  <Line>Southampton</Line>
                                  <PostCode>12345678</PostCode>
                             </Address>
                             <WorksNumber>20090030</WorksNumber>
                             <NINO>NP258719D</NINO>
                             <BirthDate>1985-07-11</BirthDate>
                             <Gender>male</Gender>
                             <StartDate>2009-04-20</StartDate>
                             <TaxCodeInUse>647L</TaxCodeInUse>
                        </P46>
                   </InYearMovements>
              </IRenvelope>
         </Body>
    </GovTalkMessage>
    I want to replace the value 'http://www.govtalk.gov.uk/taxation/PAYE/MOV/09-10/1' of attribute xmlns belonging to the node 'IRenvelope' with the value 'http://www.govtalk.gov.uk/taxation/PAYE/MOV/10-11/1'
    So the output of the mapping should be:
    <?xml version="1.0" encoding="UTF-8"?>
    <GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
         <EnvelopeVersion>2.0</EnvelopeVersion>
         <Header>
              <MessageDetails>
                   <Class>IR-PAYE-MOV</Class>
                   <Qualifier>request</Qualifier>
                   <Function>submit</Function>
                   <CorrelationID/>
                   <Transformation>XML</Transformation>
                   <GatewayTimestamp/>
              </MessageDetails>
              <SenderDetails>
                   <IDAuthentication>
                        <SenderID>isv142</SenderID>
                        <Authentication>
                             <Method>MD5</Method>
                             <Value>1L2xFE8WqHHI5iVMGhixAg==</Value>
                        </Authentication>
                   </IDAuthentication>
              </SenderDetails>
         </Header>
         <GovTalkDetails>
              <Keys>
                   <Key Type="TaxOfficeNumber">123</Key>
                   <Key Type="TaxOfficeReference">MD345</Key>
              </Keys>
              <ChannelRouting>
                   <Channel>
                        <URI>0142</URI>
                   </Channel>
              </ChannelRouting>
         </GovTalkDetails>
         <Body>
              <IRenvelope xmlns="http://www.govtalk.gov.uk/taxation/PAYE/MOV/10-11/1">
                   <IRheader>
                        <Keys>
                             <Key Type="TaxOfficeNumber">123</Key>
                             <Key Type="TaxOfficeReference">MD345</Key>
                        </Keys>
                        <PeriodEnd>2009-09-29</PeriodEnd>
                        <DefaultCurrency>GBP</DefaultCurrency>
                        <IRmark Type="generic">03Bfkipk6UDWSXLj77ObBVoK894=</IRmark>
                        <Sender>Company</Sender>
                   </IRheader>
                   <InYearMovements>
                        <EmployerName>form p60</EmployerName>
                        <P46 Statement="A">
                             <Name>
                                  <Fore>Smith</Fore>
                                  <Sur>John</Sur>
                             </Name>
                             <Address>
                                  <Line>Sterling Residency</Line>
                                  <Line>Gehde</Line>
                                  <Line>Hedge End</Line>
                                  <Line>Southampton</Line>
                                  <PostCode>12345678</PostCode>
                             </Address>
                             <WorksNumber>20090030</WorksNumber>
                             <NINO>NP258719D</NINO>
                             <BirthDate>1985-07-11</BirthDate>
                             <Gender>male</Gender>
                             <StartDate>2009-04-20</StartDate>
                             <TaxCodeInUse>647L</TaxCodeInUse>
                        </P46>
                   </InYearMovements>
              </IRenvelope>
         </Body>
    </GovTalkMessage>
    Thanks & Regards,
    Aditi Naik

    Hi,
    You get name of an attribute by this code
    <xsl:for-each select="@*">
        <xsl:text>Value of </xsl:text>
               <xsl:value-of select="name(.)"/>
        <xsl:text> is </xsl:text><xsl:value-of select="."/>
    </xsl:for-each>
    Change value by providing new value in <xsl:value-of select="."/>
    Regards
    suraj

  • How to search for a text node with a particular value in an xml document with labview

    supposing i have the following xml document:
    <head>
    <book>
    <bookname>zio</bookname>
    <author>dan</author>
    </book>
    <book>
    <bookname>the spear warrior</bookname>
    <author>britney</author>
    </book>
    <book>
    <bookname>the beard</bookname>
    <author>derrick</author>
    </book>
    </head>
    i want to search for the author of the book "the beard" using for example the V.I Get first match  of labview to access the the node with value "the beard" and then use Get next sibling  V.I  and Get node text content to get get the author of this book..so my question is how do i write the xpath expression for Get first match so as to access the node with bookname "the beard" instantyly?  am trying to minimise the use of loops because they increase the time duration,..thank you (NB:i dont want to use Get all Matched V.I because it obliges me to use a loop in order to access the name derrick and this increases the time duration for my v.i)
    Solved!
    Go to Solution.

    Since it's all text, why not use a real quick Match Pattern (or Regular Expression, but you don't need that much power here), see attached.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ
    Attachments:
    Two-stage match demo.vi ‏8 KB

  • Using XSLT to extract value of a XML node with namespace

    I have a XML source code here.
    <?xml version="1.0" encoding="utf-8" ?>
    <rss version="2.0" xmlns:job="http://www.pageuppeople.com">
      <channel>
        <title>SMH Jobs</title>
        <link>internalrecruitment.smhgroup.com.au/jobsrss.ashx?stp=di</link>
        <description>A listing of jobs available here</description>
        <item>
          <title>eCommerce Optimisation Advisor</title>
          <description>A new and exciting opportunity exists for an experienced eCommerce Advisor to join</description>
          <job:location PUReferenceID="3711">Sydney - Inner Suburbs & CBD</job:location>
        </item>
      </channel>
    </rss>
    I want to use XSLT to extract value of a XML node with namespace <job:location>, and the returned value should be string 'Sydney - Inner Suburbs & CBD'. I tried a few XSL code below, but failed with error or nothing was returned.
    <xsl:value-of select="job:location" disable-output-escaping="yes"/>
    <xsl:value-of select="job/location" disable-output-escaping="yes"/>
    <xsl:value-of select="job\location" disable-output-escaping="yes"/>
    <xsl:value-of select="location" disable-output-escaping="yes"/>
    This might be an easy question for you, but I would appreciate if anyone can help.

    Hi Suncorp IT Learner,
    We need to tell the XSLT that some elements are in another namespace. Copy the xmls declarations for the prefixes you need to use. Then use the xsl format as:
    <xsl: value-of select=”job:location/@PUReferenceID”/>
    In following issue, Chriztian has a good explanation:
    http://our.umbraco.org/forum/developers/xslt/33353-XSLT-reading-XML-attribute-value
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Value nodes with depth in Context - programmatically binding.

    I am resonably new to Java Webdynpro and have been unable to solve this issue so far if someone has a link to a implementation (pseudo code) it would be greatly appreciated.
    I have a context supplied from an interface that is not flat.
    With data in the context it may look something like this with value attributes in each Node
    Context -
    -Node A1
               --- Node B1
               --- Node B2
    - Node A2
               --- Node B3
               --- Node B4
    If the A nodes where only nodes I could loop through the number of Nodes I wanted to create, something like;
       INodeAElement tempNode = wdContext.createNodeAElement();
       tempNode.setAttributes ..........
       wdContext.NodeNodeA.bind(tempNode).
    or build and arraylist and bind that ...but when it comes to a Node with daughter Nodes I havent the slight idea of how to build the structure. I'm sure its a very simple answer but I have no idea how to do it, and I havent been able to find any reference on how to do it.
    Can anyone point me in the right direction ..
    thanks in advance.

    Context -
    -Node A1
    --- Node B1
    --- Node B2
    - Node A2
    --- Node B3
    --- Node B4
    It depends on if the B-nodes are singleton or non-singleton child nodes.
    For non-singleton child nodes there exists one B-node for each A-node-element.
    In that case the context can be filled like this:
    IA1Element a1 = wdContext.nodeA1().createAndAddA1Element();
    for (int i = 0; i < some_number; ++i)
      IB1Element b1 = a1.nodeB1().createAndAddB1Element();
    for (int i = 0; i < some_number; ++i)
      IB2Element b2 = a1.nodeB2().createAndAddB2Element();
    And so on.
    Armin

  • How can I replace column value with a particular value in SQL

    Hi All,
    Can anyone please tell me how can I format my output with replacing a column value with a specific value which actually depends on the present value of the column
    I am executing the following SQL statement
    select state,count(id) from <table_name> where composite_dn= <composite_dn_name> group by state;
    My Present output is:
    State No.Of Instance
    1 3
    3 28
    I want to replace the value in the column state as follows
    State No.OfInstances
    Completed 3
    Faulted 28
    I want "1" to be reppaced by "Completed" and "3" to be replaced by "Faulted"
    Is is possible with SQL or PL/SQL , if it is then how can I achieve this required result. Please help!!
    Thanks in Advance!!
    Edited by: Roshni Shankar on Oct 27, 2012 12:38 AM

    Hi Roshni,
    I guess this CASE clause can be simulated by a DECODE and also it is very easy to use.
    Refer -- http://www.techonthenet.com/oracle/functions/decode.php
    select decode(t1.state,t2.state_id,t2.state_name), t1.count_id
    from <table_2> t2, (select state,count(id) count_id
    from <table_name>
    where composite_dn= <composite_dn_name>
    group by state) t1
    where t1.state = t2.state_id;HTH
    Ranit B.
    Edited by: ranit B on Oct 27, 2012 2:02 PM
    -- link added
    Edited by: ranit B on Oct 27, 2012 2:19 PM
    -- sample code added

  • Replacing the same value in a string with varying values

    If I have a string:
    "%s is the %s I am referring to"
    and - I want to replace the %s occurrences with DIFFERENT values... what's the best way to do this.
    I was thinking parsing it into seperate strings using substr and instr but, I'm not sure if that's overkill or not.
    Replace is ideal but - it replaces every occurrence so - you can state just replace the first occurrence with one value and the second with another (i.e. if the desired result after replacing the above string was supposed to be "This is the string I am referring to"
    Any help is appreciated.
    Thanks

    Hi,
    wtlshiers wrote:
    If I have a string:
    "%s is the %s I am referring to"
    and - I want to replace the %s occurrences with DIFFERENT values... what's the best way to do this.Whenever you have a question, please post CREATE TABLE and INSERT statements for a little sample data, and the results you want from that data.
    Explain how you get those results from that data.
    Always say which version of Oracle you're using (e.g. 11.2.0.3.0).
    See the forum FAQ {message:id=9360002}
    I was thinking parsing it into seperate strings using substr and instr but, I'm not sure if that's overkill or not.Depending on your requirements, you might need to do that.
    Replace is ideal but - it replaces every occurrence so - you can state just replace the first occurrence with one value and the second with another (i.e. if the desired result after replacing the above string was supposed to be "This is the string I am referring to"As you said, REPLACE changes all occurrences. There's no way to tell it (for example) to change only the first one.
    REGEXP_REPLACE, is a lot more flexible. It does have an option for giving a specific occurrence, but you may not even need that feature. You might just want something like
    REGEXP_REPLACE ( '%s is the %s I am referring to'
                , '(.*)%s(.*)%s(.*)'
                , '\1This\2string\3'
                )It all depends on your data and your requirements.
    Are the new values (such as 'This' and 'string') fixed, or can they change from row to row?
    Will you always have 2 (or some known number) of '%s's in the original string?
    Does '%' always signal something that is to be replaced? If not, how can you tell when it does and when it doesn't?
    Does 's' always come right after '%'? If not, what are the possibilites, and what do the different characters signify?

  • Key probelm w. Generic EnumMap -- How to replace a value with unknown key?

    Hi, i have a problem that i want to replace an value of an key/value pair, but I dont have the approiate key for that, to avoid passing the key throug all methods, I just implemented
    a method in the delegate class.
    public K getFirstAssociatedKey(BilanzObjekt bo){
               Set<K> keys = this.container.keySet();
               for(K key: keys){
                   V value = this.container.get(key);
                   if (bo == value){                    
                        return key;
               return null;
         }It works, but I can't use the retrieved key for a put-statement, cause the satic type comparision seems to fail. Even the key is retrieved from the original, the compilier is unable to validate that the key is in the approiate Enum, so it refuses the operation.
    In my special case I can avoid this by returning the value to the calling mehod inside the delegate, but that can't be the solution for all cases. Even If i would pass the key-vaue through all methods, the universial declaraction of ? extends Enum<?> would raise the same problem, that the compiler can't verify if the given key ist part of the Enum of the current EnumMap.
    Cause i still not an expert dfor generics, I might have overseen an solution.
    So is there any way to retrieve valid keys for the put-method at runtime without declaring a specilized subtype? Using rawtypes would supress compiler-errors, but that isn't the way what Generics intends. I allready have some lager Enums and some subsuets with EnumSet. But this solution isn't absolutly clean, cause you have to use the EnumSet to Iterate over the map and can't use keySet() anymore (Without special preparations for the values not contained in the EnumSet). Also I don't want to limit the code to only one type of Enum. So I my looking for another solution.
    Is there hoepfully any easy and gernerally solution to that problem?
    Thanks a lot in advance.
    Greetings Michael

    Hi, I redesigned my programm a little bit by returning the Objeckt which should be replaced to the delegate, but this causes the problem that I know that it is the exact type, cause the previous value had the same type before, but I can't replace it as long I don't except a fixed type for the value-parameter of the EnumMap.
    The workaround which worked with keys via Map.Entry, cause I didn't replaced them, don't work here.
    I found a solution which works for me (after the redisign mentioned above), even it is quite dirty., cause it moves the error detection form compiletime to runtime. But to gain more flexibilty, i prefer this. The else clause is just to find some programming faults as early as possible. I was quite suprised that the cast to V is legal, but the put -method will throw a ClassCastEcxception if it is not. So its a trade off betwenn flexibility and early error detection. I'm sure that should not used widely, but is a soluion or workaround for my problem.
    /* dirty cast */
    V new_v = (V) old.getReplacingValue();
                        if ( new_v != null){
                                  /* If the both instance are of the same base class, this operation is safe,
                                   * Cause if the previous value was ok, then the new value must be also OK!
                                   * This should be the default case.*/
                             if(new_v.getClass().getName().equals( old.getClass().getName()) ){                         
                                         this.container.put(key,  new_v);                         
                               }else{
                             /* Otherwise a class-cast exception is most likely,
                              * but should normally not reached, if replacing methods are always returning the most specialized type and are overwritten in all subtypes.  */
                                 try{
                                  this.container.put(key,  eBoNew);
                                  }catch(ClassCastException cce){
                                  cce.printStackTrace();
                   }Greetings Michael

  • How to replace key value with character

    Hi Experts
    Can any one tell me, how to replace key value with character, whether it is possible are not. My present report is displaying below format.
    country--city-area-flatnocountry--City-Flatno
    Customer--USACOst1111---UK--HD20--
    C100--11---11--
    C200--11---1--
    For the above example format i am able to display. But now i want to replace 1 with character value for example. For C100
    country is USA at presnt 1 but it should replace with USA.
    You find required format below.
    country--city-area-flatnocountry--City-Flatno
    Customer--USACOst1111---UK--HD20--
    C100--USACOst1111--
    C200--UK--HD20--
    thanks .
    Regards,
    Vishal.

    Hi Markus,
    Thanks for reply,
    Actually i dont have attribute for the customer, the data is maintained in ods, in the form, customer name one info-object and customer value one more info-object this value got text. This value stored in the ods as below
    costomer number  customer value
    C100--USA
    -C100CO
    C100--11-
    C200----
    UK
    C200----
    20
    Please let me know any clarification you need.
    Thanks and Regards,
    Vishal.

Maybe you are looking for

  • Need to add information/data to the Quote Print output for a quote

    I am trying to modify the print quote output generated after selecting a quote on the quote form. I need to know how to add information to this output. I am not sure where the output is selected from. How do I modify the select to include information

  • Userexit -- TVAK-LISOF

    Hi In sales document there is field TVAK-LISOF - immediate delivery.  With the document type (example ZOR having TVAK-LISOF blank), whenever the sales order is created for specific plants, the TVAK-LISOF field should be set to A. Creation of new docu

  • Lock screen in Xcode

    Hello I'm new in Xcode. I would like to make an Lock Screen application. How can I tell the textfield that when the word 'test' is entered, the program closes.But if Ienter a different word should appear a message. Example code would be helpful. Than

  • Visio document imported into a SharePoint VisioWebAccess webpart : open links in new tab or window

    Hello. I'm using a SharePoint Server 2010, with a Visio Web Access WebPart. With Visio 2010, I created a vdw document which I put in this webpart. This works very well, but i have some hyperlinks which I want to be opened in a new tab (or a new windo

  • Syncing deletes some contacts in outlook and creates duplicates on iPhone

    I've got an odd problem here and I'm not sure how long it's been going on ... I have an iPhone 5s running iOS7.0.6 I have a Windows Vista PC running Outlook 2007 Itunes is V11.1.3.8 I do NOT use iCloud or a Microsoft Exchange server It is just a loca