Parse XML document which have xlink/xpointer inside

dear friends,
There are lots of topic talking about parse xml, validating xml with schema and so on, but no one or any book talking about parsing xml document which can parse document with link inside.
According to Mr Meggison at http://www.megginson.com/Background/
we can do it, but he is not expert with this thing.
For example I have 3 XML document. My main XML document, let named it A.XML have XPointer inside and this element pointing to B.XML and C.XML using xpointer. how to parse A.XML and in the same time my SAX recognized this XPointer and parse also element inside B.XML and C.XML.
I am really grateull for any helpful information from you.
best regards

I think you need to look for a SAX or DOM parser that undestands XPointers and knows how to follow them to additional content.
I have used XSLT and specified external documents to it. It knows how to read a document and in effect make a nodeset which can be searched with the XPath capabilities of XSLT.
It sounds like you wnat an <include file="xxx"/> capability and have the parser stop reading the current file, and start reading the second file.
That works in Schemas, but I'm unaware of any way to do it with SAX or DOM in one pass.
It would not be too hard to process the first file, say with DOM.
After the Document is built, go find the <include> elements, read get the attribute needed, build a new Document and merge it into the original Document in place of the <include> element.
Is this more what you want to do?
Dave Patterson

Similar Messages

  • XML document must have a top level element. Error processing resource

    Hi,
    I am trying to send a XML file to a web browser from a servlet. I read the contents of the XML file into a string and I am sending it to the brower. Before I do this I set the 'Content-type' header of the httpResponse to "application/xml" . Embedded in the XML file is an xml-stylesheet elemetn indicating which *.xsl stylesheet to use to parse the XML content.
    I get the following error:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'http://127.0.0.1:8080/testReplyingXML/xml-to-html.xs...
    Now, if I take the stylesheet element out of the XML string I sent, then the browser stores the content into and *.xml file. I manually run the "xml-to-xsl " stylesheet mentioned in the error output above, and there is no problem, the xml content gets successfully transformed in a viewable HTML .
    It is only when I embed the "stylesheet" element into the XML content that I get this error.
    So the browser is receiveing valid XML.
    I am not sure if the above error is complaining about the XML content I send or the stylesshet .
    Does anyone have an idea of what am I doing wrong?
    For your information here are my servlet code and the XML file:
    servlet:-
    package webapps.testReplyingXML;
    import java.io.BufferedReader;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.FileReader;
    import java.util.Enumeration;
    import java.util.StringTokenizer;
    import java.io.PrintWriter;
    public class ReplyXML extends HttpServlet {
              static int transactionCount = 0;
              public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException ,IOException {
                   String Q_PARAM = "query";
                   String requestString = req.getQueryString();
                   for ( Enumeration en = req.getParameterNames() ; en.hasMoreElements() ; )
         String k = (String)en.nextElement() ;
         String[] x = req.getParameterValues(k) ;
         String s = null;
         String DATA_PARAM= "";
         for(int i = 0 ; i < x.length ; i++ )
         s = x[i] ;
         //System.out.println("s = " + s);
         if (k.equals("query")){
              try {
                             //res.setHeader("Content-Type", "application/xml");
                             //res.setHeader("Transfer-Encoding", "chunked");
                             //res.setHeader("Cache-Control", "no-cache");
                             //res.setHeader("Server", "Jetty/5.1.10");
                             //res.setHeader("Pragma", "no-cache");
                             //res.setHeader("X-Joseki-Server", "Joseki-3.0-dev");
                             res.setStatus(res.SC_OK);
                             StringBuffer fileData = new StringBuffer(1000);
                        BufferedReader reader = new BufferedReader(new FileReader("sparql_results.xml"));
                        char[] buf = new char[1024];
                        int numRead=0;
                        while((numRead=reader.read(buf)) != -1){
                        String readData = String.valueOf(buf, 0, numRead);
                        fileData.append(readData);
                        buf = new char[1024];
                        reader.close();
                        String xmlMsg= fileData.toString();
                        System.out.println("XMLMSG= " + xmlMsg);
                             PrintWriter outresp = res.getWriter();
                             outresp.println(xmlMsg);
                             outresp.close();
              }catch (Exception e) {
                   e.printStackTrace();
              public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
                   doGet(req, res);
    XML FILE:
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="xml-to-html.xsl"?>
    <sparql
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:xs="http://www.w3.org/2001/XMLSchema#"
    xmlns="http://www.w3.org/2005/sparql-results#" >
    <head>
    <variable name="book"/>
    <variable name="title"/>
    </head>
    <results ordered="false" distinct="false">
    <result>
    <binding name="book">
    <uri>http://example.org/book/book6</uri>
    </binding>
    <binding name="title">
    <literal>Harry Potter and the Half-Blood Prince</literal>
    </binding>
    </result>
    <result>
    <binding name="book">
    <uri>http://example.org/book/book5</uri>
    </binding>
    <binding name="title">
    <literal>Harry Potter and the Order of the Phoenix</literal>
    </binding>
    </result>
    <result>
    <binding name="book">
    <uri>http://example.org/book/book4</uri>
    </binding>
    <binding name="title">
    <literal>Harry Potter and the Goblet of Fire</literal>
    </binding>
    </result>
    <result>
    <binding name="book">
    <uri>http://example.org/book/book3</uri>
    </binding>
    <binding name="title">
    <literal>Harry Potter and the Prisoner Of Azkaban</literal>
    </binding>
    </result>
    <result>
    <binding name="book">
    <uri>http://example.org/book/book2</uri>
    </binding>
    <binding name="title">
    <literal>Harry Potter and the Chamber of Secrets</literal>
    </binding>
    </result>
    <result>
    <binding name="book">
    <uri>http://example.org/book/book1</uri>
    </binding>
    <binding name="title">
    <literal>Harry Potter and the Philosopher's Stone</literal>
    </binding>
    </result>
    </results>
    </sparql>

    Error processing resource http://127.0.0.1:8080/testReplyingXML/xml-to-html.xs...
    Well, if one more character had been deleted from that message then you would have a problem. But as it is, the error message says there's an error processing a resouce whose name ends with "xml-to-html.xs" followed by something. That would be the stylesheet if I'm not mistaken. Most likely the browser can't find it at the URL mentioned in the error message.

  • Using parser to parse xml document

    Hi all:
    I have a xml document which has a root element and the a list of elements(same type) underneath it.
    My question is:
    Is there a restriction on the number of elements(same type) that you can extract from the Document?
    Thanks.
    Rino

    If you use DOM of JDOM, you will have a problem when you run out of system memory.
    If you use SAX, the parser will throw events with the required data for the current node (element, data, attribute). Once the event has been processed, the data is out of scope (unless you still hold a reference to it).
    If you use SAX, you are able to process each node without keeping the data from that node any longer than you like. Unless you have to have the entire document available, I would suggest using SAX.

  • XML document must have a top level element. Error

    Hi, I am trying to generate an XML. Below is a sample code from my function. The function generates a 0 byte file which when I try to open gives me 'xml document must have a top level element' error. Any ideas?
    FUNCTION generateXml(    p_1      VARCHAR2,
                             p_2      VARCHAR2,
                             p_3      VARCHAR2
                             ) RETURN CLOB
    IS
        ctx dbms_xmlgen.ctxHandle;
        xml CLOB;
        v_sql varchar2(2000);
    BEGIN
    lv_sql:=' select * from v_dc where rownum =1';
    ctx := dbms_xmlgen.newContext(v_sql);
    dbms_xmlgen.setRowSetTag(ctx, 'CONTENT');
    xml := dbms_xmlgen.getXML(ctx);
    return xml;
    END;
    END generateXml;

    I just need to understand if we can generate XML from a sql that has sub-queries in it.Should be no problem:
    SQL> create or replace function generatexml (p_1 varchar2, p_2 varchar2, p_3 varchar2)
      return clob
    is
      ctx     dbms_xmlgen.ctxhandle;
      xml     clob;
      v_sql   varchar2 (2000);
    begin
      v_sql := ' select * from dept left outer join (select * from emp) emp on (emp.deptno = dept.deptno) where rownum = 1';
      ctx := dbms_xmlgen.newcontext (v_sql);
      dbms_xmlgen.setrowsettag (ctx, 'CONTENT');
      xml := dbms_xmlgen.getxml (ctx);
      dbms_xmlgen.closecontext (ctx);
      return xml;
    end generatexml;
    Function created.
    SQL> select generatexml (null, null, null) xml from dual
    XML                                                                            
    <?xml version="1.0"?>                                                          
    <CONTENT>                                                                      
    <ROW>                                                                         
      <DEPTNO>10</DEPTNO>                                                          
      <DNAME>ACCOUNTING</DNAME>                                                    
      <LOC>NEW YORK</LOC>                                                          
      <EMPNO>7782</EMPNO>                                                          
      <ENAME>CLARK</ENAME>                                                         
      <JOB>MANAGER</JOB>                                                           
      <MGR>7839</MGR>                                                              
      <HIREDATE>09.06.81</HIREDATE>                                                
      <SAL>2450</SAL>                                                              
      <DEPTNO>10</DEPTNO>                                                          
    </ROW>                                                                        
    </CONTENT>                                                                     
    1 row selected.Maybe your query simply doesn't return any rows?

  • Error using SOAPRunner:  XML document must have top level element

    Hi all,...................xMII 11.5.3 b66
    I am attempting to consume a BLS transaction as a web service from a J2EE app. 
    When I test it with http://naholldo31020/Lighthammer/SOAPRunner/Amy/GetListOfPlants I am getting an error message from the browser.  The BLS transaction works fine when called from a Query template.  What am I missing?
    The XML page cannot be displayed
    Cannot view XML input using style sheet.
    Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing
    resource 'http://naholldo31020/Lighthammer/SOAPRunner/Amy/GetL...
    WSDL from WSDLGen...
    <?xml version="1.0" encoding="UTF-8" ?>
    - <definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:s0="http://www.sap.com/xMII"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.sap.com/xMII">
    - <!--  Types
      -->
    - <types>
    - <s:schema elementFormDefault="qualified" targetNamespace="http://www.sap.com/xMII">
    - <s:complexType name="InputParams">
    - <s:sequence id="InputSequence">
      <s:element maxOccurs="1" minOccurs="0" name="RequestXML" type="s:Xml" />
      <s:element maxOccurs="1" minOccurs="0" name="RowCount" type="s:long" />
      <s:element maxOccurs="1" minOccurs="0" name="RowSkips" type="s:long" />
      <s:element maxOccurs="1" minOccurs="0" name="Table" type="s:string" />
      </s:sequence>
      </s:complexType>
    - <s:element name="XacuteRequest">
    - <s:complexType>
    - <s:sequence>
      <s:element maxOccurs="1" minOccurs="0" name="LoginName" type="s:string" />
      <s:element maxOccurs="1" minOccurs="0" name="LoginPassword" type="s:string" />
      <s:element maxOccurs="1" minOccurs="0" name="InputParams" type="s0:InputParams" />
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:complexType name="Rowset">
    - <s:sequence>
      <s:element maxOccurs="unbounded" minOccurs="0" name="Row" type="s0:Row" />
      </s:sequence>
      <s:attribute name="Message" type="s:string" />
      </s:complexType>
    - <s:complexType name="Row">
    - <s:sequence id="RowSequence">
      <s:element maxOccurs="1" minOccurs="1" name="ErrorMessage" type="s:string" />
      <s:element maxOccurs="1" minOccurs="1" name="OutputXML" type="s:string" />
      </s:sequence>
      </s:complexType>
    - <s:element name="XacuteResponse">
    - <s:complexType>
    - <s:sequence>
      <s:element maxOccurs="1" minOccurs="0" name="Rowset" type="s0:Rowset" />
      </s:sequence>
      </s:complexType>
      </s:element>
      </s:schema>
      </types>
    - <!--  Messages
      -->
    - <message name="XacuteSoapIn">
      <part element="s0:XacuteRequest" name="parameters" />
      </message>
    - <message name="XacuteSoapOut">
      <part element="s0:XacuteResponse" name="parameters" />
      </message>
    - <!--  Ports
      -->
    - <portType name="XacuteWSSoap">
    - <operation name="Xacute">
      <input message="s0:XacuteSoapIn" />
      <output message="s0:XacuteSoapOut" />
      </operation>
      </portType>
    - <!--  Bindings
      -->
    - <binding name="XacuteWSSoap" type="s0:XacuteWSSoap">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    - <operation name="Xacute">
      <soap:operation soapAction="http://www.sap.com/xMII" style="document" />
    - <input>
      <soap:body use="literal" />
      </input>
    - <output>
      <soap:body use="literal" />
      </output>
      </operation>
      </binding>
    - <!--  Service mapping
      -->
    - <service name="XacuteWS">
    - <port binding="s0:XacuteWSSoap" name="XacuteWSSoap">
      <soap:address location="http://naholldo31020/Lighthammer/SOAPRunner/Amy/GetListOfPlants" />
      </port>
      </service>
      </definitions>

    Hi Amy,
    here is an example how you can call a WS via http GET:
    http://<server>/Lighthammer/Runner?Transaction=<path_to_your_TRX>&XacuteLoginName=YourAccount&XacuteLoginPassword=yoursecret&outputparameter=*
    Please note you do not need to use credentials in case you calling localhost.
    I think in your case this should be the right url:
    http://naholldo31020/Lighthammer/Runner?Transaction=Amy/GetListOfPlants&XacuteLoginName=YourAccount&XacuteLoginPassword=yoursecret&outputparameter=*
    Please change parameters for
    - XacuteLoginName
    - XacuteLoginPassword
    - outputparameter (you can specify * or one of your transaction output parameter)

  • XML document must have a top level element

    Hi all,
    I have deployed my web services in 904. When I try to see the generated wsdl, I am seeing:
    XML document must have a top level element.
    in IE. Does anyone know why?
    Thanks.

    If you take a look under the location where the application was deployed, you should find a file with the name of your interface (or class) and the extension .wsdl.
    If there is already a file of that name, we do not try to re-generate it. If this file is not a valid XML file, then it will explain the error message you are seing.
    Another reason for this error is when the code generation fail silently. It can occurs in some rare case, when you have started oc4j using a JRE instead of JDK (without javac).
    Hope this helps,
    Eric

  • How do I open my old Appleworks documents which have turned into Unix Executable Files?  I would like to convert them into Pages documents.

    How do I open my old Appleworks documents which have turned into Unix Executable Files?  I would like to convert them into Pages documents.  I also have old Word Perfect documents which have become similarly unopenable.

    Best bet might be to try opening them using LibreOffice [free] and save them to .doc.
    Do you really want to save them as .pages files? You are jumping from the frypan into the fire. Yet another proprietary format that Apple has again deadended with no working translation.
    Peter

  • No default attributes while Parsing XML document

    Hellow.
    I have such a problem:
    I have XML document that uses XSD-schema.
    In XSD-schema there is element that have two atributes:
    <xsd:complexType name = "El1">
          <xsd:attribute name = "atr1" xsd:default = "0" type = "xsd:boolean"/>
          <xsd:attribute name = "atr2" default = "0" type = "xsd:boolean"/>
    </xsd:complexType>And in XML document I write:
    <El1 atr1 = "1"/>According to the XSD-schema parser must add to El1 second attribute "atr2" with its default value because it has default value. But when I do such a code:
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    doc = builder.parse(new File("file1.xml"));
    Element pEl;
    pEl = doc.getDocumentElement()
    NamedNodeMap Attribs = pEl.getAttributes();In the list of attributes "Attribs" - there is no attribute "attr1"!!!
    What I have to do???

    Hello All
    I am new to this parsing world. I have a doubt. I have an XML like
    <xml>
    <platform name = "windows">
    <computer>
    <hostname> hostname1 </hostname>
    <IPAddress>127.0.3.03 </IPAddress>
    </computer>
    <computer>
    <hostname> hostname2 </hostname>
    <IPAddress>127.0.3.04 </IPAddress>
    </computer>
    </platform>
    <platform name = "unix">
    <computer>
    <hostname> hostname6 </hostname>
    <IPAddress>127.0.3.08 </IPAddress>
    </computer>
    <computer>
    <hostname> hostname7 </hostname>
    <IPAddress>127.0.3.09 </IPAddress>
    </computer>
    </platform>
    </xml>
    If i want to get details about individual computer under each platform as a string how do i do that?
    Which parser would be ideal to be used DOM or SAX.

  • How to parse XML document returned by webservices

    Hi,
    I have a form (version 10.1.2.0) which has to display the credit card types using webservices. I created the webstub and jar file through jdeveloper and then after adding the jar files in the respective classpaths, I import it in the forms. I write the code in when-button-pressed and it gives the result in xml document like this:
    <?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><
    results><CardTypeTO><carTypId>3</carTypId><type>AMERICAN
    EXPRESS</type><numLength>15</numLength><cvvLength>4</cvvLength><comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><type>DISCOVER</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO><CardTypeTO><carTypId>1</carTypId><type>MASTERCARD</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><type>VISA</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>
    From the above xml document, I only need to display the type (such as AMERICAN EXPRESS, VISA, ETC) in my forms. Can somebody please tell me how to do it. Do I need to store the values in a table first and then retrieve it. Please advise. I have already read a otn document in xml parsing but I didnt understand anything from it.
    Please help. Thanks in advance.

    Hello,
    It probably exists a database package/function to parse this kind of stuff.
    If you want to keep the process into the Forms, here is a PL/SQL package you can use:
    CREATE OR REPLACE PACKAGE Pkg_Tools AS
      --  Types  --
      -- table of strings --
      TYPE TYP_TAB_CHAR IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
      --  Methodes   --
      -- function that return all contents for a given XML tag --
      FUNCTION Get_Xml_Tag
         PC$XmlContent  IN VARCHAR2,                 -- XML string
         PC$Tag         IN VARCHAR2,                 -- searched tag
         PC$NewLine     IN VARCHAR2 DEFAULT CHR(10)  -- defaull NL character
      RETURN TYP_TAB_CHAR ;
    END Pkg_Tools;
    CREATE OR REPLACE PACKAGE BODY Pkg_Tools
    IS
      -- fonction de retour du contenu d'une balise XML  --
      FUNCTION Get_Xml_Tag
         PC$XmlContent  IN VARCHAR2,                 -- contenu XML
         PC$Tag         IN VARCHAR2,                 -- tag recherche
         PC$NewLine     IN VARCHAR2 DEFAULT CHR(10)  -- defaull NL character
      RETURN TYP_TAB_CHAR
      IS
       TC$Table      TYP_TAB_CHAR ;
       LC$Ligne      VARCHAR2(32000) ;
       LC$Xml        VARCHAR2(32000) ;
       LN$INDEX      PLS_INTEGER := 0 ;
       LN$TagDeb     PLS_INTEGER ;
       LN$TagFin     PLS_INTEGER ;
       LN$TagLength  PLS_INTEGER ;
       LN$LigLength  PLS_INTEGER ;
       LN$Occur      PLS_INTEGER := 1 ;
      BEGIN
        IF ( PC$XmlContent IS NOT NULL AND PC$Tag IS NOT NULL ) THEN
          LC$Xml := REPLACE( PC$XmlContent, CHR(13), '' ) ;
          LN$TagLength := LENGTH( PC$Tag ) ;
           LOOP
          LN$TagDeb := INSTR( LC$Xml, PC$Tag, 1, LN$Occur ) ;
          LN$TagFin := INSTR( LC$Xml, '</' || SUBSTR(PC$Tag,2, 256), 1, LN$Occur ) ;
          LN$LigLength := (LN$TagFin - ( LN$TagDeb + LN$TagLength ) ) ;
          IF (LN$TagDeb > 0 AND LN$TagFin > 0 ) THEN
             LN$Occur := LN$Occur + 1 ;
             LC$Ligne := SUBSTR( LC$Xml, LN$TagDeb + LN$TagLength, LN$LigLength ) ;
             LOOP
               LN$INDEX := LN$INDEX + 1 ;
               LN$TagDeb := INSTR( LC$Ligne, PC$NewLine ) ;
               IF LN$TagDeb > 0 THEN
                 IF Trim( SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 )) IS NOT NULL THEN
                   TC$Table(LN$INDEX) := SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 ) ;
                 ELSE
                   LN$INDEX := LN$INDEX - 1 ;
                 END IF ;
                 LC$Ligne := SUBSTR( LC$Ligne, LN$Tagdeb + LENGTH( PC$NewLine ), 30000 ) ;
               ELSE
                 IF Trim(LC$Ligne) IS NOT NULL THEN
                    TC$Table(LN$INDEX) := LC$Ligne ;
                 END IF ;
                 EXIT ;
               END IF ;
             END LOOP ;
          ELSE
              EXIT ;
          END IF ;
           END LOOP ;
        END IF ;
        RETURN TC$Table ;
      END Get_Xml_Tag ;
    END Pkg_Tools;
    /Then the call:
    DECLARE
       LC$t  VARCHAR2(2000);
       LT$Table Pkg_Tools.TYP_TAB_CHAR ;
    BEGIN
       lc$t := '<?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><results>'
    ||'<CardTypeTO><carTypId>3</carTypId><TYPE>AMERICAN EXPRESS</TYPE><numLength>15</numLength><cvvLength>4</cvvLength>'
    ||'<comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><TYPE>DISCOVER</TYPE>'
    ||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO>'
    ||'<CardTypeTO><carTypId>1</carTypId><TYPE>MASTERCARD</TYPE><numLength>16</numLength><cvvLength>3</cvvLength>'
    ||'<comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><TYPE>VISA</TYPE>'
    ||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>' ;
       LT$Table := Pkg_Tools.Get_Xml_Tag(LC$T,'<TYPE>') ; 
       IF LT$Table.COUNT > 0 THEN
         FOR i IN LT$Table.First .. LT$Table.Last LOOP
            dbms_output.put_line( 'Table(' || i || ')=' || LT$Table(i) ) ;
         END LOOP ;
       ELSE
         dbms_output.put_line( 'tag xml not found' ) ;
       END IF ;
    END;Francois

  • Need help in Parsing XML Document in Oracle

    Hello Experts,
    I urgently need your help. We have xml document on the Web but not on the File System. How can I parse the xml document on the web in Oracle.
    Any link, blog or sample code would be appreciated.
    Your help would be appreciated.
    Kind Regards,
    Bhavin
    London, UK

    This breaks down to two issues
    1) Getting the XML into Oracle
    2) Parsing the XML inside Oracle
    For #1, the first two options that come to my mind are httpuirtype and utl_http. Both can be used to get information from a URL that understands HTTP requests.
    For #2, you can treat the XML as a DOMDocument or XMLType to parse it. You also could parse it via a SQL statement using XQuery or XMLTable as well.
    Many of those examples can be found on the {forum:id=34} forum or [Marco&apos;s blog|http://www.liberidu.com/blog/]. A few parsing examples that I've done can be seen at {message:id=3610259}, make sure to also follow the link I put in there to a previous example before that.

  • Parsing XML document with nested elements into multiple db tables(master-detail)

    Can you help me with storing xml document into master-detail tables?
    I have two tables:
    1) customers (customerid number primary key, firstname varchar2(30),lastname varchar2(30))
    2) cust_addresses (customerid number references customers, street varchar2(30),city varchar2(30),state varchar2(10),zip varchar2(10))
    I have XML document:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW num="1">
    <CUSTOMERID>1044</CUSTOMERID>
    <FIRSTNAME>Paul</FIRSTNAME>
    <LASTNAME>Astoria</LASTNAME>
    <HOMEADDRESS>
    <STREET>123 Cherry Lane</STREET>
    <CITY>SF</CITY>
    <STATE>CA</STATE>
    <ZIP>94132</ZIP>
    </HOMEADDRESS>
    <HOMEADDRESS>
    <STREET>N.Fryda 4</STREET>
    <CITY>CB</CITY>
    <STATE>CZ</STATE>
    <ZIP>37005</ZIP>
    </HOMEADDRESS>
    </ROW>
    </ROWSET>
    I know that I must use DBSM_XMLSave package, create view and instead of trigger but I did found no example in documentation.
    Thanx.

    Interested question; one I do not know the answer to at the moment, I am afraid. I would like to know your results.
    To tell others, though, what I have done. I did finally adapt Muench's not-yet-published examples #71 to work with a table. Here the table has as it's value "#{backing_app_EPG_DAYPG.jobDayDriverTable[row.Id1]}"
    This accesses a hash map defined in the backing bean as follows:
    public Map jobDayDriverTable = new HashMap(){
    @Override
    public Object get(Object key) {
    Number jobDayId = (Number)key;
    if (getEpgDayPage().jobDayDrivers(jobDayId) != null) {
    return getEpgDayPage().jobDayDrivers(jobDayId).getAllRowsInRange();
    else return null;
    jobDayDrivers returns RowIterator. From this I call getAllRowsInRange which returns a Row[]. The table consumes this as a value, and lists the values as I want.
    Since the table is using Rows for its rows, I am guessing that it would have access to #{row.rowKeyStr}, or at least #{row.<pk>} which would allow you to programmatically set the current row using code like the following:
    public static boolean setCurrentRow() {
    // BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    // bindings.getOperationBinding("setCurrentRowWithKey");
    (OperationBinding)EL.get("#{bindings.setCurrentRowWithKey}");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return false;
    return true;
    You could call this as part of code in a pages backing bean behind a button or link.
    Hope this helps somebody.
    By the way example #71 was to get a detail set of rows from a master row value and display the detail set in the master row of an af:table.
    You can find this and other examples at http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html

  • Parse xml document with xpath

    I would like to parse an xml document using xpath, see:
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    however, in the documentation (in the link above), it states that I need J2SE 5.0.
    Currently, I have:
    $ java -version
    java version "1.5.0_11"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)
    Does that mean that I really have to install J2SE 5.0 in order to use J2SE 5.0's XPath support? Does anybody know anything about getting started with XPath, and whether I can just use my existing version of Java? I've never used XPath.
    For more documentation, one can view:
    http://www.w3.org/TR/xpath20/
    Thank you.

    I have copied the code for the xpath tutorial on
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    exactly as it is on the tutorial, and imported the correct jars (I think).
    But still my code is giving lots of errors!
    Granted its my first shot but anyway here's the code and the errors...
    package test;
    import org.jdom.xpath.*;
    import java.io.*;
    import javax.xml.xpath.*;
    public class XPath {
         public static void main (String [] args){
              XPathFactory factory = XPathFactory.newInstance();
              XPath xPath=factory.newXPath();
              XPathExpression  xPathExpression=xPath.compile("/catalog/journal/article[@date='January-2004']/title");
              File xmlDocument = new File("/home/myrmen/workspace/Testing/test/catalog.xml");     
              //FileInputStream fis = new FileInputStream(xmldocument); 
              InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
              String title = xPathExpression.evaluate(inputSource);
              String publisher = xPath.evaluate("/catalog/journal/@publisher", inputSource);
              String expression="/catalog/journal/article";
              NodeSet nodes = (NodeSet) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);
              NodeList nodeList=(NodeList)nodes;
              SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
              org.jdom.Document jdomDocument = saxBuilder.build(xmlDocument);
              org.jdom.Attribute levelNode = (org.jdom.Attribute)(XPath.selectSingleNode(jdomDocument,"/catalog//journal[@title='JavaTechnology']" + "//article[@date='January-2004']/@level"));
              levelNode.setValue("Intermediate");
              org.jdom.Element titleNode = (org.jdom.Element) XPath.selectSingleNode( jdomDocument,"/catalog//journal//article[@date='January-2004']/title");
              titleNode.setText("Service Oriented Architecture Frameworks");
              java.util.List nodeList = XPath.selectNodes(jdomDocument,"/catalog//journal[@title='Java Technology']//article");
              Iterator iter=nodeList.iterator();
              while(iter.hasNext()) {
                   org.jdom.Element element = (org.jdom.Element) iter.next();
                   element.setAttribute("section", "Java Technology");
              XPath xpath = XPath.newInstance("/catalog//journal:journal//article/@journal:level");
              xpath.addNamespace("journal", "http://www.w3.org/2001/XMLSchema-Instance");
              levelNode = (org.jdom.Attribute) xpath.selectSingleNode(jdomDocument);
              levelNode.setValue("Advanced");
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         Type mismatch: cannot convert from XPath to XPath
         The method compile(String) is undefined for the type XPath
         InputSource cannot be resolved to a type
         InputSource cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeList cannot be resolved to a type
         NodeList cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         The method selectSingleNode(Document, String) is undefined for the type XPath
         The method selectSingleNode(Document, String) is undefined for the type XPath
         Duplicate local variable nodeList
         The method selectNodes(Document, String) is undefined for the type XPath
         Iterator cannot be resolved to a type
         The method newInstance(String) is undefined for the type XPath
         The method addNamespace(String, String) is undefined for the type XPath
         The method selectSingleNode(Document) is undefined for the type XPath
         at test.XPath.main(XPath.java:12)

  • Parsing xml document

    <?xml version="1.0" ?>
    </result>
    <response xmlns="http://comnet.com/namespaces/wcm/appint/1.0">      <objectset>
    <objectstore>                               <id>{275F7BDB-6F42-4CC1-99A3-59134AE30C38}</id>                <name>Alaska</name>
         <properties>
         <property>
         <name>Display Name</name>                     <value>Alaska</value>                     <symname>DisplayName</symname>                <datatype>8</datatype>
         </property>
                   </properties>
    </objectstore>
    <objectstore>                               <id>{98FA40B5-A425-4092-85D4-9BBD61A77E6F}</id>                <name>Yukon Territory</name>
              <properties>
         <property>
         <name>Display Name</name>                <value>Yukon Territory</value>                <symname>DisplayName</symname> <datatype>8</datatype>
    </property>
    </properties>      </objectstore>
    <count>2</count>
    </objectset>
    </response>
    </result>
    </appintresponse>
    hi this my xml document.i trying to parse this document..
    i need to display the id and name values of each objectstore tag in a select box
    id as option value and name as option text.
    iam doing like this..
    e = doc.getDocumentElement();
    list = e.getElementsByTagName("name");
    for(int i = 0; i < list.getLength(); i++)
    n = list.item(i);
    if(n.hasChildNodes())
    list2 = n.getChildNodes();
    for(int j = 0; j < list2.getLength(); j++)
    n2 = list2.item(j);
    String name =n2.getNodeValue();
                                                      out.println(name);
    it displaying the name but also its displaying the value which is name tag of property element..how can i avoid this..
    regards,

    as <id> is a child of <ObjectStore> it would seem that you should getElementsByName("ObjectStore") first, then find the id and name children.

  • Parse XML document ,create table according to tags &  load data to  table

    Hi All!
    I have one of the most common problem, one faces when dealing with xml stuff and oracle.I get xml documents, with each file having different tags.I want to write a pl/sql procedure such that, the xml file is parsed, a table is created with the tag names becoming the column names and all the nodes' data get inserted into the table as rows.I am using oracle 10g.
    I read a thread at the following url:
    Parse XML and load into table
    But did not get much of it.
    Can anybody please tell me how to accomplish this.
    Thanking in advance.
    Regards,
    Deepika.

    Why do people have such an aversion to the XML DB forum for XML questions...
    See FAQ for XML DB forum here: XML DB FAQ
    Explains all about getting XML into tables in the database.

  • Parse XML document based on the criteria

    Hi,
    I'm trying to parse an xml document using sax parser. I don't want to parse whole xml document. I want to parse based on the start element which I specify and parsing should stop based on the end element which i specified. I don't know how to restrict while parsing . The start element and end element will be varying ? Can somebody help out in resolving this problem.
    thanks in advance

    Don't look at it that way. The SAX parser will give you the document in pieces; just ignore the pieces you aren't interested in.

Maybe you are looking for

  • IPhone 4 not recognized by PC

    Hi For some time now my iPhone is not recgnized by my pc( I get a message saying device not recognized). I have tried every suggestion I saw including updating and reinstalling the driver. Checking it on other computers ( Mac and pc) - it was not rec

  • Population of Oracle DBs from XML?

    Forgive me if I haven't fully understood Oracle's new XML parser for Java, but is it possible to >>directly<< populate an Oracle database from an XML file or do you have to use the Java parser. As a developer using Delphi it would be most useful to h

  • Odd Issue Editing in Photoshop with color and lens corrections

    First off, I'm on LR 4.4 and PS CS6 (Camera Raw 7.4.0.137) using ProPhoto RGB as my LR colorspace and have my PS color settings as Working Space: ProPhoto RGB and my color management policies to preserve embedded profiles. When I right click on a DNG

  • Three ATA drives in a G4?

    Hi I have a G4 (AGP Graphics) with 2 ATA HD's installed. I want to upgrade to Tiger but on a new drive as I have very little space left on my Macintosh HD. Can I fit another ATA drive? The manual is slightly vague as to the exact number of ATA/SCSI d

  • Cannot find created infoobject in infoobjects, can see it in metadata repos

    Hi all, I have created a characteristic infobject in an infoarea. But i cannot view the infoobject in the infoobjects (when i click find and see, it says not entries found). But the same when i check in the meta data repository, i can see the infoobj