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

Similar Messages

  • 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

  • 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

  • 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?

  • URGENT: What else is necessary for me and why?

    Hi All!
    I am desiging a socket based data transmission system, and our messages, Connection Logs, Application Configuration Data will be stored in xml format. I have also designed dtd for them.
    I NEED TO KNOW WHY AND WHICH OF (XSL, XSLT, XPATH, DOM, SAX, etc. ) SHOULD I USE TO PARSE THE XML DATA FOR JAVA APPLICATION. AND IS ALL THIS NECESSARY FOR THIS OR NOT?
    Plz specify one sentence for each!
    Thanks in Advance
    Kashif

    - XSL, XSLT: used for transforming XML in something else (XML, XHTML, text...)
    - XPATH: used for querying nodes content, XSL relies heavily on this
    - DOM: a parsing technique that will produce a hierarchy of objects (nodes) representing your XML doc,
    - SAX: a parsing technique that will raise events for each specific part (nodes) of your XML doc.

  • How to skip XML tags in Simple transformation

    Hi,
    I am trying to convert an XML file to ABAP code using Simple Transformations.
    I tired converting a small XML file to ABAP using it and it worked fine.
    The problem is that the number of tags in the XML file I now want to parse is huge (over 200).
    Is there any way that for the tag in XML corresponding tag is not created in ST? Is there any conditional tag to achieve this?
    Also, is Simple Transformation a better way of parsing in such a scenario over XSLT and DOM parser?
    Thanks and Regards,
    Neha
    Edited by: Neha Anand on Jun 2, 2008 1:19 PM

    Hi Raja,
    I have already looked through the code snippets and I am able to write a CALL TRANSFORMATION.
    I want to find out if the number of tags is huge then if there is any way that some tags can be skipped for matching tags in XML which anyhow I dont need for manipulation.
    Thanks and Regards,
    Neha

  • How to capture the value of certain HTML tags

    Hi All,
    I would like to retrieve the values of the following HTML outputs and is wondering whether there is a simpler method to do:
    <td class="propType"><b>Address</b></td>
                            <td class="propType"><b>Agent Office</b></td>
                            <td class="propType"><b>Result</b></td>
                            <td class="propType" align="right"><b>Amount</b></td>
                                    <td colspan="6"><strong class="propType">
                                    <td><strong>Date</strong></td>
                                    <td><strong>Amount</strong></td>
                                    <td><strong>Agent Office</strong></td>
                                    <td><strong>Selling Agent</strong></td>
                                    <td class="even">Aug-07</td>
                                    <td class="even">$2,925,000 </td>
                                    <td class="even">Di Jones RE</td>
                                    <td class="even">Andrew Hennessy</td>One awkard method is by using the stringbuffer as follows:
    String greaterthanSignedList[] = greaterthanSigned.split(">") to pickup all the text that comes after the greater than (ie ">" sign)...
    String lessthanSignedList[] = lessthanSigned.split("</") to get the string before the less than (ie "</" sign) ...
    Here are the output that I am looking for:
    Address
    Agent Office
    Result
    Amount
    Date
    Amount
    Agent Office
    Selling Agent
    Aug-07
    $2,925,000
    Di Jones RE
    However, I am sure that there must be an easier way to do this. Would anyone be able to point me to the right direction?
    Many thanks,
    Jack

    htran_888 wrote:
    Only 1 option is needed. ie either XSLT, SAX, DOM... whichever is the simplest.The name Simple API for XML kind of says it all, but you might need to write a lot of unnecessary code. I like to write an XSL stylesheet that converts the input data into something that I can easily parse.
    The Java code looks like this:
    PipedReader result = new PipedReader();
    Writer resultWriter = new PipedWriter(result);
    TransformerFactory transFact = TransformerFactory.newInstance();
    Transformer trans = transFact.newTransformer(new StreamSource(stylesheet));
    trans.transform(new StreamSource(xmlInput), new StreamResult(resultWriter));
    resultWriter.close();Writing the XSL stylesheet should be trivial in your case, but you can do a lot with it.
    I suggest you toy around a bit with both XSLT and SAX. Traversing the DOM manually is not really advisable.
    With kind regards
    Ben

  • XML and MIDlet

    Hi all,
    Can somebody help me to give the tutorial about building XML using servlet ?
    I need an servlet which can generate XML before send it back to the client (in this case I use MIDlet as the client).
    So far I use kXML as the parser, and it works.
    I don�t think to use XSL because the target is not HTML based or web page.
    Thank You,
    Best Regards,
    CHi

    ichiwan wrote:
    all of those links are using XSLT or DOM approach.
    I want the similar tutorial but without involving XSLT or DOM.
    In other words, only pure servlet that able to generate xml tagsWell that is simple to do.. If u know writing servlets and know about xml typos, just use that knowldge to generate your xml file.
    What u need to do is in your response u have to write the xml data. This is how...
            response.setContentType ("text/xml;charset=UTF-8");
            PrintWriter out = response.getWriter ();
            out.println ("<?xml version="1.0" encoding="ISO-8859-1"?>");
            out.println ("<CATALOG>");
            for (int i=0; i<dataVector0.size(); i++) {
                    out.println ("<CD>");
                    out.println ("<TITLE>"+dataVector0.elementAt (i)+"</TITLE>");
                    out.println ("<ARTIST>"+dataVector1.elementAt (i)+"</ARTIST>");
                    out.println ("<COUNTRY>"+dataVector2.elementAt (i)+"</COUNTRY>");
                    out.println ("<COMPANY>"+dataVector3.elementAt (i)+"</COMPANY>");
                    out.println ("<PRICE>"+dataVector4.elementAt (i)+"</PRICE>");
                    out.println ("<YEAR>"+dataVector5.elementAt (i)+"</YEAR>");
                    out.println ("</CD>");
            out.println ("</CATALOG>");
            out.close ();You should have corresponding data in the Vectors dataVector0 thru dataVector5... The resulting response will look something like >> http://www.w3schools.com/xml/cd_catalog.xml
    Hope this helps...
    SD+

  • 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

  • DOM parsing In Applet (URgent)

    Is it possible to implement DOM parsing in Applet?
    I am getting classnotfoundException .
    I am giving the code below. pl read the code.
    Applet.(parserapplet.java)
    =========================
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.util.*;
    import java.applet.*;
    import com.security.*;
    // for DOM parsing ....
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;
    public class parserapplet extends Applet
    public void init()
    public void start()
    try
    if (Class.forName("com.ms.security.PolicyEngine") != null)
    {  // required for IE
         PolicyEngine.assertPermission( PermissionID.SYSTEM );
    catch (Throwable cnfe)
         System.out.println("Policy Engine Exception: " + cnfe);
    try
         String str = "<?xml
    version=\"1.0\"?><html><body></body></html>";
         ByteArrayInputStream bis = new
    ByteArrayInputStream(str.getBytes());
         System.out.println("After creating input stream");
         BufferedInputStream bufIn     = new BufferedInputStream(new
    DataInputStream(bis));
         parseXMLMessage     (bufIn);
    catch(Exception e){}
    // Actual DOM parsing goes here.....
    public void parseXMLMessage(InputStream xmlMessage)
    Document document      = null;
         DocumentBuilder documentBuilder           = null;
         DocumentBuilderFactory documentBuilderFactory     = null;
         try
         documentBuilderFactory = DocumentBuilderFactory.newInstance();
         documentBuilder     = documentBuilderFactory.newDocumentBuilder();
         document     = documentBuilder.parse(xmlMessage);
         System.out.println("Document node: " + document);
         catch(FactoryConfigurationError fce)
         System.out.println("Exception Factory configuration error " + fce);
         catch(ParserConfigurationException pce)
         System.out.println("Exception Parser configuration Exception " pce);
         catch(SAXException saxe)
         System.out.println("Exception SAX error " + saxe);
         catch(Exception e)
         System.out.println("Exception " + e);
    Html code:
    =========
    <html>
    <body>
    <APPLET code="parserapplet.class" archive = "xalan.jar" width=0
    height=0
    MAYSCRIPT>
    <param name=cabbase value=MyApplet.cab>
    </APPLET>
    </body>
    </html>
    I have signed the Applet using signcode utility and i have put the
    parserapplet.class in the MyApplet cab file and signed it. On invoking
    the html file, it request for permission, and after clicking yes, the
    applet loads.Fine.
    No problem upto this stage.
    But after loading of the applet the following exception is thrown in
    Javaconsole.
    Exception:
    =========
    com.ms.security.SecurityExceptionEx[Host]: cannot access file
    C:\WINNT\Java\lib\jaxp.properties
    at com/ms/security/permissions/FileIOPermission.check
    at com/ms/security/PolicyEngine.deepCheck
    at com/ms/security/PolicyEngine.checkPermission
    at com/ms/security/StandardSecurityManager.chk
    at com/ms/security/StandardSecurityManager.checkRead
    at java/io/File.exists
    at javax/xml/parsers/DocumentBuilderFactory.findFactory
    at javax/xml/parsers/DocumentBuilderFactory.newInstance
    at parserapplet.parseXMLMessage
    at parserapplet.init
    at com/ms/applet/AppletPanel.securedCall0
    at com/ms/applet/AppletPanel.securedCall
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    javax.xml.parsers.FactoryConfigurationError:
    java.lang.ClassNotFoundException:
    org/apache/crimson/jaxp/DocumentBuilderFactoryImpl
    at javax/xml/parsers/DocumentBuilderFactory.newInstance
    at parserapplet.parseXMLMessage
    at parserapplet.init
    at com/ms/applet/AppletPanel.securedCall0
    at com/ms/applet/AppletPanel.securedCall
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    I dont know which .jar file to archive (i tried xalan,crimson, jaxp
    but which of no use). I was surprised why the security Exception is
    thrown , when parsing.
    I have not accessed the System files!( but it searches for
    jaxp.properties file!). I think the jar file is not downloaded. How to
    verify that it is downloaded in applet?
    The above code is only for sample.
    If anybody who knows how to correct it please mail me at:
    "[email protected]" with corrected code. I want this very
    urgently.
    Help meeeeeeeeeeeeeeeeeeee!!!!!
    Prasanna.

    Have you found the answer to this problem? I am having a similar problem when running the parser in an ActiveX Bean.
    THanks

  • XSLT problem -- urgent

    Hi,
    We are porting our application from WLS5.1 to WLS6.0SP2. We
    use Apache's Xerces parser for XSLT processing. After starting the server while
    loading a page, I get the following error:
    javax.xml.transform.TransformerException
    at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1242)
    at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    java.lang.ArrayIndexOutOfBoundsException
    at org.apache.xalan.serialize.SerializerToXML.accum(SerializerToXML.java:1321)
    at org.apache.xalan.serialize.SerializerToXML.outputLineSep(SerializerToXML.java:195)
    at org.apache.xalan.serialize.SerializerToXML.indent(SerializerToXML.java:2241)
    at org.apache.xalan.serialize.SerializerToHTML.startElement(SerializerToHTML.java:559)
    at org.apache.xalan.transformer.QueuedStartElement.flush(QueuedStartElement.java:357)
    at org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandler.java:770)
    at org.apache.xalan.transformer.ResultTreeHandler.endElement(ResultTreeHandler.java:279)
    at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:749)
    at org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:498)
    at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:193)
    at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2202)
    at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2085)
    at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1219)
    at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    Has anyone come across this problem and got the solution ?
    Regards,
    Ramkumar

    This is correct you can use different 3rd party parsers like crimson or xml4j , by
    configuring the xml registry .However using different versions of apache xerces and xalan
    other than those shipped can cause compatibility problems and is not supported.
    Look at the faq url for details.
    http//e-docs.bea.com/wls/docs61/faq/xml.html#740643
    It might be possible however to hack this and get it to work.
    yeshwant
    Simon Spruzen wrote :
    If at all possible, you should limit your versions of Xalan and Xerces to those
    shipped with WLS (in weblogic.jar and xmlx.jar). So your imports look something
    like:
    import org.w3c.dom.*;
    import weblogic.apache.*; // not org.apache.*
    It seems that different versions of Xalan and Xerces ship with different versions
    of the org.w3c.dom classes that can be incompatible. You also must also use compatible
    versions of Xalan and Xerces together, else all sorts of oddness starts.
    (I wish Jakarta would merge the Xalan and Xerces packages into one super-package
    and gave it a single name)
    If you use the stuff shipped with WLS6.0 and nothing else, everything works fine.
    You don't have to use the registry and JAXP if you don't want to, however it's
    a nice clean API, providing you agree on what versions of Xalan and Xerces you're
    on. I found using JAXP with mixed versions of Xalan/Xerces just made things more
    confusing!
    WLS6.1 upgrades Xalan and Xerces and drops xmlx.jar. Here's part of a reply from
    a support case I've raised in a related area that clears things up:
    [Helen - BEA Support - writes:]
    "Here is some information that I hope will clarify things a little more :-
    The packaging was intended to make sure that customers could use newer versions
    of xerces and xalan without causing problems for the built in parser.The org.apache
    classes are packaged in xmlx.jar whereas the weblogic.apache classes are packaged
    in weblogic.jar.
    Originally, we planned to rev the xmlx.jar version of Xerces more often than
    the built-in version in WLS. But it turned out that there were compatibility
    problems involving the Level 2 DOM classes (org.w3c.dom package), so in
    practice people couldn't easily plug in a different version of Xerces than
    the one included in weblogic.jar. This problem generally only affects
    customers desiring to plug in a different version of Xerces;
    Because of the compatibility issue, which is not easily solvable, we have
    decided not to support plugging in a different version of Xerces than the one
    shipped. Therefore, we have decided to axe xmlx.jar.
    Note that for 6.1 it is not possible to use a different version of xerces and
    xalan than what is shipped as per
    http//e-docs.bea.com/wls/docs61/faq/xml.html#740643"
    "Ram Kumar" <[email protected]> wrote:
    Hi Kenneth,
    Yes, it is already in my classpath before weblogic.jar.
    Do I need to use the XML Registry and JAXP API for this to work compulsorily
    Regards,
    Ramkumar
    "Kenneth Chenis" <[email protected]> wrote:
    Try putting your xerces.jar file in the classpath before the weblogic.jar
    .... that resolved some (not all) of the problems we had with the internal
    xerces/parser classes in the weblogic.jar file.
    hope this helps,
    Kenneth Chenis
    ComponenTree Inc.
    Data Code Inc.
    [email protected]
    978-521-5970
    "Ram Kumar" <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    We are porting our application from WLS5.1 to WLS6.0SP2. We
    use Apache's Xerces parser for XSLT processing. After starting theserver
    while
    loading a page, I get the following error:
    javax.xml.transform.TransformerException
    atorg.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1242)
    atorg.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    java.lang.ArrayIndexOutOfBoundsException
    atorg.apache.xalan.serialize.SerializerToXML.accum(SerializerToXML.java:1321)
    atorg.apache.xalan.serialize.SerializerToXML.outputLineSep(SerializerToXML.jav
    a:195)
    atorg.apache.xalan.serialize.SerializerToXML.indent(SerializerToXML.java:2241)
    atorg.apache.xalan.serialize.SerializerToHTML.startElement(SerializerToHTML.ja
    va:559)
    atorg.apache.xalan.transformer.QueuedStartElement.flush(QueuedStartElement.jav
    a:357)
    atorg.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandle
    r.java:770)
    atorg.apache.xalan.transformer.ResultTreeHandler.endElement(ResultTreeHandler.
    java:279)
    atorg.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:
    749)
    atorg.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.ja
    va:498)
    atorg.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.jav
    a:193)
    atorg.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
    erImpl.java:2202)
    atorg.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Transformer
    Impl.java:2085)
    atorg.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1219)
    atorg.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    Has anyone come across this problem and got the solution ?
    Regards,
    Ramkumar

  • XSLT bug with attributes+in memory DOM

    Hello,
    I know there was a thread about this one some time ago but i
    don't know the current state of this matter, so :
    The XSLT processor has problems with attributes when the DOM was
    build dynamically (attributes are returned as being empty). When
    i save the same DOM, reload it and then do the transform
    attributes are properly transformed.
    The Version 2.0.0.1 of the Java parser states to have solved a
    problem when accessing attributes (bug #920536) but this seems to
    be an other one (i tried 2.0.0.0 and 2.0.0.1 and both had this
    problem).
    Bye Heiko.
    null

    We were unable to reproduce the problem you illustrated. We got
    the output:
    <HTML>
    <BODY>
    the value is : 1
    </BODY>
    </HTML>
    irrespective of whether the lines were commented out. Can you
    describe your environment - JRE/JDK, OS. etc?
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    You wrote:
    : Hello,
    : the following program illustrates what i mean :
    : package testing;
    : import oracle.xml.parser.v2.*;
    : import org.w3c.dom.*;
    : import java.io.*;
    : public class XMLTest {
    : public static final void main(String [] args) throws
    : Exception {
    : XMLDocument doc=new XMLDocument();
    : doc.setVersion("1.0");
    : doc.setStandalone("yes");
    : Node root=doc.createElement("ROOT");
    : Node att=doc.createAttribute("value");
    : att.setNodeValue("1");
    : root.getAttributes().setNamedItem(att);
    : doc.appendChild(root);
    : doc.print(new FileOutputStream("c:\\test.xml"));
    : DOMParser parser=new DOMParser();
    : parser.parse(new FileInputStream("c:\\test.xml"));
    : doc=parser.getDocument();
    : XSLStylesheet xsl=new XSLStylesheet(new
    : FileInputStream("c:\\test.xsl"), null);
    : XMLDocument out=new XMLDocument();
    : out.appendChild(new XSLProcessor().processXSL(xsl,
    doc));
    : out.print(System.out);
    : with the stylesheet test.xsl as follows :
    : <?xml version="1.0"?>
    : <xsl:stylesheet
    : xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
    : xmlns="http://www.w3.org/Profiles/xhtml1-transitional"
    : default-space="strip"
    : indent-result="yes"
    : >
    : <xsl:template match="ROOT">
    : <HTML>
    : <BODY>
    : the value is : <xsl:value-of select="@value"/>
    : </BODY>
    : </HTML>
    : </xsl:template>
    : </xsl:stylesheet>
    : if you run the program as given the result is :
    : the value is:
    : but when you uncomment the lines storing & retrieving the
    : document the result is as i would expect it :
    : the value is: 1
    : Bye Heiko.
    null

  • Use DOM as an argument of  XSLT document() function

    I have in memory several DOM documents. I have not stored in file system the XML files that are represented by these DOMs. I want to process with a stylesheet
    all of these DOMs (as DOMSource's) using document() function from the stylesheet. How can I refer to the secondary DOMs from document function if I haven't the files?
    F.e.
    <xsl:value-of select="document('file.xml')/.../..."/> file.xml only exists loaded in memory as DOM.
    Can anybody help me?? Thanks

    Thank you DrClap but I'm not sure about the use of URIResolver:
    if my xslt:
    <xsl:value-of select="document('file1.xml')\...\..."/>
    <xsl:value-of select="document('file2.xml')\...\..."/>
    I must define my own class that implements URIResolver and write my own resolve method, isn't it?
    class Resuelve implements URIResolver{
         private Document doc1;
         private Document doc2;
         public Resuelve(Document doc1, Document doc2){
              this.doc1 = doc1;
              this.doc2 = doc2;
         public Source resolve(String href, String base){
              if(base.equalsIgnoreCase("file1.xml")){
                   Source s1 = new DOMSource(doc1);
                   return s1;
              else if(base.equalsIgnoreCase("file2.xml")){
                   Source s2 = new DOMSource(doc2);
                   return s2;
              else{
                   return null;
    I suppose that XSLT processor use automatically resolve method. I don't understand the href parameter...
    Is this class correct? if not, can you show me an example please?
    Thank you very much

  • Approach on parsing an XML file (JAXP, JAXB, DOM, SAX, XSLT)

    I have a pretty basic xml file that contains a database table name, fields, and sort order. My job is to read the XML file, construct the query based on the information in the nodes, and then output it in various ways. I know I can use JAXP, JAXB, DOM, SAX, and XSLT for this.
    I have the experience doing this using DOM. I have read up on JAXP, JAXB, and XSLT. I'm having a little bit of a difficult time on chosing the most appropriate way to do this. Again, I've always done it using DOM, but I'm not so sure that is the best way to do it here. Just looking for some recommendations from people whom are more familiar with XML parsing and processing.

    markwagoner wrote:
    I tried several of those but found them rather tedious. Now I just use JDOM for everything, it make life much easier.It doesn't, actually. It kept your learning curve shallow, but that's all. If you were to invest some time in JAXB, you'd find it made life easier for some things. If you invested time in XSLT, it would make life easier. Endlessly working with JDOM is incredibly tiresome after a while. You just don't know it because you never invested enough in learning anything else.
    Don't bother posting any code to "enlighten" me as to how simple JDOM is. I've been using it for years.

  • 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

  • Where is the update to 4.1?

    Hello I'm owner of a license of ACS, but my current version is 4.0.3. I read at November/2010 about the new 4.1 version but never was notified about the update by means of my Adobe profile or in acs4 operator account in my domain. In my downloads the

  • Quick Time 7.6.9

    i just upgraded my computer from os 10.4.11 to 10.5.6 the new quick time player 7.6.9 will not play my current quick time videos created under quick time player 6.0. WHY?

  • After latest update, half my music library won't play

    The cover art is gone, when I select a song it will immediately cycle through until it finds a song that hasn't been messed up... I'm really confused because there is no reason why this would happen. A lot of the songs affected have been purchased th

  • OBIEE - How to add developer comments?

    I was wondering how do other folks out there document changes to their OBIEE reports? I have worked on a few other applications where in the code we would add "comments" to specific pieces such as date of modification, when it was modified and by who

  • Draw window

    hi, i not sure how to start create the window in my form. i tried to right click and create new window but it doesn't seem to let me adjust the size. can advise how to create window? thanks