Append xml elements to a file

Ok. After solve the problem of append to files using a file adapter in osb (Re: Write/Append text file with OSB now i want to know if there is some way to append elements to an existant xml. For each request i will have the following message:
<root_node>
<msg>
<element />
<element />
<inner>
<inner_data />
</inner>
<inner>
<inner_data />
</inner>
<msg>
</root_node>
And, for two requests ai want to log:
<root_node>
<msg>
<element />
<element />
<inner>
<inner_data />
</inner>
<inner>
<inner_data />
</inner>
<msg>
<msg>
<element />
<element />
<inner>
<inner_data />
</inner>
<inner>
<inner_data />
</inner>
<msg>
</root_node>
And no:
<root_node>
<msg>
<element />
<element />
<inner>
<inner_data />
</inner>
<inner>
<inner_data />
</inner>
<msg>
</root_node>
<root_node>
<msg>
<element />
<element />
<inner>
<inner_data />
</inner>
<inner>
<inner_data />
</inner>
<msg>
</root_node>
As i'm doing (in my tests).
Thank you.

do you want to append/insert nodes in the file
or do you want to construct that xml first in the osb and after that insert the xml in the file ?
http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/modelingmessageflow.html
Message Processing Actions
Insert activity
you can use the insert activity to insert/append xml parts in your payload, and when the format is done, write it to the file

Similar Messages

  • Appending XML data to a file using file adaptor

    Hi,
    I am trying to append data to a file using file adaptor in XML format. (Objective is to store data as XML message in the file). I understand it is possible to append data to an existing file by making appropriate changes in WSDL manually. However, my issue is every time the XML data is appended to a file even the XML header message is also getting appended. As a result the file data does not adhere to defined schema structure anymore.
    Is there a way to save XML data in a file in append mode ?
    Thanks, Riz

    I am having the same issue as well, which makes the output XML an invalid one. I have an XSD that has a hierarchy of elements. whenever I am wiriting the child elements the header message & the name space is also getting written. For example
    <?xml version="1.0" ?><Parent xmlns="http://testSchema.com/outputSchema">
    <StartDate>01/01/2001</StartDate>
    <EndDate>01/30/2001</EndDate>
    <Child/>
    </Parent>
    <?xml version="1.0" ?><Child xmlns:ns1="http://testSchema.com/outputSchema">
    <ns1:Id>20012981</ns1:Id>
    <ns1:Value/>
    <ns1:Date>01/15/2001</ns1:Date>
    </Child>
    <?xml version="1.0" ?><Child xmlns:ns1="http://testSchema.com/outputSchema">
    <ns1:Id>20012981</ns1:Id>
    <ns1:Value/>
    <ns1:Date>01/15/2001</ns1:Date>
    </Child>
    I am using a onefile adapter partnerlink to write the parent & an another one for writing the child element, since the child elements will repeat more than once. One other way to fix this issue is write the data using java embedded activity, but that would need a lot of boiler plate code, for writing/reading/appending the same file & for handling all those IOexceptions & buffer IN/outs. I am curious if someone had the same issue & how they resolved it.

  • Append XML elements with same name in an XML document

    Hi,
    I am using Oracle9i XMLDB utilities to modify an XML document stored in the database. I have a sample XML document like this in the database:
    <Person>
    <Address ID="1"> </Address>
    </Person>
    My task is to include a second <Address> element with a different attribute so that my XML document will become
    <Person>
    <Address ID="1"> </Address>
    <Address ID="2"> </Address>
    </Person>
    After creating the second element, I am using the function xmldom.appendChild() or xmldom.insertBefore() but they remove the first <Address> element and replace it with the second one. This is not what I want since I want both <Address> elements to be present.
    Could anyone please advise.
    Thanks.
    A. Dennis

    Please post your question [url http://forums.oracle.com/forums/forum.jsp?forum=154]here for quick response.
    thank you.
    Regards,
    Anupama
    [url http://otn.oracle.com/sample_code/]OTN Sample Code

  • Howto use Converting File Content in Rec. Adapt. to suppress a xml-element

    Hi,
    we use PI/700, SP6.
    I have following structure (example):
    <MsgOut>
      <Sender>Partner1</Sender>
      <Receiver>Partner2</Receiver>
      <FlatPayload>
         blabla blabla
      </FlatPayload>
    </Msgout>
    Now I wanna use a XI-File-Adapter to write just a Flat-File with the content (of the element <FlatPayload>):
        blabla blabla
    (in other words: I wanna suppress all other xml-elements beside of FlatPayload)
    But I'm not able to configurate this with the function "Converting File Content"
    I tried different possiblities:
    e.g.
    setting yyy.fieldFixedLengths = 0 and yyy.fixedLengthTooShortHandling = Cut
    (yyy = Sender and Receiver)
    or
    just defining "MsgOut,FlatPayload" as RecordSet Structure (without Sender and Receiver)
    Result: no success.
    Now my question: is it possible to suppress some xml-elements?
    Thanks for your help!
    bye
    Wolfgang

    HI,
    You can suppress the XML Nodes/Elements over here. Not Fields ..
    For e.g if your outout xml is like this
    <MsgOut>
        <Sender>Partner1</Sender>
        <Receiver>Partner2</Receiver>
    <FlatPayload>
       <flatdata> blabla blabla</flatdatat>
    </FlatPayload>
    </Msgout>
    In this case you can suppress the <FlatPayload> node/element here.. Using Cut Parameter in the Receiver File Content COnversion.
    /people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12
    So in your case, you can restructure your data type as you required.. I have mentioned in vice-versa here
    Hope this helps,
    Regards,
    Moorthy
    Message was edited by: Krishna Moorthy P

  • Need solu to Append the data frm different files..Element 'Rec' not expecte

    i need solution to append the data coming from different files.
    sample file is of format
    Header Records
    Data Records
    i need to append the data coming from files to single file which consist of single header and data records from all the four files.
    Using assign activity to append the Data Record. but not able to force the data to write in the target location
    Facing following error..
    Record in the below error is data records. i can view all the appended data put variable.but facing following error Element 'Record' not expected.
    <Record>
    <RecType>1</RecType>
    <SSAppsID>ICD </SSAppsID>
    <TSAppsID>NPS </TSAppsID>
    <FileType>CUSTOMER</FileType>
    <SeqNo>0030</SeqNo>
    <CusNum>50902 </CusNum>
    <CSAppID>ICONS </CSAppID>
    <CusName>YTL Communications Sdn Bhd </CusName>
    <OldIDCardNum/>
    <NewIdentyCardNum/>
    <PassPortNum/>
    <BusinessRegNum/>
    <Police_armyPerNum/>
    <SEGCode>W20</SEGCode>
    <SecCode/>
    <NewSegCode/>
    <IcareMAsterAccNum/>
    </Record>
    </Record>
    </Root-Element>
    </part>
    </PutFilesToTarget_Put_InputVariable>
    </input>
    <fault>
    <bpelFault>
    <faultType>0</faultType>
    <bindingFault>
    <part name="summary">
    <summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Put_InboxNew' failed due to: Translation Error. Translation Error. Error while translating message to native format. Please make sure that the payload for the outbound interaction conforms to the schema. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
    </part>
    <part name="detail">
    <detail>Element 'Record' not expected.</detail>
    </part>
    <part name="code">
    <code>null</code>
    </part>
    </bindingFault>
    </bpelFault>
    </fault>
    <faultType>
    <message>0</message>
    </faultType>
    </messages>

    ya i am reading the data and writing the data with the same format..
    but i need to append data from different files..eliminating the header from second file..
    i am invoking the write adapter out of the while loop..
    this seems some problem while writing..its looking for data records still..

  • Js load xml element - style match from another file

    Hi all
    I got a ID file with a placed xml file, all styles are prepaired.
    Now I would like to load the xml element <-> style match from a given template file, where I prepaired all the matches.
    I would imagine this is a bit like loading the styles or the swatches from another file, but have not found any code samples yet.
    Can anybody help?
    Thanks
    Romano

    js for Structure; XML; Map Tags to Styles...
    I don't think that is what I am looking for and I feel I must asked this question in an unclear way...
    so I started a new discussen with the above heading.
    Thank you anyway.
    Romano

  • [XMLType] : Appending list of XML elements

    hi everybody,
    I have a lttle question : a would like to append a list of XML elements to another XML document :
    I have two XMLs :
    <rowset><A>..</A> <A>..</A></rowset> (1)
    and
    <rowset><B>..</B> <B>..</B></rowset> (2)
    and I would like to have
    <rowset><A>..</A> <A>..</A><B>..</B> <B>..</B></rowset>
    I have generated the two XML (1) and (2) by using DBMS_XMLGEN package, and I have them stored in an XMLType, but I dont know how to operate to get the wanted result.
    Can anybody tell me how to do this in a PL/SQL program?
    thanks,
    Marie.

    I don't use XSLT, i just query the XML-documents stored in an XMLType column with a simple SQL-statement.
    I have posted a simple example over here Re: Is it possible to influence the creation of empty elements?

  • Carriage Returns and Tabs in XML element

    I have a number of carriage returns and tabs within an xml element. When I take that element I would like it to transform to html in which I am then displaying within a JEditorPane. However, when I do this it is one long string. I have tried the xml:space="preserve" within that element and this still is not working.
    Here is part of the xml with the carriage return line feeds. The element that I am talking about is called pseudocode. You can see it is displayed correctly below.
    Design Document XML : <?xml version="1.0" encoding="ISO-8859-1"?><design-doc><title-page><title>Testing Document</title><class-prepared-for>Lloyd</class-prepared-for><authors>Ben Garbers</authors><date-created>September 23, 2004</date-created></title-page><introduction text="This is the introduction. This is the introduction."/><class-definitions><class-definition class-name="ClassOne" visibility="public" class-complexity="not complex"><global-variables><variable visibility="public" name="VariableOne" object="String" comments="This is a String."/><variable visibility="public" name="VariableTwo" object="Integer" comments="This is an Integer."/></global-variables><methods><method name="MethodOne" synopsis="This will do some things." purpose="public" visibility="public"><input-parms><variable visibility="null" name="firstName" object="String" comments="null"/></input-parms><output-parms><variable visibility="null" name="lastName" object="String" comments="null"/></output-parms><local-variables><variable visibility="null" name="age" object="int" comments="null"/></local-variables><pseudocode xml:space="preserve">/* Ensure that player name exist in the system*/
    if (player =null)
         NullPlayerException;
              if (NOT (isPlayerNameExist(player)))
                   throw PlayerNameNotExistException;
              /* Ensure player name exist in the team already*/
              i ? 1;
              while (i <= length(mPlayers)) {
                   if (mPlayers.mPlayerName != playerName)
                        throw PlayerNameNotExistInTeamException;
    this.mPlayers ? this.mPlayers - player;</pseudocode>
    However, when I do the transformation I get the following with the pseudocode:
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    It looks like it adds some spaces but no carriage returns or line feeds.
    My transformation code is the following:
         public ParseFile(String xmlString) {
              try {
              //Here we will load the correct style sheet for the message
              //that will be formatted.
              String urlString = "DesignDocument.xsl";
              URL url = this.getClass().getResource(urlString);
              System.out.println("URL to style sheet = " + url.toString());
              String styleSheetName = url.getFile();
              System.out.println("Style sheet name : " + styleSheetName);
              InputStream styleSheetInputStream = this.getClass().getResourceAsStream(urlString);
              //We will than load our SAXParerFactory and parse the message.
              SAXParserFactory SPFactory = SAXParserFactory.newInstance();
              SPFactory.setValidating(true);
              SAXParser sp = SPFactory.newSAXParser();
              XMLReader sax2parser = sp.getXMLReader();
              //NO Validation done on for this because we do NOT have a DTD.
              sax2parser.setFeature(
                   "http://xml.org/sax/features/validation",
                   false);
              sax2parser.setContentHandler(new FileContentHandler());
              //we create a character array of the length of the xml message String
              char[] messageCharacterArray =
                   new char[xmlString.length()];
              // we then put the xml string into the character array.
              messageCharacterArray = xmlString.toCharArray();
              // after this ew end up creating a CharArrayReader that will be used by the Sax
              // parser to parse the xml.
              CharArrayReader xmlCharArrayReader =
                   new CharArrayReader(messageCharacterArray);
              // we put the xml character array within the Input Source which will then be parsed
              // by the Sax2 parser.
              InputSource in = new InputSource(xmlCharArrayReader);
              // Use a Transformer for outputting the message into our formatted xml using
              // the stylesheet defined up in a messages own sxl stylesheet file.
              TransformerFactory tFactory = TransformerFactory.newInstance();
              tFactory.setURIResolver(new BasicURIResolver());
              StreamSource stylesource = new StreamSource(styleSheetInputStream);
              Transformer transformer = tFactory.newTransformer(stylesource);
    //          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    //          transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          Properties properties = new Properties();
    //          properties.setProperty("indent", "yes");
    //          properties.setProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          transformer.setOutputProperties(properties);
              // We will use a ByteArrayOutputStream to put our transformed xml.
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              StreamResult result = new StreamResult(bos);
              SAXSource source = new SAXSource(in);
              transformer.transform(source, result);
              String s = bos.toString();
              StringBuffer sb = new StringBuffer();
              //This will make sure the Version Line is not shown.
              BufferedReader br = new BufferedReader(new StringReader(s));
              String line = "";
              while ((line = br.readLine()) != null) {
                        sb.append(line);
              bos.close();
              br.close();
              formattedXmlString = sb.toString();
              System.out.println("--------------------------------");
              System.out.println(formattedXmlString);
              System.out.println("--------------------------------");
              } catch (Exception e) {
                   e.printStackTrace();
    I have been searching and trying to figure this out forever. Any help would be greatly appreciated. Bottom line is that I want carriage returns and tabs to work when transferring from the xml to xsl.

    I get the following line when adding the <pre> tags.
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    On the screen this is shown on 1 line. It looks like the tabs are working correctly. However, the carriage return, line feeds do not seem to be working. The xml that is pushed into the transformation has the carriage returns and line feeds and is formatted correctly. There has to be something happening when the xsl takes the xml String. When I add <BR></BR> within the xml that doesn't seem to work either.
    I am really sumpted. If you could help DrClap I would really be appreciated.

  • SAX, incor. data for XML element, XML 1.1 doc (1.0 ok) in JRE 6 (JRE 5 ok)

    Hello,
    for some reason, the test case below fails when driven with Java 6. Looks like, when long string data is stored in a XML element, DocumentHandler's characters() method will be provided with incorrect data.
    With XML 1.0, parsing works fine in all my tests, Apache Xerces, JRE 5, JRE 6.
    With XML 1.1., parsing works fine with Apache Xerces, JRE5 but not with JRE6.
    I've checked it with latest JRE 6 update 4.
    Anyone else xperiencing such problems with XML1.1 parsing when using JAXP bundled with Java 6?
    I've tried to file a bug at bugdatabase, but for some reason I got no response for my issue - so I'm trying the forum now ;-)
    Thanx for comments
    Merten
    import java.io.StringReader;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    import junit.framework.TestCase;
    import junit.framework.TestResult;
    import junit.framework.TestSuite;
    /** snippet to demonstrate problem in SAXParser */
    public class ProblemWithSAXParser extends TestCase
    public static void main(String[] args)
    TestResult result=junit.textui.TestRunner.run(suite());
    System.exit(result.wasSuccessful() ? 0 : 1);
    private static junit.framework.Test suite()
    final TestSuite ts=new TestSuite();
    ts.addTestSuite(ProblemWithSAXParser.class);
    return (ts);
    /** small DocumentHandler, just waiting for one and only XML element <c></c> */
    class MySAXDocumentHandler extends DefaultHandler
    boolean listening=false;
    public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
    throws SAXException
    System.out.println("startElement uri " + uri + " localName " + localName + " qName " + qName);
    if("c".equals(qName))
    listening=true;
    public void endElement(final String uri, final String localName, final String qName) throws SAXException
    System.out.println("endElement uri " + uri + " localName " + localName + " qName " + qName);
    if("c".equals(qName))
    listening=false;
    public void characters(final char ch[], final int start, final int length) throws SAXException
    if(listening)
    final String str=new String(ch, start, length);
    System.out.println("<c> element, start==" + start + " length==" + length + " ch.length==" + ch.length + " ch=="
    + str);
    sb.append(str);
    private final StringBuffer sb=new StringBuffer();
    /** return what I got for XML element <c></c> */
    public String toString()
    return (sb.toString());
    /** test an XML document with an element <c>, use XML 1.0 and XML 1.1 and some (more)
    * content in the XML element */
    public void testWithSunAndApache() throws Exception
    // test XML element content for <c> element
    final StringBuffer plain_str=new StringBuffer("");
    for(int i=0; i < 500; i++)
    plain_str.append("0123456789 This is some text ").append(i).append(". ");
    final String xml_orig=plain_str.toString();
    // SAX parsers, one Sun, one (original) Apache Xerces
    // accept that Apache Xerces is not in path ...
    final String prop_name="javax.xml.parsers.SAXParserFactory";
    final String prop_val_sun="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
    final String prop_val_apache="org.apache.xerces.jaxp.SAXParserFactoryImpl";
    System.setProperty(prop_name, prop_val_sun);
    final SAXParser sax_sun=SAXParserFactory.newInstance().newSAXParser();
    System.out.println("SaxParser Sun= " + sax_sun);
    assertTrue(("" + sax_sun).indexOf("com.sun.") >= 0);
    System.setProperty(prop_name, prop_val_apache);
    SAXParser sax_apache;
    try
    sax_apache=SAXParserFactory.newInstance().newSAXParser();
    catch(final Throwable t)
    System.err.println("no Apache Xerces in path? " + t);
    sax_apache=null;
    System.out.println("SaxParser Apache= " + sax_apache);
    assertTrue(sax_apache==null || ("" + sax_apache).startsWith("org.apache."));
    // i==0: XML 1.0, i==1: XML 1.1
    for(int i=0; i <= 1; i++)
    assert i == 0 || i == 1;
    final String xml_version=(i == 0 ? "1.0" : "1.1");
    final StringBuffer sb=new StringBuffer("<?xml version=\"" + xml_version + "\" encoding=\"UTF-8\"?><c>");
    sb.append(xml_orig);
    sb.append("</c>");
    final String xml=sb.toString();
    // parse it!
    final StringReader string_reader_sun, string_reader_apache;
    string_reader_sun=new StringReader(xml);
    final InputSource input_source_sun=new InputSource(string_reader_sun);
    string_reader_apache=new StringReader(xml);
    final InputSource input_source_apache=new InputSource(string_reader_apache);
    final MySAXDocumentHandler my_handler_sun, my_handler_apache;
    my_handler_sun=new MySAXDocumentHandler();
    my_handler_apache=new MySAXDocumentHandler();
    sax_sun.parse(input_source_sun, my_handler_sun);
    if(sax_apache!=null)
    sax_apache.parse(input_source_apache, my_handler_apache);
    final String xml_sun=my_handler_sun.toString();
    final String xml_apache=my_handler_apache.toString();
    assertNotNull(xml_sun);
    assertNotNull(xml_apache);
    System.out.println("xml version " + xml_version);
    System.out.println("xml " + xml);
    System.out.println("xml_orig " + xml_orig);
    System.out.println("xml_sun " + xml_sun);
    System.out.println("xml_apache " + xml_apache);
    // test the data returned from DocumentHandler
    if(sax_apache!=null)
    assertEquals(xml_orig, xml_apache);
    assertEquals(xml_orig.length(), xml_sun.length()); // length seems to be okay
    assertEquals(xml_orig, xml_sun); // content seems to be not okay for XML 1.1
    }

    thanx, DrClap, haven't seen the "code" button for some reason, code is attached again
    The output of my test is like this for JRE6 (truncated)
    xml_sun 456789 This is is some text 0. 0123456789 This is some text 1.
    xml_apache 0123456789 This is some text 0. 0123456789 This is some text 1.
    Notice, xml_sun not only starts wrong ("0123" missing) - for some reason, the text there is not "This is some text" but "This is is some text" - very interesting in a way. I guess there's an issue with repeated text chunks ...
    So, the data in my XML element is kind of changed, the length of the string is okay but the characters are "misplaced" or so :-) I thought about a problem with StringBuffer first, but the StringBuffer works fine for Apache ... so I really think there's an issue with JRE 6's parser for XML 1.1
    Merten
    import java.io.StringReader;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    import junit.framework.TestCase;
    import junit.framework.TestResult;
    import junit.framework.TestSuite;
    /** snippet to demonstrate problem in SAXParser */
    public class ProblemWithSAXParser extends TestCase
    public static void main(String[] args)
      TestResult result=junit.textui.TestRunner.run(suite());
      System.exit(result.wasSuccessful() ? 0 : 1);
    private static junit.framework.Test suite()
      final TestSuite ts=new TestSuite();
      ts.addTestSuite(ProblemWithSAXParser.class);
      return (ts);
    /** small DocumentHandler, just waiting for one and only XML element <c></c> */
    class MySAXDocumentHandler extends DefaultHandler
      boolean listening=false;
      public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
        throws SAXException
       System.out.println("startElement uri " + uri + " localName " + localName + " qName " + qName);
       if("c".equals(qName))
        listening=true;
      public void endElement(final String uri, final String localName, final String qName) throws SAXException
       System.out.println("endElement uri " + uri + " localName " + localName + " qName " + qName);
       if("c".equals(qName))
        listening=false;
      public void characters(final char ch[], final int start, final int length) throws SAXException
       if(listening)
        final String str=new String(ch, start, length);
        System.out.println("<c> element, start==" + start + " length==" + length + " ch.length==" + ch.length + " ch=="
          + str);
        sb.append(str);
      private final StringBuffer sb=new StringBuffer();
      /** return what I got for XML element <c></c> */
      public String toString()
       return (sb.toString());
    /** test an XML document with an element <c>, use XML 1.0 and XML 1.1 and some (more)
      * content in the XML element */
    public void testWithSunAndApache() throws Exception
      // test XML element content for <c> element
      final StringBuffer plain_str=new StringBuffer("");
      for(int i=0; i < 500; i++)
       plain_str.append("0123456789 This is some text ").append(i).append(". ");
      final String xml_orig=plain_str.toString();
      // SAX parsers, one Sun, one (original) Apache Xerces
      // accept that Apache Xerces is not in path ...
      final String prop_name="javax.xml.parsers.SAXParserFactory";
      final String prop_val_sun="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
      final String prop_val_apache="org.apache.xerces.jaxp.SAXParserFactoryImpl";
      System.setProperty(prop_name, prop_val_sun);
      final SAXParser sax_sun=SAXParserFactory.newInstance().newSAXParser();
      System.out.println("SaxParser Sun= " + sax_sun);
      assertTrue(("" + sax_sun).indexOf("com.sun.") >= 0);
      System.setProperty(prop_name, prop_val_apache);
      SAXParser sax_apache;
      try
       sax_apache=SAXParserFactory.newInstance().newSAXParser();
      catch(final Throwable t)
       System.err.println("no Apache Xerces in path? " + t);
       sax_apache=null;
      System.out.println("SaxParser Apache= " + sax_apache);
      assertTrue(sax_apache==null || ("" + sax_apache).startsWith("org.apache."));
      // i==0: XML 1.0, i==1: XML 1.1
      for(int i=0; i <= 1; i++)
       assert i == 0 || i == 1;
       final String xml_version=(i == 0 ? "1.0" : "1.1");
       final StringBuffer sb=new StringBuffer("<?xml version=\"" + xml_version + "\" encoding=\"UTF-8\"?><c>");
       sb.append(xml_orig);
       sb.append("</c>");
       final String xml=sb.toString();
       // parse it!
       final StringReader string_reader_sun, string_reader_apache;
       string_reader_sun=new StringReader(xml);
       final InputSource input_source_sun=new InputSource(string_reader_sun);
       string_reader_apache=new StringReader(xml);
       final InputSource input_source_apache=new InputSource(string_reader_apache);
       final MySAXDocumentHandler my_handler_sun, my_handler_apache;
       my_handler_sun=new MySAXDocumentHandler();
       my_handler_apache=new MySAXDocumentHandler();
       sax_sun.parse(input_source_sun, my_handler_sun);
       if(sax_apache!=null)
        sax_apache.parse(input_source_apache, my_handler_apache);
       final String xml_sun=my_handler_sun.toString();
       final String xml_apache=my_handler_apache.toString();
       assertNotNull(xml_sun);
       assertNotNull(xml_apache);
       System.out.println("xml version " + xml_version);
       System.out.println("xml        " + xml);
       System.out.println("xml_orig   " + xml_orig);
       System.out.println("xml_sun    " + xml_sun);
       System.out.println("xml_apache " + xml_apache);
       // test the data returned from DocumentHandler
       if(sax_apache!=null)
        assertEquals(xml_orig, xml_apache);
       assertEquals(xml_orig.length(), xml_sun.length()); // length seems to be okay
       assertEquals(xml_orig, xml_sun); // content seems to be not okay for XML 1.1
    }

  • Oracle xml v2 parser collapses xml element nodes

    Hi,
    Whenever I pass load an XML document and parse it using the DOMParser object, it collapses empty XML elements. Eg, if my XML file has the following element:
    <firstname></firstname>, once it passes through the parser, it becomes <firstname/>!
    How can I prevent this from happening? Is there some setting that I can set to stop it?
    Urgent response required.
    thanks!
    neelam

    This is an incorrect statement.
    Whether the incoming document had:
    <x>
    or
    <x></x>
    All that will be reflected in the DOM model is the presence of an "X" Element. An Element does not have a value in the DOM model (anyElement.getNodeValue() ALWAYS returns null). In either case, to associate a child text node with the "X" element, you would have to:
    1) Construct a new Text node
    2) Call appendChild() to append the child text node to the "X" element
    There is no semantic difference, in other words, between <x> and <x></x>

  • How to find out the page number of an xml element

    Hi everybody, sorry for my very bad english (french guy! logical). I hope you see what I'm looking for.
    I'm scripting (javascript) an exporting script of every articles from a multi-pages indesign script.
    In fact I could have one or more article in one file, every one of them is on an separate xml element. for each I have to export an xml file named with, first, the page number where appears the xml element, second, the number of exported article.
    I'm success the second purpose, but not the first.
    Someone have an idea ?

    Try this,
    var myDoc=app.activeDocument;
    var root = myDoc.xmlElements[0];
    var docTag = root.evaluateXPathExpression('//doc');
    for(i=0; i<docTag.length; i++)
        var docPos = docTag[i].insertionPoints.lastItem();
        var docFrame = docPos.parentTextFrames[0];
        var docPage;
        try
             docPage = docFrame.parentPage;
    catch(e)
            docPage = docFrame.parent.name;
        alert(docPage.name);
    Vandy

  • How to display the total of a particular xml element page wise

    Hello friends,
    My requirement is like I need to display an xml element Margin along with the other elements..Now I want the sum of margin element for each page... how do I do it in the rtf template.. and the end user views it in pdf form...
    thanks in advance

    Can you check the example in http://download.oracle.com/docs/cd/E10415_01/doc/bi.1013/e12187/T421739T481157.htm#4535379
    You can also check an example in your local machine in C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\samples\RTF templates\Advanced\Page Total

  • Missing XML Element when using asset from library

    This is not really a scripting question but I seem to be unable to find any regular ID forum and it has something to do with a scripting workflow I established for a customer.
    A script places an asset from a library onto a document and then (amongst other things) imports some XML file.
    The asset in the library consists of a number of textframes and has the structure e.g.:
    article
    box
    box
    Now the customer needs new templates (that is assets in the library) and we cannot produce them anymore. It seems that as of CS 3 5.0.4 Adobe changed the behavior of the library. Dragging e.g. two box-tagged boxes with an article parent XML into the library leads to an asset without the article element. Can someone confirm this? And more important is there a reason to it? Or is there a way to configure the behavior?
    I guess I could create a parent xml element by script after placing the element but then I would need to redo all existing libraries.
    Thank you,
    Ralf

    while( testIterator.hasNext() ) {
       Element testElement = (Element)testIterator.next();
       String code = testElement.getChildTextTrim("code");
        if( null == code ) {
               continue;
       String analysis= testElement.getChildTextTrim("analysis");
       //same for description
    }

  • Can i have xml elements with same name but one is having attrbt..?

    Hi all,
    I am suppose to take input from one system into BPEL.That system is auto gererating xml file. But that file is strange. It has two xml element with
    same name but with completely different sequence. First one is having two comlexTypes while second is having 5 simple types.
    Now the difference is First element is having attribute while second is not.
    So is that file is correct.?
    thanks a lot.
    /mishit

    can you post the file? or load the file into JDeveloper and check the syntax or use XMLSpy for validation of the XML.

  • JMS Queue XML: Elements with same name

    Hi
    I notice that ODI does not do a good job of reverse-engineering JMS queue models where an element name is referenced in different parts of the schema.
    For example:
    root
    ..body
    ...consignment
    ....load
    .....event
    ....unload
    .....event
    etc
    In the above, ODI will reverse-engineer the 'event' element under 'load', but not the one under 'unload'.
    I don't have control over the xsd models and was therefore wondering if there is some sort of workaround I can perform in this scenario?
    Cheers

    Actually, I just found the following Oracle note sums this up: 757642.1
    Is it possible to use the SAME ELEMENT as a SUB-ELEMENT in multiple DIFFERENT Elements of an XML File?
    If so, what is the impact of this approach on the reverse engineered Model and Datastores and how can Integration Interfaces be set up to map these identical ELEMENT for which the content is semantically different and as a result to be used differently in different Oracle Data Integrator (ODI) Integration Interfaces.
    The following XML is a simple example in which the ITEM Element is logically set as a sub-element to three other XML Elements:
    •Shoppinglist
    •GroceryStore
    •HardwareStore
    <Shoppinglist>
    <Item>ShoppingList</Item>
    <GroceryStore>
    <Item>Eggs</Item>
    <Item>Milk</Item>
    <Item>Bread</Item>
    </GroceryStore>
    <HardwareStore>
    <Item>Screwdriver</Item>
    <Item>Hammer</Item>
    <Item>Nails</Item>
    </HardwareStore>
    </Shoppinglist>Solution
    Such an approach must be avoided. This is a strict limitation of the ODI XML Driver.
    See Bug:8563428 DUPLICATE SUBELEMENTS WITH DIFFERETNT TYPES ARE NOT SUPPORTED BY XML DRIVER

Maybe you are looking for

  • Why my FIle sender Communication channel is inactive?

    I tried to edit and save it again, but i can see active at ID but inactive at RWB-->Channelmonitorring.. what to do?

  • Downloading ovi suite

    When I started my ovi player it said I had had to install the new version but when I was downloading it..It showed network error.I can't use ovi now... Help...

  • Content Player showing the error Not ok!

    Hi All, Here we configured learning solution on Portal and given all permissions to the folder where the SCORM content placed and given SAP_ALL permision to the user . But while testing the content player by the url /lms/mediator/config it is giving

  • Can't open and edit html?

    I am trying to to open an html document after creating it, but when it opens it goes directly to the internet and not into plain text?

  • Premiere Pro Crashing on Loading (even empty) Sequences

    Prmiere Pro CS5 freezes and then crashes when I try to open any sequence. It is unusable. I have a new Dell Precision M6700, Windows 7 64bit, SP1, Intel Core I7 3940XM CPU @3.00GHz, 16Gb Ram, NVidia Quadro K5000M. I have uninstalled and reinstalled P