Update passed in XML doc with pl/sql xmldom

Hi,
I have an xml document that is passed in through a stored procedure as CLOB. I'm trying to use the XMLParser and XMLDOM to add an additional node
The XML looks something like the following
<rowset>
<row>
<firstname>john</firstname>
</row>
<row>
<firstname>jane</firstname>
</row>
</rowset>
I need to loop through each of <mynames> nodes and then add another node <lastame> so it looks like the following
<rowset>
<row>
<firstname>john</firstname>
<lastame>smith</lastame>
</row>
<row>
<firstname>jane</firstname>
<lastame>smith</lastame>
</row>
</rowset>
I have the following code
parseClob XMLPARSER.Parser;
newNames XMLDOM.DOMDocument;
tempNode XMLDOM.DOMNode;
mye xmldom.domelement;
     item_text xmldom.DOMText;
numofrows number;
     nodeList xmldom.DOMNodeList;
     newnode xmldom.domnode;
parseClob := xmlparser.newParser;
XMLPARSER.parseClob(parseClob,names);
newNames := XMLPARSER.getDocument(parseClob);
XMLPARSER.freeParser(parseClob);
nodeList := xslprocessor.selectNodes(xmldom.makeNode(newNames), '//rowset/row');
numOfRows := xmldom.getlength(nodeList)-1;
for i in 0..numOfRows LOOP
newnode := xmldom.item(nodeList, i);
          --create the new node
mye := xmldom.createElement(newName, 'lastname');
--add it to the new node   
tempNode := xmldom.appendChild(newnode, xmldom.makeNode(mye));
--update the text in the lastname   
item_text := xmldom.createTextNode(newNames, 'smith');
tempNode := xmldom.appendChild(tempNode, xmldom.makeNode(item_text));
end loop;
what happens is that when i write out the newnode xml out to a buffer i see the <lastname> tag
but when i write out the newNames xml out to a buffer after the loop is finished the <lastname> tag is
missing. like it didn't update the newNames xml
I've seen lots of example on how to create an XML document with the DOM from scratch but nothing about updating
an passed in xml document. any help would be appreciated

Updatexml is reference in Oracle 9i, I'm sorry i should have mentioned that I am using oracle 8i. Is there something you can use in oracle 8i?

Similar Messages

  • Has anybody tried creating and validating a XML doc with XML Schema?

    Hi,
    Has anybody tried creating and validating a XML doc with XML Schema?

    With XMLBeans, an XML document may be created from and validated with an XML schema.

  • Create XML docs with hierarchy of tags and attr defined in databaste tables

    Hi,
    My problem is a little unique one. I want the ability to define the structure of the XML document (i.e. the hierarchy of element tags and attribute names) in the database tables. The values of tags and attributes will also be populated at runtime in tables.
    Then write some generic API that reads the structure of the XML document through the database tables and spits out an XML document based on this structure and values stored in the tables.
    So, basically, I want the tag names and values both to be values in the database rather than the tag names being the columns in database tables.
    With this I should be able to have one procedure/function that can serve the purpose of creating XML documents with different structures by just specifying that structure in the form of database tables.
    Almost all the Oracle XML utilities I read about, create XML docs based on a SQL query with tag names being columns in the database tables. Any help will be highly appreciated.
    Thanks,
    Monika

    Which database release are you using...
    The computed constructors feature of XQuery may help.
    -Mark

  • Still problems serializing xml-docs with xml-parser for java v2.0.2.7

    Hi !
    I'm using the Oracle XML Parser 2.0.2.7.0 and get some problems when serializing the XMLDocument.
    In one class (DOMOut) I parse a xml-file with the oracle.xml.parser.v2.DOMParser, then obtain the XMLDocument and write it to System.out
    In another class (DOMIn) I fetch the XMLDocument from System.in, search for a given Element and print it's TextValue (if existing) to System.out
    That is where the error occurs.
    I get the XMLDocument from System.in but the returning NodeList from doc.getElementsByTagName() is empty. [nl.getLength()==0] even if it shouldn't be.
    Look at this code and output:
    [DOMOut]
    DOMParser parser = new DOMParser();
    parser.parse(url);
    XMLDocument doc = (XMLDocument)parser.getDocument();
    ObjectOutputStream out = new ObjectOutputStream(System.out);
    out.writeObject(doc); out.flush();
    [DOMIn]
    ObjectInputStream in = new ObjectInputStream(System.in);
    XMLDocument doc = (XMLDocument)in.readObject();
    doc.print(System.out);
    NodeList nl = doc.getElementsByTagName("Name");
    System.out.println("Length of NodeList: "+nl.getLength());
    if (nl.getLength()==0)
    System.out.println(argv[0] + ": not in this document!");
    else {
    XMLNode node = (XMLNode) nl.item(nl.getLength()-1);
    System.out.println(node.getNodeName() + ": " + (node.getFirstChild()).getNodeValue());
    This is the relevant code.
    I javac both classes and then do this:
    java DOMOut xmltestfile.xml > xx
    java DOMIn Name < xx
    And get this as output:
    <?xml version = '1.0'?>
    <!DOCTYPE course [
    <!ELEMENT course (Name,Dept,Instructor,Student)>
    <!ELEMENT Name ((#PCDATA)*)*>
    <!ELEMENT Dept ((#PCDATA)*)*>
    <!ELEMENT Instructor (Name)>
    <!ELEMENT Student (Name)*>
    ]>
    <course>
    <Name>Calculus</Name>
    <Dept>Math</Dept>
    <Instructor>
    <Name>Jim Green</Name>
    </Instructor>
    <Student>
    <Name>Jack</Name>
    <Name>Mary</Name>
    <Name>Paul</Name>
    </Student>
    </course>
    Length of NodeList: 0
    Name: not in this document!
    Has anyone an idea?
    If I do all this stuff without serializing it works.
    If I do not search for argv[0], but the string "Name" it fails.
    If I do search for "*" it works fine!
    I'm very confused could anybody please help me a bit??
    Stefan.
    [[email protected]]

    The link has been fixed. You will go to the v2 download page
    now. Sorry for the inconvience.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Renilton Oliveira (guest) wrote:
    : I didn't find the file for version 2.0.0.0 as well.
    : Renilton
    : Andrei Filimonov (guest) wrote:
    : : I tried to download XML Parser for Java v2 it seems that
    only
    : v
    : : 1.0.1.4 is available. Could you please give an exact URL for
    : v2
    : : download?
    : : Andrei Filimonov
    : : Oracle XML Team wrote:
    : : : The Oracle XML v2 parser is now available for download
    here
    : as
    : : : an early beta release and is written in Java. It features
    : an
    : : : improved architecture over the Oracle XML v1 parser and
    has
    : : : shown better performance on small to large XML documents.
    : It
    : : : will also be able to format the XML document according to
    a
    : : : stylesheet, having integrated an XSLT processor.
    : : : Version 2 of the XML Parser for Java, besides
    incorporating
    : an
    : : : XSLT processor, has been re-architected from version 1.
    This
    : : has
    : : : resulted in a number of changes to the class names
    : especially
    : : : those that support Namespaces. See v2changes.txt and
    : the .diff
    : : : difference files in the sample directory.
    : : : Oracle XML Team
    : : : http://technet.oracle.com
    : : : Oracle Technology Network
    null

  • Generete xml doc with dtd form

    Hi,
    I am trying to generate xml doc based on dtd kind format.
    I use following code to get my xml doc is ok based on dtd like
    -----------dtd file---------------
    <!ELEMENT client_data (client_job*, person*)>
    <!ELEMENT client_job (job_cd, job_title?, primary_responsibilities?, grade_cd?, br_job_cd, eeo_job_group_id, effective_date?, end_date?)>
    <!ATTLIST client_job errMsg CDATA #IMPLIED>
    <!ATTLIST client_job deleteFlag ( Y | N ) 'N'>
    <!ELEMENT job_cd (#PCDATA)>
    <!ELEMENT job_title (#PCDATA)>
    <!ELEMENT primary_responsibilities (#PCDATA)>
    <!ELEMENT br_job_cd (#PCDATA)>
    <!ELEMENT eeo_job_group_id (#PCDATA)>
    -----------------end dtd--------------
    OracleXMLQuery qry = new OracleXMLQuery(conn, sql);
    qry.setRowsetTag("client_data");
    qry.setRowIdAttrName(null);
    // qry.useNullAttributeIndicator(true);
    qry.useLowerCaseTagNames();
    qry.setRowTag("client_job");
    xmlDocToReturn = qry.getXMLDOM();
    But if my dtd like following, i.g. has tree level, and data from multiple tables, the above code doesn't work for thes case
    --------------tree level dtd----------------
    <!ELEMENT person (person_name)>
    <!ATTLIST person person_id CDATA #REQUIRED>
    <!ATTLIST person hire_date CDATA #IMPLIED>
    <!ATTLIST person effective_date CDATA #IMPLIED>
    <!ATTLIST person end_date CDATA #IMPLIED>
    <!ELEMENT person_name (formatted_name*, given_name*, prefered_given_name?, middle_name?, family_name*, affix*)>
    <!ELEMENT formatted_name EMPTY>
    <!ATTLIST formatted_name type ( presentation | legal | sortOrder) 'presentation'>
    <!ELEMENT given_name (#PCDATA)>
    <!ELEMENT prefered_given_name (#PCDATA)>
    <!ELEMENT middle_name (#PCDATA)>
    <!ELEMENT family_name (#PCDATA)>
    <!ATTLIST family_name primary ( true | false | undefined ) 'undefined'>
    -----------------end dtd -------------------
    I try to use XMLDocumentFragment to create xml doc and appendChild , but the xml doc is not the format of the dtd required. Can you give me a Java sample?
    Thanks in advance.
    Yan

    Why don't you use XSLT?

  • Is it possible to create indexes & use them on xml docs with namespaces?

    I have put an XML doc in a BDBXML container which looks like this:
    *<ns1:note xmlns:ns1="http://www.testsch.org/ns">*
    *<ns1:to>Eric</ns1:to>*
    *<ns1:from>Brendan</ns1:from>*
    *<ns1:msg>How r u?</ns1:msg>*
    *</ns1:note>*
    Now, I am creating an index on the element "to", as:
    addIndex "ns1" "to" node-element-equality-string
    Though the index has been shown as getting created using the listIndexes command, if I lookup that index with the following command:
    lookupIndex node-element-equality-string "ns1" "to"
    the output is:
    *0 objects returned for eager index lookup 'node-element-equality-string'*
    Whereas, if I do the whole procedure without the namespaces in the document & the commands, the result is fine:
    *1 object returned for eager index lookup 'node-element-equality-string'*
    Can someone please tell me whether using namespaces, the indexes can be created or not? If yes, how?
    Thanks,
    Dev
    Edited by: user11871332 on Sep 7, 2009 3:53 PM

    Hi Dev,
    When using XML, the prefix for the namespace is really just syntactic sugar. The actual namespace in your example is "http://www.testsch.org/ns", and that's the value that you need to use when creating your index:
    addIndex "http://www.testsch.org/ns" "to" node-element-equality-stringJohn

  • Adding an XML doc with repeating tags

    Hello,
    Can anyone tell me how I take an XML document with a tag that can appear from 0-N times and map it to a database table? I am currently using a supertable and then using triggers to move data to the appropriate spot but am stuck on how to map tags that don't correspond 1-1.
    My structure is like
    <product>
    <name>
    <model>
    <cost>
    <feature>* (0-N)
    <spec>* (0-N)
    </product>
    Thanks.
    null

    Do a getElementsByTagName on a node and do a
    insert on each node found.

  • XML doc with multiple namespaces

    Hi,
    a little stupid question...
    Is it possible to get a xml file that assigns two different namespaces and I don't want to use a prefix?
    example:
    xml doc uses namespace xmlns:a="someuri" and xmlns:b="otheruri"
    <?xml version="1.0" encoding="UTF-8"?>
    <Root xmlns="someuri" xmlns:b="otheruri">
    <test/>
    <b:rest/>
    </Root>
    Some way to get prefix b out of it?
    Thanx

    okay, it was a stupid question...
    solution:
    <?xml version="1.0" encoding="UTF-8"?>
    <Root xmlns="someuri" xmlns:b="otheruri">
    <test/>
    <rest xmlns="otheruri"/>
    </Root>

  • XML docs with BLOB

    I know it is possible to save an XML document into a BLOB field. However, can anyone tell me if it is possible to pass a BLOB in an XML document. What I mean is can I have an XML document structured as follows? Is so, where can I find the syntax. We receive XML orders via XSQL page and would like to store this data in the DB.
    <xml version="1.0">
    <books>
    <book>
    <isbn>032541251</isbn>
    <title>How to Program in XML</title>
    <cover>****.jpg file with picture of book that can be store in BLOB ****</cover>
    <exceprt>****.PDF or MS Word .DOC of prelude for example****</except>
    </book>
    </books>
    </xml>
    Any help would be appreciated

    Refer
    http://builder.com.com/5100-31-5075709.html
    The XMLType may also be used.
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/HowToLoadLargeXML.html

  • Xml dom with pl/sql or java

    Hi,
    For increase speed an procedure with xmldom, wich langage can I use ? pl/sql or java
    Thanks
    Ben

    I also recall readings somewhere how Oracle have coded the database packages into native C to boost performance, but for the life of me I can't recall where it was now.
    I've not done any Java parsing work, but I have been using PL/SQL to parse XML Schema documents (which are in effect XML documents so there's no difference there really). I found that all I needed to be able to parse the XML schema so that I could navigate through the document and carry out my own processing was the use of the DBMS_XMLDOM package. This allowed me to navigate from the root element down through the siblings and children elements and extract the attributes and any data that was required on the way.
    The Oracle PL/SQL Packages and Types Reference details all the available built-in packages sufficiently well.
    Regards

  • Slow extraction in big XML-Files with PL/SQL

    Hello,
    i have a performance problem with the extraction from attributes in big XML Files. I tested with a size of ~ 30 mb.
    The XML file is a response of a webservice. This response include some metadata of a document and the document itself. The document is inline embedded with a Base64 conversion.  Here is an example of a XML File i want to analyse:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body>
          <ns2:GetDocumentByIDResponse xmlns:ns2="***">
             <ArchivedDocument>
                <ArchivedDocumentDescription version="1" currentVersion="true" documentClassName="Allgemeines Dokument" csbDocumentID="***">
                   <Metadata archiveDate="2013-08-01+02:00" documentID="123">
                      <Descriptor type="Integer" name="fachlicheId">
                         <Value>123<Value>
                      </Descriptor>
                      <Descriptor type="String" name="user">
                         <Value>***</Value>
                      </Descriptor>
                      <InternalDescriptor type="Date" ID="DocumentDate">
                         <Value>2013-08-01+02:00</Value>
                      </InternalDescriptor>
                      <!-- Here some more InternalDescriptor Nodes -->
                   </Metadata>
                   <RepresentationDescription default="true" description="Description" documentPartCount="1" mimeType="application/octet-stream">
                      <DocumentPartDescription fileName="20mb.test" mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" hashValue=""/>
                   </RepresentationDescription>
                </ArchivedDocumentDescription>
                <DocumentPart mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" representationNumber="0">
                   <Data fileName="20mb.test">
                      <BinaryData>
                        <!-- Here is the BASE64 converted document -->
                      </BinaryData>
                   </Data>
                </DocumentPart>
             </ArchivedDocument>
          </ns2:GetDocumentByIDResponse>
       </soap:Body>
    </soap:Envelope>
    Now i want to extract the filename and the Base64 converted document from this XML response.
    For the extraction of the filename i use the following command:
    v_filename := apex_web_service.parse_xml(v_xml, '//ArchivedDocument/ArchivedDocumentDescription/RepresentationDescription/DocumentPartDescription/@fileName');
    For the extraction of the binary data i use the following command:
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    My problem is the performance of this extraction. Here i created some summary of the start and end time for the commands:
    Start Time
    End Time
    Difference
    Command
    10.09.13 - 15:46:11,402668000
    10.09.13 - 15:47:21,407895000
    00:01:10,005227
    v_filename_bcm := apex_web_service.parse_xml(v_xml, '//ArchivedDocument/ArchivedDocumentDescription/RepresentationDescription/DocumentPartDescription/@fileName');
    10.09.13 - 15:47:21,407895000
    10.09.13 - 15:47:22,336786000
    00:00:00,928891
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    As you can see the extraction of the filename is slower then the document extraction. For the Extraction of the filename i need ~01
    I wonder about it and started some tests.
    I tried to use an exact - non dynamic - filename. So i have this commands:
    v_filename := '20mb_1.test';
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    Under this Conditions the time for the document extraction soar. You can see this in the following table:
    Start Time
    End Time
    Difference
    Command
    10.09.13 - 16:02:33,212035000
    10.09.13 - 16:02:33,212542000
    00:00:00,000507
    v_filename_bcm := '20mb_1.test';
    10.09.13 - 16:02:33,212542000
    10.09.13 - 16:03:40,342396000
    00:01:07,129854
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    So i'm looking for a faster extraction out of the xml file. Do you have any ideas? If you need more informations, please ask me.
    Thank you,
    Matthias
    PS: I use the Oracle 11.2.0.2.0

    Although using an XML schema is a good advice for an XML-centric application, I think it's a little overkill in this situation.
    Here are two approaches you can test :
    Using the DOM interface over your XMLType variable, for example :
    DECLARE
      v_xml    xmltype := xmltype('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
           <soap:Body> 
              <ns2:GetDocumentByIDResponse xmlns:ns2="***"> 
                 <ArchivedDocument> 
                    <ArchivedDocumentDescription version="1" currentVersion="true" documentClassName="Allgemeines Dokument" csbDocumentID="***"> 
                       <Metadata archiveDate="2013-08-01+02:00" documentID="123"> 
                          <Descriptor type="Integer" name="fachlicheId"> 
                             <Value>123</Value> 
                          </Descriptor> 
                          <Descriptor type="String" name="user"> 
                             <Value>***</Value> 
                          </Descriptor> 
                          <InternalDescriptor type="Date" ID="DocumentDate"> 
                             <Value>2013-08-01+02:00</Value> 
                          </InternalDescriptor> 
                          <!-- Here some more InternalDescriptor Nodes --> 
                       </Metadata> 
                       <RepresentationDescription default="true" description="Description" documentPartCount="1" mimeType="application/octet-stream"> 
                          <DocumentPartDescription fileName="20mb.test" mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" hashValue=""/> 
                       </RepresentationDescription> 
                    </ArchivedDocumentDescription> 
                    <DocumentPart mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" representationNumber="0"> 
                       <Data fileName="20mb.test"> 
                          <BinaryData> 
                            ABC123 
                          </BinaryData> 
                       </Data> 
                    </DocumentPart> 
                 </ArchivedDocument> 
              </ns2:GetDocumentByIDResponse> 
           </soap:Body> 
        </soap:Envelope>');
      domDoc    dbms_xmldom.DOMDocument;
      docNode   dbms_xmldom.DOMNode;
      node      dbms_xmldom.DOMNode;
      nsmap     varchar2(2000) := 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="***"';
      xpath_pfx varchar2(2000) := '/soap:Envelope/soap:Body/ns2:GetDocumentByIDResponse/';
      istream   sys.utl_characterinputstream;
      buf       varchar2(32767);
      numRead   pls_integer := 1;
      filename       varchar2(30);
      base64clob     clob;
    BEGIN
      domDoc := dbms_xmldom.newDOMDocument(v_xml);
      docNode := dbms_xmldom.makeNode(domdoc);
      filename := dbms_xslprocessor.valueOf(
                    docNode
                  , xpath_pfx || 'ArchivedDocument/ArchivedDocumentDescription/RepresentationDescription/DocumentPartDescription/@fileName'
                  , nsmap
      node := dbms_xslprocessor.selectSingleNode(
                docNode
              , xpath_pfx || 'ArchivedDocument/DocumentPart/Data/BinaryData/text()'
              , nsmap
      --create an input stream to read the node content :
      istream := dbms_xmldom.getNodeValueAsCharacterStream(node);
      dbms_lob.createtemporary(base64clob, false);
      -- read the content in 32k chunk and append data to the CLOB :
      loop
        istream.read(buf, numRead);
        exit when numRead = 0;
        dbms_lob.writeappend(base64clob, numRead, buf);
      end loop;
      -- free resources :
      istream.close();
      dbms_xmldom.freeDocument(domDoc);
    END;
    Using a temporary XMLType storage (binary XML) :
    create table tmp_xml of xmltype
    xmltype store as securefile binary xml;
    insert into tmp_xml values( v_xml );
    select x.*
    from tmp_xml t
       , xmltable(
           xmlnamespaces(
             'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
           , '***' as "ns2"
         , '/soap:Envelope/soap:Body/ns2:GetDocumentByIDResponse/ArchivedDocument/DocumentPart/Data'
           passing t.object_value
           columns filename    varchar2(30) path '@fileName'
                 , base64clob  clob         path 'BinaryData'
         ) x

  • Parsing an XML doc with unavailable entity (DTD)

    Hi all,
    I am trying to parse an XML file (web.xml) that has the following DOCTYPE in the head of the document:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app id="WebApp">When the parser starts, it will look for the DTD on the Sun site, however my work firewall blocks access to this so I get an exception when parsing.
    To resolve this, I have tried to force the parser to look for a local copy of the DTD instead of the Sun site but to no avail. I still get the same error but don't know why it wont look at the local DTD.
    Here is my code:
    * InterceptingXml.java
    * Created on 04 April 2006, 15:58
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package org.xmldemos;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.net.URI;
    import java.net.URISyntaxException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.xml.sax.EntityResolver;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    * @author CS781RJ
    public class InterceptingXml
        /** Creates a new instance of InterceptingXml */
        public InterceptingXml() { }
        public void parse(String filename)
            try
                // Create an XML parser
                DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                // Install the entity resolver
                builder.setEntityResolver(new MyResolver());
                // Parse the XML file
                Document doc = builder.parse(new File(filename));
            catch (SAXException e) { e.printStackTrace(); }
            catch (ParserConfigurationException e) { e.printStackTrace(); }
            catch (IOException e) { e.printStackTrace(); }
            catch (Exception e) { e.printStackTrace(); }
        public class MyResolver implements EntityResolver
            // This method is called whenever an external entity is accessed
            // for the first time.
            public InputSource resolveEntity(String publicId, String systemId)
                try
                    System.out.println("publicId: " + publicId + " systemId: " + systemId);
                    // Wrap the systemId in a URI object to make it convenient
                    // to extract the components of the systemId
                    URI uri = new URI(systemId);
                    System.out.println("URI scheme: " + uri.getScheme());
                    System.out.println("URI scheme specific: " + uri.getSchemeSpecificPart());
                    // Check if external source is a file
                    if ("http".equals(uri.getScheme()))
                        String filename = uri.getSchemeSpecificPart();
                        filename = "file:/C:/web-app_2_3.dtd";
                        InputSource isrc = new InputSource(new FileReader(filename));
                        return isrc;
                catch (URISyntaxException e) { }
                catch (IOException e) { }
                // Returning null causes the caller to try accessing the systemid
                return null;
        public static void main(String[] args)
            InterceptingXml ixml = new InterceptingXml();
            ixml.parse("c:\\web.xml");
    }And here is the exception:
    init:
    deps-jar:
    compile-single:
    run-single:
    publicId: -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN systemId: http://java.sun.com/dtd/web-app_2_3.dtd
    URI scheme: http
    URI scheme specific: //java.sun.com/dtd/web-app_2_3.dtd
    java.net.UnknownHostException: java.sun.com
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
            at java.net.Socket.connect(Socket.java:507)
            at java.net.Socket.connect(Socket.java:457)
            at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
            at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
            at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
            at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
            at sun.net.www.http.HttpClient.New(HttpClient.java:287)
            at sun.net.www.http.HttpClient.New(HttpClient.java:299)
            at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:792)
            at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:744)
            at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:669)
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:913)
            at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973)
            at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905)
            at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:872)
            at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:282)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1021)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
            at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
            at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
            at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
            at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
            at org.xmldemos.InterceptingXml.parse(InterceptingXml.java:45)
            at org.xmldemos.InterceptingXml.main(InterceptingXml.java:88)
    BUILD SUCCESSFUL (total time: 18 seconds)I have noticed that return isrc; does not get executed even though the debugger steps to the line above it.
    Thanks in advance.
    Riz

    What's the point of all that code in your EntityResolver? Would the code work just as well if the DTD didn't even exist? Then do this:public InputSource resolveEntity(String publicId, String systemId)
                return new InputSource(new StringReader(""));
            }However if you really do need to redirect to a local copy of the DTD then consider this:catch (IOException e) { }can be a real barrier to understanding in the case that an IOException is thrown. At least print a stacktrace. And: the FileReader class wants a file name in its constructor, not a URI. And in this code:String filename = uri.getSchemeSpecificPart();
    filename = "file:/C:/web-app_2_3.dtd";you could write this instead:String filename = "file:/C:/web-app_2_3.dtd";which would be both shorter and easier to understand.

  • Applet parsing XML doc with schema

    I'm trying to parse (org.apache.xerces.parsers.SAXParser) an xml document and validate it with a schema file. I'm having a little difficulty understanding how the schemaLocation (as specified in the xml file) is used by the parser. I'm trying to use a relative path....but what is it relative to???
    In the xml file I specify the schemaLocation as...
    xsi:schemaLocation="http://tempuri.org/DeviceDefinition.xsd ./Configuration/DeviceDefinition.xsd"
    The directory structure I'm using is...
    ProjectX/applet.jar
    ProjectX/applet.html
    ProjectX/Configuration/DeviceDefinition.xml
    ProjextX/Configuration/DeviceDefinition.xsd
    It's my understanding that when working with an applet the paths are a relative to the directory where the applet is installed - ProjectX in this case. Yet when I use the above defined schemaLocation I get the following error:
    [Fatal Error] :0:0: File "file:///C:/Documents and Settings/dnelson/Desktop/Configuration/DeviceDefinition.xsd" not found.
    It seem to be using my user.dir as a starting point for the relative path. Does anyone know why this happens???
    What's the proper way to specify the schemaLocation??

    xerces hates spaces in uri. so try encoding the url or get rid of the spaces

  • Search XML doc with Intermedia

    Is the following query correct for Intermedia? It doesn't return any rows and I know I have some in my table.
    SELECT ID
    FROM ngtn_transition
    WHERE transition_name = 'Negotiate'
    AND status = 0
    and ( contains (source, '(DESKA WITHIN desk) and (USRA WITHIN user)') > 0 OR
    contains (destination,'(DESKA WITHIN desk) and (USRA WITHIN user)') > 0 ) and
    ( contains (source, 'DESKB WITHIN desk') > 0 OR
    contains (destination, 'DESKB WITHIN desk') > 0 );
    null

    Yes, thanks Steve. I loaded ctxsrv as a daemon process and it syncs all DML every few seconds. Very nice, however, I heard ctxsrv causes a lot of index fragmentation?

  • ON UPDATE CASCADE and Autoincrement primary key with Oracle SQL Developer

    hello everybody,
    I want to know if Oracle SQL Developer manage autoincrement on primary key and "ON UPDATE CASCADE" when i migrate (with data) SQL Server database in Oracle database.
    Can you help me ?
    Thanks for your suggestions.

    Obtain the value of the auto increment key with the getGeneratedKeys() method.
    Statement stmt = null;
    ResultSet rs = null;
    stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
                                    java.sql.ResultSet.CONCUR_UPDATABLE);
    stmt.executeUpdate("DROP TABLE IF EXISTS autoIncTable");
        stmt.executeUpdate(
                "CREATE TABLE autoIncTable ("
                + "priKey INT NOT NULL AUTO_INCREMENT, "
                + "dataField VARCHAR(64), PRIMARY KEY (priKey))");
    stmt.executeUpdate(
                "INSERT INTO autoIncTable  (dataField) "
                + "values ('data field value')",
                Statement.RETURN_GENERATED_KEYS);
    int autoIncKeyFromApi = -1;
        rs = stmt.getGeneratedKeys();
        if (rs.next()) {
            autoIncKeyFromApi = rs.getInt(1);
        } else {
        rs.close();

Maybe you are looking for

  • Problem in  Creating a view using infotypes PA0001,PA0002,...

    Hi, Can anybody please help me how to create a Maintainence view using PA0001,PA0002,PA0003,PA0006,PA0032. I tried to create it using se54. when i use PA0003 as check table, i am not able to create relations with PA0001,PA0002,PA0032,PA0006. Thanks i

  • Firmware Upgrade for WRT54G

    I have download latest firmware Version 8, I completed the firmware upgrade successfully, however on the router page right on the top it still show the earlier version 1.02. How do I checked whether I upgraded to Version 8. I have followed the firmwa

  • How to insert automatic Date/Time Stamp on filename?!

    I have a simple chart that I fill out for work hours and whatnot every day with the Numbers program. I would love to have the date inserted into the filename automatically so that I don't have to manually enter it every day when I save. Is this possi

  • Problem while installing adobe photoshop cs6

    Hey guys, I have been trying to install adobe photshop CS3 trial version on my MAC. I have the adobe air installed. When I get to adobes webpage to download the trial version i get this message: This application cannot be installed because this insta

  • Interfacing Accounting entries to Oracle Financials

    Dear Experts, We are implementing an IS-Retail project for a client. The strange part of the implementation is that the client will still be using Oracle Financials as the Finance module and SAP FICO module will be just a facilitator. Keeping this in