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 :(.

Similar Messages

  • I am trying to setup wireless using my old dome Airport ExtremeBase station. I had previously used it about 5 years ago when I had dial up but have now switche to DSL with Windstream. I can not get connecte as ABS keeps trying to dial up(the phone number)

    I am trying to setup wireless using my old dome Airport Extreme Base station. I had previously used it about 5 years ago when I had dial up but have now switched to DSL with Windstream. I can not get connected as the ABS keeps trying to dial up(the old phone number). When I tried to change my network settings an annoying popup window says "your network settings have been changed by another application'. I have no idea what the message is all about and when I close this window it immediately pops up again and prevents me -as far as I can tell -from changing my Airport settings?  I need advice on how to get this wireless setup done. Maybe a reset? or something else? I have the DSL phone line plugged into WIndsteam Seimens Speedstream 4200 modem and then the ethernet (yellow) wire from the WIndsteam Seimens Speedstream 4200 modem to the port on the dome that is a circle of dots.

    1)Can you explain how using the AEBS as a bridge will work with the Seimens Speedstream4200?
    As a bridge, the AEBS will basically become a wireless access point. This will allow the AEBS to provide a wireless network, but still allow the Speedstream to provide NAT & DHCP services for the wireless clients connected to the AEBS. If the AEBS was left as a router, you would have a double-NAT condition which isn't necessary bad in itself, but would create a second subnet. That would make it more difficult for clients connected to the AEBS to access clients connected to the Speedstream.
    2) Is there a link that will guide me through the steps to set the AEBS as a bridge?
    You can easily reconfigure the AEBS as a bridge using the AirPort Utility.
    ref: AirPort Utility > Select the AEBS > Manual Setup > Internet > Internet Connection > Connection Sharing = Off (Bridge Mode)
    3)Can I just connect the DSL phone line to the AEBS and eliminate the Speedstream4200?
    Unfortunately no. The AEBS does not have a built-in DSL modem. You will still need the Speedstream to provide this function.

  • Using XPath with the XML DOM

    I have just started to use the XML DOM API. One thing I cannot see yet is an easy way to use XPath to get the value of an element.
    What I would like to do is pass an XPath expression like this:
    \EDIFACT\ORDERS\NAD[2]\NAD01\NAD0102
    into a method, and get the value of the element returned to me.
    Does anybody know if there is a method of one of the DOM interfaces that would provide that kind of functionality, or am I going to have to traverse the nodes of the DOM tree manually to do this?
    BR,
    Tony.

    Hi Tony,
    I read your posted question - I have the same problem.
    I think that the method find_from_path_ns (or find_from_path) is the only "xpath"-like way to get a value.
    BUT the syntax is very limited so you cannot use all good features of xpath
    To traverse the nodes manually is (in my problem) unpractible - the xml-structures are different and it's horrible to traverse the tree.
    I need xpaths like ' //x/y[3]/z[a='MS']' . I know, the performance is not very good but for small XML-messages fast enough
    Do you have any solutions?
    regards
    Wolfgang Hummel

  • 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

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

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

  • Problem with DOM API

    Hi,
    I use org.w3c.dom to create an XML file.
    I need to configure "xmlns" into father and child tags, because I have to send my XML to a soap webservice,
    and the server arises "error in schema XML" if I put "xmlns" only in father, not in child.
    The problem is that DOM API automatically removes the "xmlns" from child, and I didn't find a way to force it
    to use "xmlns" at any time.
    This is my XML before to generate the DOM tree:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?> 
      <nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2"> 
        <enviNFe versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe"> 
          <idLote>75600</idLote> 
          <NFe xmlns="http://www.portalfiscal.inf.br/nfe"> 
            ... many internal tags ...
          </NFe> 
        </enviNFe> 
    </nfeDadosMsg>After to generate the DOM tree, NFe becomes without "xmlns", only "<NFe>".
    If I change to:
    <NFe xmlns="http://www.portalfiscal.inf.br/nfeXXX">then the DOM tree becomes fine with "xmlns" into enviNFe and NFe, but
    because the xmlns's are differents.

    If you stop thinking of that as an "xmlns attribute" and start thinking of it as what it really is, namely a namespace declaration, then you might understand the part of the DOM documentation which refers to namespaces better. You might also track down the rule which describes what a "default" namespace is and how it's inherited (and overridden) by child elements. Without that these things are just going to be a mystery to you.
    Also be sure to make your DOM be namespace-aware if you're going to use namespaces. By default it isn't. I believe it's the factory which has the setNamespaceAware method and not the parser.

  • 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 the Java DOM properly

    I am new to the Java DOM (package org.w3c.dom) and have read several tutorials on its basic use, but cannot find the answers to what I feel are some very basic questions.
    In org.w3c.dom (the "Java DOM"), Documents, Elements and Nodes are interfaces all representing the components of an XML document, which is a tree structure where each node can have 0+ children (representing the recursive nature of XML itself). The Document interface represents the entire document, whereas Elements (which extend Nodes) represent a specific tag/element in an XML document, and all of its children (the subtree extending from the Element).
    QUESTION #1: What class, then, actually represents the tree data structure of the XML document? Document, Element and Node are interfaces, meaning they can only provide abstract methods and static members. For instance, Node has a method called "getFirstChild()"... since this is an interface method, it has to be abstract... so where is it defined? Another way to look at this question is:
    noises.xml
    ========
    <animals>
         <cow noise="moo"/>
         <dog noise="woof"/>
    </animals>
    DomTestDriver.java
    ==================
    DocumentBuilderFactory dbf = new DocumentBuilderFactory()
    DocumentBuilder db = dbf.newInstance();
    Document doc = db.parse("noises.xml");
    Element root = doc.getRoot();
    Element cow = root.getFirstChild();Here I have read/parsed noises.xml into a Document object. I am now free to explore the document, modifying it as I wish, etc. When I call root.getFirstChild(), somewhere, somehow, a tree structure is holding an in-memory version of noises.xml, and getFirstChild() queries that structure for the correct Node to return... what is this structure?!? It must be a class... so what is it???
    ***End of Question #1***
    Second, it would be nice if I could modify a Document object or Element at runtime. For instance:
         Element horse = new Element();
         horse.setTagName("horse");
         horse.setAttribute("noise", "naaay");
         root.replaceChild(horse, cow);
         // Now, the 'doc' Document object, which originally parsed noises.xml, looks like:
              <animals>
                   <horse noise="naaay"/>
                   <dog noise="woof"/>
              </animals>
         */Several problems with the code sample above:
    (1) Element is an interface! I can't instantiate it like "Element horse = new Element();"
    (2) Neither Element nor Node specify a "setTageName(String)" method, telling me that Java     does not want me using the Java DOM like this... why?!?!
    QUESTION #2: So, if my code sample above doesn't work, how do I create new Element objects and insert them into my Document object, or into another Element's subtree?

    the top hit for the google search "java dom tutorial" should answer questions 2 and 3. as for 1, the answer is "it doesn't matter". the point of frameworks designed like this is that each jdk implementation is free to provide its own, compatible dom implementation. in case you are curious, the sun jdk implementation uses a modified version of apache xerces, but like i said, that doesn't really matter and should not be visible to you.

  • How to add node value using org.w3c.dom.Document?

    Hi ,
    I'm using org.w3c.dom.Document to deal with xml files. I could successfully add nodes , and their attributes. However I could not add a value of the node. (e.g. <myNode>I couldn't add this value</myNode>)
    does anyone know how to deal with this?
    I tried subNode.setNodeValue("the value i can't add"); whereas the subNode is an instance of org.w3c.dom.Node... i know this is interface i of course used the concrete class
    org.apache.crimson.tree.ElementNode
    but when I used the subNode.getNodeValue() i simply got null?
    can u plz help me?
    thanks in advance

    Reading the API documentation for the Node interface might help. At least you wouldn't be surprised when the results are exactly what the documentation says they will be.
    What would really help would be forgetting the idea that an Element can have a value. Text nodes have values, though, so create a Text node and make it the child of the Element node.

  • ReRender using client-side dom id

    Is it possible to use client-side DOM ids for rerendering. I have noted that JSF/Richfaces only accepts server-side DOM names.
    e.g.
    <h:form id="myForm">
        <h:outputText id="testData" value="#{testAction.testData}" >
        <a4j:commandButton id="updateData" value="Update Data"
                                 action="#{testAction.updateData}" reRender="testData"/>
    </h:form>client-side DOM id: testData
    server-side DOM id: myForm:testData
    Is there some method on the server (maybe in rerender phase) that I call to achieve this i.e. reRender="myForm:testData"
    Thanks,
    Philip

    The problem that I've posted is just an example. The real jsf page is extremely complex which is made up repeating data that is nested multiple levels deep. I'm trying to minimize the amount of data being rerendered as the page is over 1.5MB in size as it stands, but still needs to be extremely interactive and responsive.
    The form lives within the repeating rich:dataGrid to minimize the amount of data being submitted to the server. In the real application this repeat is nested within a few other repeats multiple levels deep. I also use ajax regions to minimize the amount of processing on the server side.
    The problem I'm trying to solve is as follows:
    1) I have page with lots of repeating data multiple levels deep. At each data level content is represented in a set of panels/forms.
    2) Changing one value in one of the forms can initiate a complex set of events, where data needs to be rerendered in other areas outside the current form (but on the same page).
    3) The data across all these tables can be sorted by the end user, which means that I have lost the original link between the backing data and the client-DOM component i.e. if you sort data, the data changes its position, but the DOM components remain unchanged. This is problematic as I need to know down to a single field what needs to rerendered.
    The solution that I am trying to employ:
    1) As the page loads (or is subsequently rerendered on a post-back) I store a unique identifier (based on pk of the backing component - ejb entity) and the client dom id of the component back in a map on the server (pk to client dom map). I only need to do this for a select set of fields that I know might change during step 2 above. If one element is changed that causes a data change in another area of the screen, I can get to the client ID by doing a look up on pk/client dom map.
    2) I am using the ajaxKeys property combined with the field name to calculate the exact component that needs to be renrendered. However, to get at this I need to parse the client ID to figure out the ajaxKeys and field name. I then need to set these keys for every table that is a parent of the current field that I am trying to rerender. One issue that I am faced with using this approach is: if I need to update more than one field within the same rerender but is based on different ajaxKeys - still trying to figure this one out.
    This process would be so much easier if I could just tell JSF to rerender based on the set of client IDs that I know need to be rerendered.
    Thanks for the advice.
    Philip

  • HT202667 Hi - My daughter was using her Apple TV until recently when she got a Smart TV.  Now the Apple TV is not needed so she passed it on to me.  How do I get it transferred over from her Home Sharing account to mine so that I can use it with my PC?

    Hi - My daughter was using her Apple TV until recently when she got a Smart TV.  Now the Apple TV is not needed so she passed it on to me.  How do I get her Home Sharing account transferred over to mine so that I can use it with my PC? Thanks!

    As  Winston Churchill wrote, however you might want to do a factory reset on the Apple TV.
    This way all information pertaining to your daughter will be removed from the device. Specifically if see was sign into any of the streaming service, Netflix, Hulu, etc. her credentials will still be associated with this Apple TV, doing  a factory reset will remove all that and make it as if you purchased the device and just plugged it in.
    regards

  • OPEN CURSOR using a WITH clause in the select query

    Hi,
    I am using Oracle 9i. I have a requirement where I have a REFCURSOR as an OUT parameter for my procedure. I have declared the TYPE and created the procedure.
    In the procedure, I am using OPEN <cursor_name> FOR <query>;
    Ideally this works in most of the cases that I have tried earlier. However, in the current case I am using a WITH clause in my query to get the results.
    I need help in understanding if the above mentioned syntax would not allow me to use the WITH clause in the query.

    What error do you get , seems to work ok for me on 10g
    SQL> begin
      2  open :cv for 'with x as (select * from emp)  select * from x';
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print :cv
         EMPNO
    ENAME
    JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7521
    WARD
    SALESMAN        7698 22-FEB-81       1250        500         30
          7566
    JONES
    MANAGER         7839 02-APR-81       2975                    20
         EMPNO

  • My iPhone 4 will not sync my new voice memos from the "Voice Memos" app to my computer. This is frustrating, should not be so hard, can someone please help. I use PC with windows 7 with iPhone version 6.1.3 and iTunes most recent. Thanks.

    My iPhone 4 will not sync my new voice memos from the "Voice Memos" app to my computer. This is frustrating, should not be so hard, can someone please help. I use PC with windows 7 with iPhone version 6.1.3 and iTunes most recent. Thanks.

    In the Music tab of iTunes, do you have 'Include Voice Memos' checked?

  • I ordered my Macbook Air with Aperture two years ago. I now have an iMac - can I use that with Aperture in any way?

    I ordered my Macbook Air with Aperture two years ago. I now have an iMac - can I use that with Aperture in any way? I appreciate that it is a different computer but I am now the end user of both devices and I was just wondering if it was possible.
    Thanks,
    Sean

    The answer would be in your software license agreement for Aperture. However if you cannot locate it you can ask in the Aperture forum, the link for that is:
    https://discussions.apple.com/community/professional_applications/aperture
    However I believe you can have Aperture installed on two machines however only one may be using it at a time.
    On the new iMac launch the Mac App Store - Purchased - look for Aperture and download to your new machine.

Maybe you are looking for