XSLT with DOM/C++ Parser

Help,
Anyone familiar with xslprocess class with DOM Parser for C++? My application needs to transform the original XML document, and then parse the new document (parse elements in tree). The example in the XDK demo directory (XSLSample.cpp) stops short of this. This demo/sample code simply output the newly transformed to the standard output (screen). My attempt to parse the newly transformed XML has been unsuccessful. Most of my code is base direcly from the sample:
void
DbXMLLoad::transformXML( const string& filename)
xmlpar.xmlinit();
strcpy(xml_doc, (char*)filename.c_str());
xmlpar.xmlparse((oratext *), xml_doc, (oratext *) 0, flags);
xslpar.xmlinit();
strcpy(xsl_doc, "it2xxx.xsl");
xslpar.xmlparse((oratext *), xsl_doc, (oratext *) 0, flags);
respar.xmlparse((oratext *) result, (oratext *) 0, flags);
xslproc.xslprocess(&xmlpar, &xslpar, &respar, &result);
xslproc.printres(&respar.getDocumentElement(), 1);
// Parse the newly transformed XML document????
constructTree(result, 1);
(void) xmlpar.xmlterm();
(void) xslpar.xmlterm();
(void) respar.xmlterm();
void
DbXMLLoad::constructTree(Node *node, word level)
if (node) {
dumpTree(node, level);
if ((node->getType() !=DOCUMENT_TYPE_NODE) && node->hasChildNodes()) {
nodes = node->getChildNodes();
n_nodes = node->numChildNodes();
for (i=0; i< n_nodes; i++)
constructTree(nodes->item(i), level + 1);
void
DbXMLLoad::dumpTree(Node *node, uword level)
switch (node->getType()) {
case ELEMENT_NODE: // start database processing
case TEXT_NODE: // continue database processing
default:
Appreciate your help. Thanks in advance
Russ

what is "respar"?What version of XDK do you use?

Similar Messages

  • To convert XML to ABAP internal table can we do it with DOM or we need XSLT

    I have a requirement where I need to collect the data from XML file into an internal table.
    I need to collect this data into an internal table as I should make use of this data and do Goods Receipt in SAP.
    My XML file is very very complex and the child nodes in my XML file may occur ones or 10 times and change dynamically.
    I want to know if XML to ABAP internal table is possible with DOM or does it need XSLT too.
    I used the blog of Robert which uses DOM, but it I am unable to collect the data in internal table. The blog explains only how to wtite the out put to screen as element and value.
    I want to know if XML to ABAP internal table is possible with DOM or do I need XSLT too? I am confused please help.
    Any help will be highly appreciated.
    Regards,
    Jessica Sam

    Hello Jessica
    Why not using the DOM itself for processing?
    Below you see the post-processing coding which I use to add the interchange control number (ICN) into an EDI message (which at this stage is still an XML-EDI stream). This is done on SAP-XI yet on the ABAP stack so you could use this approach on your R/3 system as well.
    method POSTPROCESSING.
    * Post-Processing of outbound EDI invoices & dispatch advices
      me->map_icn( ).
    endmethod.
    method MAP_ICN.
    * define local data
      DATA: lo_node       TYPE REF TO if_ixml_node,
            ld_name       TYPE string,
            ld_value      TYPE string,
            ld_error_code type MPG_ERRCODE,
    **        ld_control_number   TYPE char13,
            ld_rc         TYPE i,
            ld_msg        TYPE string.  " bapi_msg.
      DATA: ld_interface  TYPE string.
      DATA: incode TYPE REF TO if_ixml_node_collection.
      LOG-POINT ID zedi
        SUBKEY mc_subkey_method_trace.
      ld_error_code = md_clsname.
    * Get next interchange control number (ICN)
      me->md_next_number = me->get_next_number(
          id_nrobj  = me->md_nrobj   " Object (SNRO)
          id_nrnr   = me->md_nrnr ). " Number Range
      CALL METHOD zcl_edi_uk_counter=>calculate_modulo_n09
        EXPORTING
          id_input  = me->md_next_number
        receiving
          rd_output = me->md_next_number.
    * Build ICN according to naming conventions agreed with EDI customer
      me->md_icn = me->generate_icn( me->md_next_number ).
      ld_value = me->md_icn.  " type conversion to string
      CLEAR: incode,
             lo_node.
      incode  = me->mo_document->get_elements_by_tag_name( mc_d_0020 ).
      lo_node = incode->get_item( index = 0 ).
      CALL METHOD lo_node->set_value
        EXPORTING
          value = ld_value
        RECEIVING
          rval  = ld_rc.
      IF ( ld_rc NE 0 ).
        CONCATENATE 'Error [' mc_d_0020
                    ']: Method SET_VALUE (IF_IXML_NODE)'
                    INTO ld_msg.
        CONDENSE ld_msg.
        me->mif_trace->trace2( message = ld_msg ).
        RAISE EXCEPTION TYPE cx_mapping_fault
          EXPORTING
    *        textid =
    *        previous =
            error_code = ld_error_code
            error_text = ld_msg.
    **    MESSAGE ld_msg TYPE 'A'.
      ENDIF.
      CLEAR: incode,
             lo_node.
      incode  = me->mo_document->get_elements_by_tag_name( mc_d_0020_2 ).  " element for ICN
      lo_node = incode->get_item( index = 0 ).
      CALL METHOD lo_node->set_value
        EXPORTING
          value = ld_value
        RECEIVING
          rval  = ld_rc.
      IF ( ld_rc NE 0 ).
        CONCATENATE 'Error [' mc_d_0020_2
                    ']: Method SET_VALUE (IF_IXML_NODE)'
                    INTO ld_msg.
        CONDENSE ld_msg.
        me->mif_trace->trace2( message = ld_msg ).
        RAISE EXCEPTION TYPE cx_mapping_fault
          EXPORTING
    *        textid =
    *        previous =
            error_code = ld_error_code
            error_text = ld_msg.
    **    MESSAGE ld_msg TYPE 'A'.
      ENDIF.
    * define local data
      DATA: ls_record       TYPE mpp_dynamic.
      CLEAR: ls_record.
      ls_record-namespace = mc_dynamic_namespace.
      ls_record-name      = mc_icn.
      ls_record-value     = ld_value.
      mif_dynamic->add_record( ls_record ).
    endmethod.
    In your case you would need to do a DO...ENDDO loop until you parsed all required nodes.
    NOTE: ME->MO_DOCUMENT is of TYPE REF TO IF_IXML_DOCUMENT.
    Regards
       Uwe

  • XML Parser for Java v2. Applying XSLT to DOM tree

    I encountered pretty weird behavior of XML Parser for Java v2.
    While applying XSLT to XML document created in memory using DOM
    interface I couldn't access element attributes. For example,
    given the XML document:
    <root>
    <Item ID="00001">Value of Item 00001</Item>
    <Item ID="00002">Value of Item 00002</Item>
    </root>
    and XSLT:
    <xsl:template match="/">
    <HTML>
    <HEAD>
    <TITLE>XSLT Test</TITLE>
    </HEAD>
    <BODY>
    <xsl:for-each select="/Error">
    <H1>Error</H1><xsl:value-of select="."/>
    </xsl:for-each>
    <TABLE border="0" cellspacing="0" cellpadding="2">
    <TBODY>
    <xsl:for-each select="/root">
    <TR>
    <TH style="background-color:khaki">
    <xsl:text>Attribute</xsl:text>
    </TH>
    <TH style="background-color:khaki">
    <xsl:text>Value</xsl:text>
    </TH>
    </TR>
    <xsl:for-each select="Item">
    <TR>
    <TD><xsl:value-of select="@ID"/></TD>
    <TD><xsl:value-of select="."/></TD>
    </TR>
    </xsl:for-each>
    </xsl:for-each>
    </TBODY>
    </TABLE>
    </BODY>
    </HTML>
    </xsl:template>
    If I build DOM tree by parsing XML file the resulting HTML
    document after applying XSLT will display
    Attribute Value
    00001 Value of Item 00001
    00002 Value of Item 00002
    But if I build DOM tree using following code:
    XMLDocument xDoc = new XMLDocument();
    Element root = xDoc.createElement( "root" );
    xDoc.appendChild( root );
    Element elem = xDoc.createElement( "Item" );
    elem.setAttribute( "ID", "00001" );
    root.appendChild( elem ).
    appendChild( xDoc.createTextNode( "Value of Item 00001" ) );
    elem = xDoc.createElement( "Item" );
    elem.setAttribute( "ID", "00002" );
    root.appendChild( elem )
    .appendChild( xDoc.createTextNode( "Value of Item 00002" ) );
    the same XSLT will produce the following HTML output:
    Attribute Value
    Value of Item 00001
    Value of Item 00002
    So the value for the ID attribute is not displayed. At the same
    time I can access this attribute using DOM interface. For
    example, following code
    NodeList nList = xDoc.getElementsByTagName( "Item" );
    Element e;
    for( int i = 0; i < nList.getLength(); i++ )
    e = (Element)nList.item( i );
    System.out.println( "ID: " + e.getAttribute( "ID" ) );
    produces an output
    ID: 00001
    ID: 00002
    Here is the code for applying XSLT to DOM tree:
    DOMParser parser = new DOMParser();
    parser.parse( new FileInputStream( "test.xsl" ) );
    XMLDocument xsldoc = parser.getDocument();
    XSLStylesheet xsl = new XSLStylesheet( xsldoc, createURL( "" ) );
    XMLDocument out = new XMLDocument();
    out.appendChild( new XSLProcessor().processXSL(xsl, xDoc) );
    out.print( new FileOutputStream( "test.html" ) );
    Andrei Filimonov
    null

    We are not getting what you're getting on Solaris. See the
    following:
    Script started on Tue Jun 22 18:53:56 1999
    Processing /view/test/vobs/oracore3/.ndeprodrc.csh
    Processing /private/.nderc.csh
    [test] > cat bruno.xml
    <my_grandpa age="88">
    <my_dad age="66">
    <me age="44">
    <my_son age="22">
    </my_son>
    </me>
    </my_dad>
    </my_grandpa>
    [test] > cat bruno.xsl
    <?xml version="1.0"?>
    <!-- Identity transformation -->
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
    <xsl:template match="me">
    <xsl:value-of select="my_son/@age"/>
    <xsl:value-of select="@age"/>
    <xsl:value-of select="../@age"/>
    <xsl:value-of select="../../@age"/>
    </xsl:template>
    </xsl:stylesheet>
    [test] > java XSLSample bruno.xsl bruno.xml
    <root>
    22446688
    </root>
    [test] > exit
    script done on Tue Jun 22 18:54:22 1999
    What platform are you on and does your stylesheet and xml doc
    match ours?
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Bruno Bontempi (guest) wrote:
    : I had a similar problem in accessing element attributes from
    an
    : XSLT sheet.
    : It seems like the processor correctly accesses element
    attributes
    : in the context node, but does not retrieve values of
    attributes
    : outside the context node.
    : For example, for an XML document like:
    : <my_grandpa age="88">
    : <my_dad age="66">
    : <me age="44">
    : <my_son age="22">
    : </my_son>
    : </me>
    : </my_dad>
    : </my_grandpa>
    : and an XSL stylesheet like:
    : <xsl:template match="me">
    : <xsl:value-of select="my_son/@age"/>
    : <xsl:value-of select="@age"/>
    : <xsl:value-of select="../@age"/>
    : <xsl:value-of select="../../@age"/>
    : </xsl:template>
    : I expect an output like:
    : 22446688
    : but all I get is
    : 44
    : I am also using Jim Clark's XT, which is returning the
    expected
    : result.
    : Thanks in advance for your help,
    : Bruno.
    : Andrei Filimonov (guest) wrote:
    : : I encountered pretty weird behavior of XML Parser for Java
    v2.
    : : While applying XSLT to XML document created in memory using
    DOM
    : : interface I couldn't access element attributes. For example,
    : : given the XML document:
    : : <root>
    : : <Item ID="00001">Value of Item 00001</Item>
    : : <Item ID="00002">Value of Item 00002</Item>
    : : </root>
    : : and XSLT:
    : : <xsl:template match="/">
    : : <HTML>
    : : <HEAD>
    : : <TITLE>XSLT Test</TITLE>
    : : </HEAD>
    : : <BODY>
    : : <xsl:for-each select="/Error">
    : : <H1>Error</H1><xsl:value-of select="."/>
    : : </xsl:for-each>
    : : <TABLE border="0" cellspacing="0" cellpadding="2">
    : : <TBODY>
    : : <xsl:for-each select="/root">
    : : <TR>
    : : <TH style="background-color:khaki">
    : : <xsl:text>Attribute</xsl:text>
    : : </TH>
    : : <TH style="background-color:khaki">
    : : <xsl:text>Value</xsl:text>
    : : </TH>
    : : </TR>
    : : <xsl:for-each select="Item">
    : : <TR>
    : : <TD><xsl:value-of select="@ID"/></TD>
    : : <TD><xsl:value-of select="."/></TD>
    : : </TR>
    : : </xsl:for-each>
    : : </xsl:for-each>
    : : </TBODY>
    : : </TABLE>
    : : </BODY>
    : : </HTML>
    : : </xsl:template>
    : : If I build DOM tree by parsing XML file the resulting HTML
    : : document after applying XSLT will display
    : : Attribute Value
    : : 00001 Value of Item 00001
    : : 00002 Value of Item 00002
    : : But if I build DOM tree using following code:
    : : XMLDocument xDoc = new XMLDocument();
    : : Element root = xDoc.createElement( "root" );
    : : xDoc.appendChild( root );
    : : Element elem = xDoc.createElement( "Item" );
    : : elem.setAttribute( "ID", "00001" );
    : : root.appendChild( elem ).
    : : appendChild( xDoc.createTextNode( "Value of Item
    00001" )
    : : elem = xDoc.createElement( "Item" );
    : : elem.setAttribute( "ID", "00002" );
    : : root.appendChild( elem )
    : : .appendChild( xDoc.createTextNode( "Value of Item
    00002" )
    : : the same XSLT will produce the following HTML output:
    : : Attribute Value
    : : Value of Item 00001
    : : Value of Item 00002
    : : So the value for the ID attribute is not displayed. At the
    same
    : : time I can access this attribute using DOM interface. For
    : : example, following code
    : : NodeList nList = xDoc.getElementsByTagName( "Item" );
    : : Element e;
    : : for( int i = 0; i < nList.getLength(); i++ )
    : : e = (Element)nList.item( i );
    : : System.out.println( "ID: " + e.getAttribute( "ID" ) );
    : : produces an output
    : : ID: 00001
    : : ID: 00002
    : : Here is the code for applying XSLT to DOM tree:
    : : DOMParser parser = new DOMParser();
    : : parser.parse( new FileInputStream( "test.xsl" ) );
    : : XMLDocument xsldoc = parser.getDocument();
    : : XSLStylesheet xsl = new XSLStylesheet( xsldoc, createURL
    : : XMLDocument out = new XMLDocument();
    : : out.appendChild( new XSLProcessor().processXSL(xsl, xDoc) );
    : : out.print( new FileOutputStream( "test.html" ) );
    : : Andrei Filimonov
    null

  • *URGENT * Parsing nd Searching XML with DOM

    Hi,
    I am Juliana, I am a new grad, a new employee and brand new to XML, I am learning to parse XML with the XML parser for PLSQL.
    Please anyone help me how to parse the following XML string so that I will display all the session and its time schedule, or if possible display only the session that I want to display.
    Thank you very much for any of your help
    Juliana
    <Student> Id="9130099">
    <Class>
    <Session>A-100</Session>
    <Session>A-200</Session>
    <Session>A-300</Session>
    <Session>A-400</Session>
    <session>A-500</Session>
    </Class>
    <Time> At:
    <At>10:30</At>
    <At>12:30</At>
    <At>02:30</At>
    <At>04:30</At>
    <At>05:30</At>
    </time>
    </Student>

    thx for the replay
    1) i thought of using xpath but wanted to know how to do it over DOM
    2) i mean that the 3 <item> have other element inside like that:
    <item>
    <title>Implementing Service-Oriented Architectures (SOA) with the Java EE 5 SDK</title>
      <link>http://java.sun.com/developer/technicalArticles/WebServices/soa3/?feed=JSC</link>
      <description>This article presents concepts and language constructs needed to develop a Service-Oriented Architecture composite application in Java EE 5. It then describes an example application designed to solve a business problem.</description>
      <date />
      </item>and all of them have <title>, <link> etc. I want to get the same values(eg. <title>) from all the 3 <item> and not including the <title> in the begining of xml
    3) i am a professional child.....joke....
    try to get to your sensitive side...thats way.

  • XSLT or DOM (urgent)

    when both of them create a tree in the memory before processing is the first any faster than the later? If yes why? Or they are both equally slow. I have had some bad experience with DOM and was now thinking of moving forward to XSLT and trashing DOM, but would it help?
    Its urgent

    hi,
    as areadly pointed out, there should not be a comparision between DOM and XSLT. Well if you want to parse, you can consider three options that i know of,
    1) Dom
    2) Sax
    3) JDom
    you would use Dom if your document size is not too big, you want to perform some kinda query on the nodes after the document is created (for eg perform a seach for a node), for small size documents, DOM is fast and can be quite helpful as you can also change node information and can get to know the hierarchy of the nodes.
    On the Other hand you would use SAX if you want speed, you would require to create your own Object model in this case though, SAX is faster bcaz it readz the XML Document sequentially line by line and then fires events through which you could construct the object model of the XML data. SAX is faster but you have to write a lot more code to get to the data (you have to implement your own ContentHander and ErrorHandler minimally along with the Object model). also sax will not remember the document hierarchy so if you want to query nodes etc after the document has been read, SAX is not a good choice.
    JDOM is i suppose the easiest to use, also the advantage with JDOM is you can internally choose to either use SAX (through SAXBuilder) or DOM (thro DOMBuider), in either case you will get a JDOM Document object, you can then manipulate the object.. The best part about JDOM is that you get advantages of SAX and DOM, you get the node hierarchy, so you can query for specific nodes, child nodes etc.. also you can do changes in the Document and then output it to a file using the XMLOutputter. Also JDOM does not require you to do explicit typecasts as required if you code in DOM (where everything is a NODE ;-) ), ...
    well i guess you need to choose depending on what your application requires and as to which method best helps you achieve the functionality you desire..
    hope this helpz you..
    cheerz
    ynkrish

  • Problem in reading with DOM

    i have the following xml file to read with DOM
    <?xml version="1.0" encoding="UTF-8" ?>
    - <usecasediag>
    - <actor id="1">
      <name>customer</name>
      <usecase>reservation of tour</usecase>
      <usecase>view tour data</usecase>
      <usecase>cancel reservation</usecase>
      <usecase>complain</usecase>
      </actor>
    - <actor id="2">
      <name>employee</name>
      <usecase>access</usecase>
      <usecase>update</usecase>
      </actor>
    </usecasediag>after reading the above file i need to create another XML file using DOM. I have the following code but i am not able to get the value "customer","enployee" while reading the XML file....
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.*;
    import javax.xml.parsers.ParserConfigurationException;
    import com.sun.org.apache.xml.internal.serialize.OutputFormat;
    import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
    class Post
       Document dom; //to read
       Document dwrite; //to write
       Element root;//to read
       Element rootEle;//to write
       Post()
            File docFile = new File("..\\uml\\xml file\\sample.xml");
            try {
                DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                dom= db.parse(docFile);
                  } catch (java.io.IOException e)
                System.out.println("Can't find the file");
                } catch (Exception e)
                System.out.print("Problem parsing the file.");
            Element root = dom.getDocumentElement();
            findActor();
    void findActor()
         Element ele=null;     
         NodeList nl1 = dom.getElementsByTagName("actor");
         if(nl1 != null && nl1.getLength() > 0)
             for(int i = 0 ; i < nl1.getLength();i++)
                   //get each actor element
                   ele = (Element)nl1.item(i);
                   Node nameEle=ele.getFirstChild();//name element
                   Node actnm=nameEle.getFirstChild();//customer
                   String clname=actnm.getNodeValue();
             }//for
         }//if               
    }//classcan anyone figure out the problem...thanx in advance

    you are right...its taking empty tag...i tried doing it some other way but the control is not matching the "if" statement....can you please tell me how do i write code to get the name & usecase element for each actor..
    void findActor()
         Element ele=null;     
         NodeList nl1 = dom.getElementsByTagName("actor"); //all actor tags in XML
         if(nl1 != null && nl1.getLength() > 0)
             for(int i = 0 ; i < nl1.getLength();i++)
                   //get each actor element
                   ele = (Element)nl1.item(i);
                   for(Node child=ele.getFirstChild();child!=null;child=child.getNextSibling())
              if(child.equals("name"))
              { System.out.println("got it");
                   break;
             }//for i loop
         }//if               
    }

  • Thread Safety Issue with DOM

    I am parsing an XML into a DOM object using the Xerces parser that is packaged with JDK 1.5.
    First, I create a new instance of the DocumentBuilderFactory and then using the factory, create a new DocumentBuilder. I then parse the XML using the DocumentBuilder to obtain a DOM object.
    Somehow, I am seeing the same DOM object being used for different XMLs.
    Is there a thread safety issue with the Xerces parser?

    certainly, Xerces parser is not thread safe. You have to provide thread safety by making sure that only one thread is allowed to access DocumentBuilder object.

  • Installing a DOM XML Parser

    Hey, I apologize for the newbie question but I suppose this is as good a place as any for it. I'm in desperate need of a DOM XML parser and have decided upon the Apache parser, "Xerces," featured here. My problem is this, every time I make a move towards installing it, I get all mixed up at the mention of my "Apache, ant and forrest" installations that I am apparently supposed to have in order for this library to work. My question is, is this library only for use in web-based applications and thus requires Apache in order to run? I ask because the application I'm working on is simply for desktop usage and the users it will be distributed to will not have Apache installations. If somebody could help me out with a quick little walk-through on the installation of this library it would be IMMENSELY appreciated.
    Edited by: Tracekill on Sep 13, 2009 11:01 AM

    Study up on the javax.xml.parsers API here at Sun. Next, download Xerces from Apache (xml.apache.org). Finally, take a tutorial.
    - Saish

  • Can I replace a DOMParser with a SAX parser?

    hi, can I replace a DOMParser with a SAX parser? In the class "org.apache.xerces.parsers.DOMParser", there is a method called "getDocument()", it returns the document as a DOM object, but I don't see any equivalent methods in the SAX parser.

    I would avoid using SAXParser. It has been superceded by the org.xml.sax.XMLReader class.
    the XMLReader class has a method called parse() that accepts an InputSource.
    Look at the org.w3c.transform (I think that's it) package and it gives you the ability to create a stream from a DOM Document.
    Also avoid using classes that are specific to an implementation of an XML parser. I know from experience that this can really jam things up in the long run.

  • How to ignore empty text element while using DOM to parse xml??

    hi everyone,
    i am using DOM to parse an xml file. But i dont know how to cinfig the DocumentBuilderFactory to ignore empty text elements.
    For example, i have an xml file like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
        <child>Tom</child>
        <child>Jerry</child>
    </root>I used the following codes to parse:
    String fname = "Tom-and-Jerry.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    // Generate a DOM tree from the DOM builder.
    org.w3c.dom.Document dom = builder.parse(new File(fname));
    org.w3c.dom.NodeList list = dom.getChildNodes();
    for (int i=0; i<list.getLength(); i++) {
        System.out.println("Child No."+i);
        System.out.println("NodeName="+list.item(i).getNodeName());
        System.out.println("NodeType="+getType(list.item(i).getNodeType()));
        System.out.println("NodeValue="+list.item(i).getNodeValue());
        System.out.println();
    }The result is not exactly what i want ---- there are 5 children in list!! The 1st, 3rd and 5th are #text and their values are all empty. Only the 2nd and the 4th are the child that i expect.
    It is really troublesome to get all these silly empty texts as sub elements. I tried to get rid of them, but i failed. I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.
    Anyone can help me? thanks.
    Heavy ZHENG

    I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.That only does something if the XML has a DTD that enables it to know what whitespace can be ignored and what is significant. The API documentation for the method refers you to this document:
    http://www.w3.org/TR/REC-xml#sec-white-space

  • Using setEntityResolver() with DOM

    Hi,
    I'm trying to parse an XML document whose DTD
    is defined externally (actually, inside a jar file). I've succesfully done so using Xerces
    from Apache, as I can specify an entityResolver with its DOMParser. However, with the Oracle parsers, I can just specify it if I use the SAXParser, but then I cannot use the function getDocument, which I need.
    Any reason why DOMParser doesn't allow to specify an EntityResolver? Any workaround?
    This makes my application unusable with the Oracle parser, as I would have to copy the DTDs in different places, instead of including them with my library. So I'll stay with Xerces for the moment :(.

    Hi,
    I'm trying to parse an XML document whose DTD
    is defined externally (actually, inside a jar file). I've succesfully done so using Xerces
    from Apache, as I can specify an entityResolver with its DOMParser. However, with the Oracle parsers, I can just specify it if I use the SAXParser, but then I cannot use the function getDocument, which I need.
    Any reason why DOMParser doesn't allow to specify an EntityResolver? Any workaround?
    This makes my application unusable with the Oracle parser, as I would have to copy the DTDs in different places, instead of including them with my library. So I'll stay with Xerces for the moment :(.

  • DOM XML parser program

    Hi,
    I am trying to write a sample program using DOM xml parser in java to read the values in a XML file.
    please suggest me what are all the things I have to do for that.
    I know Java and XML. I want to know how to access values from XML file in java.
    Thanks
    Selvakumar

    Study up on the javax.xml.parsers API here at Sun. Next, download Xerces from Apache (xml.apache.org). Finally, take a tutorial.
    - Saish

  • I put dom storage on "false" and now I can't do a Google search. A few days ago I could search Google with dom on false. What changed?

    I customized the Firefox using 'about:config' and all the other settings work well with Google search - for example geo_enabled which I set to false.
    The one setting that has suddenly proved problematic is dom_storage. I used it in false mode successfully for months when searching on Google, now the setting has resulted in an inability to search on Google. The Google page with search bar comes up as usual when I open the browser, but with dom storage set to "false" I can't search anything - the Google search bar page just remains static.

    Users who disable DOM storage in IE8 and IE9 are reporting the same problem on Google's web search forum. For that reason, the requirement to allow DOM storage sounds like a change in Google's code rather than a browser-specific issue.
    One Firefox-specific issue is the cookie connection: Firefox appears to use cookie permissions to block DOM storage on a site-by-site basis. So if you block cookies for google.com, the DOM storage problem will kick in.

  • Using transform api with xslt and DOM Nodes

    Hi,
    when trying to transform a xml document with xslt using the javax.xml.transform api
    providing an element node of a previously parsed document, I find that absolute
    paths are not recognized.
    The following program shows what I am basically doing (the class can be executed
    on the command line providing a stylesheet and xml instance):
    import java.io.*;
    import org.w3c.dom.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    import javax.xml.parsers.*;
    class Transform {
    public static void main(String [] args) throws Exception {
         TransformerFactory tfactory = TransformerFactory.newInstance();
         Transformer transformer = tfactory.newTransformer(new StreamSource(args[0]));
         DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder parser = dfactory.newDocumentBuilder();
         Document doc = parser.parse(args[1]);
         Element domElem = doc.getDocumentElement();
         // workaround
    //     StringWriter out = new StringWriter();
    //     Transformer id = tfactory.newTransformer();
    //     id.transform(new DOMSource(domElem),new StreamResult(out));
    //     String xml = out.toString();
    //     transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(System.out));
         transformer.transform(new DOMSource(domElem), new StreamResult(System.out));
    transformer.clearParameters();
    If I use this on e.g.
    xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" encoding="ISO-8859-1" method="xml"/>
    <xsl:template match="/">
    <xsl:value-of select="/foo/bar"/>
    </xsl:template>
    </xsl:stylesheet>
    xml:
    <foo>abc<bar>def</bar></foo>
    I get
    <?xml version="1.0" encoding="ISO-8859-1"?>
    abcdef
    instead of
    <?xml version="1.0" encoding="ISO-8859-1"?>
    def
    I think this is due to the fact, that the transformation does not recognize
    any absolutely adressed xpath correctly.
    From what I read in the API docs, I think what I'm doing should be ok.
    So: did I misunderstand something or is this a bug in the java libraries?
    I'm using j2sdk 1.4.1_01 on i386 linux.
    If I use the commented code (serializing the xml and doing the transformation
    with a StreamSource, that has to be parsed again), everything's fine.
    Of course it would be easier to parse the file directly in the example but in the
    real program, I already have a dom tree and want to transform a part of it.
    Any help appreciated.
    Thanks, Morus

    why?
    that's all the point of XSL: define what part of your
    XML you want in your XSL templates, there is no need
    to prepare a sub-DOM of your DOM.
    Ok. Right. That's an alternative.
    The problem remains, that there are some stylesheets originally written
    for the current solution and though they should work with the whole document
    as well, it's not certain.
    Actually I don't know if this ever worked. I did neither write this code nor maintained the system so far.
    btw. you would be faster by giving a StreamSource to
    your transformation.Probably yes. But that would imply to rewrite a lot of code.
    What is happening is:
    there is a SOAP answser containing a xml document as the result parameter.
    The SOAP answer is parsed (I guess by the soap classes already) and the
    result xml is extracted. That's where the element node I'm trying to transform
    stems from.
    Besides, I still don't see why DOMSource takes any node if only document nodes
    work.
    Thanks, Morus

  • Parsing with DOM results in file Size of the resultant Document(Urgent ....

    hai
    1.Iam parsing xml file to Dom document using DOM
    2.I have inserted element into the document.
    3.and rebuild the file with that document with TransformerFactory
    4.It results in reduce of file size.
    please help me with some guidance.............
    thanks in advance

    Some XML outputters do not write out return characters or tabs for new nodes. If your input contained these things, that could explain why the file shrank. I would check the data and see if it is all there. Other than that, don't worry about it.

Maybe you are looking for

  • How to delete a selected row from adf table

    Hi I am using a ADF Table to get data from the database, i need to select a specific row and then delete it how to get this done. Thanks in Advance.

  • Linux+Oracle:Unable to start the DSCManager

    Hello I installed LCES on Linux+Oracle.When start Jboss,some errors like this: 2007-08-02 11:51:01,493 ERROR [org.jboss.ejb.plugins.LogInterceptor] RuntimeException in method: public abstract java.lang.Object com.adobe.idp.dsc.transaction.impl.ejb.ad

  • PSE 10 Error Message, when I try to delete some photos.  Can delete others normally.

    I recently have not been able to delete some photos.  Didn't make a copy of the actual error message. Will record more info the next time I get the message. Have more than 60,000 photos in my database. any ideas, suggestions at this point ?

  • Can't edit hyperlink

    I have a picture I assigned a hyperlink to and I need to change the link, but I can't get the "link to" to allow a change. I've tried checking and unchecking the boxes, but it stays greyed out.

  • Log Issue in HFM data load

    Hi, I'm new to Oracle data Integrator. I have an issue in log file name. I'm loading data into Hyperion Financial Management through ODI. In the Interface, when we select the IKM SQL to HFM data, we have an option of log file enabled. I made it true