Parsing an xml referencing an external DTD in PLSQL

Hello,
I am using Oracle 9.2.0.3 on HPUX 11i. I want to use DBMS_XMLPARSER to
process XML documents stored in a table as CLOBs. In the documents theres a
DOCTYPE tag <!DOCTYPE myDocType SYSTEM "DTD/myDTD.dtd">.
The following code returns :
ORA-31001: Invalid resource handle or path name "/DTD/myDTD.dtd"
ORA-06512: at "XDB.DBMS_XMLDOM", line 3840
ORA-06512: at "XDB.DBMS_XMLDOM", line 3883
My utl_file_dir parameter is set to '*'
The error comes form the call : aNodeList :=
DBMS_XMLDOM.getElementsByTagName(aDoc, 'myDocType') ;
The same code using the XDK works fine just replacing DBMS_XMLPARSER with
XMLPARSER, DBMS_XMLDOM with XMLDOM... but is slow
I also tried to remove the DOCTYPE tag and it works fine and fast.
Do you have any idea of what I could do to make the DTD regognized.
Thanks a lot
David
DECLARE
aParser DBMS_XMLPARSER.PARSER ;
aDoc DBMS_XMLDOM.DOMDOCUMENT ;
aNodeList DBMS_XMLDOM.DOMNodeList ;
aNode DBMS_XMLDOM.DOMNode ;
aNodeAttr DBMS_XMLDOM.DOMNode ;
aNodeAttrList DBMS_XMLDOM.DOMNamedNodeMap ;
CURSOR C_test IS
SELECT payload
FROM TEST ;
BEGIN
aParser := DBMS_XMLPARSER.newParser ;
DBMS_XMLPARSER.setValidationMode(aParser, FALSE) ;
DBMS_XMLPARSER.setBaseDir(aParser, '/opt/test') ;
FOR R_test IN C_test LOOP
DBMS_XMLPARSER.parseClob(aParser, R_test.payload) ;
aDoc := DBMS_XMLPARSER.getDocument(aParser) ;
aNodeList := DBMS_XMLDOM.getElementsByTagName(aDoc, 'myDocType') ;
IF DBMS_XMLDOM.isNull(aDoc) THEN
DBMS_OUTPUT.PUT_LINE('Doc IS NULL') ;
ELSE
FOR idx IN 0..(DBMS_XMLDOM.getLength(aNodeList)-1) LOOP
aNode := DBMS_XMLDOM.item(aNodeList, idx) ;
dbms_output.put_line(DBMS_xmldom.getNodeName(aNode)) ;
dbms_output.put_line(DBMS_xmldom.getNodeValue(aNode)) ;
aNodeAttrList := DBMS_XMLDOM.getAttributes(aNode) ;
FOR idx1 IN 0..(DBMS_XMLDOM.getLength(aNodeAttrList)-1) LOOP
aNodeAttr := DBMS_XMLDOM.item(aNodeAttrList, idx1) ;
dbms_output.put_line(DBMS_xmldom.getNodeName(aNodeAttr)
|| ' = '||DBMS_xmldom.getNodeValue (aNodeAttr)) ;
END LOOP ;
END LOOP ;
END IF ;
END LOOP ;
DBMS_XMLPARSER.freeParser(aParser) ;
END ;

For security purposes the DBMS_XMLPARSER and DBMS_XMLDOM package will not access files on the local file system. To allow the DTD to be resolved you will need to create a DTD folder in the root of the XML DB repository and then load the DTD into that folder. Ensure that the ACL on the DTD folder and DTD document allow the user performing the parsing read access to the docuemnt. You can verify this by connecting as the user in question and performing
select xdburitype('/DTD/myDTD.dtd').getCLOB() from dual

Similar Messages

  • Validating an XML document using external DTD?

    Hi,
    I want to validate an XML file using external DTD with SAX parser.
    How can I validate an XML file with external DTD.
    Thanks in Advance,
    Mahendra

    I dont think we can set a DTD file throug java while
    parsing an XML.I've done it with an XML schema though. Can you use that instead? For schemas you do something like:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setAttribute( "http://java.sun.com/xml/jaxp/properties/schemaSource",
                                       schemaUrl );where schemaUrl in this case would be something like file:///usr/local/whatever.xsd

  • Referencing an external DTD

    hi,
    I am facing problems while trying to parse an XML file, when the correspoding DTD is a jar file resource. I get the following error
    org.xml.sax.SAXException: Fatal Error: URI=jar:file:/u/arun/projects/base/jar/c.jar!/config/prices/parser/input.xml Line=2: External entity not found: "jar:file:/u/arun/projects/base/jar/c.jar!/config/prices/parser/../gui/format.dtd".
    at deshaw.common.format.parser.XmlParser.fatalError(XmlParser.java:575)
    at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3185)
    at .....
    my xml file URI is
    jar:file:/u/arun/projects/base/jar/c.jar!/config/prices/parser/input.xml
    the dtd is in the same jar "c.jar", albeit in a different directory "gui"
    jar:file:/u/arun/projects/base/jar/c.jar!/config/prices/gui/format.dtd
    in input.xml i am trying to reference the dtd as follows
    <!DOCTYPE Formats SYSTEM "../gui/format.dtd">
    however this relative reference does not work, and throws the above exception. i can't understand why this fails. Can somebody throw more light on this problem, and help me resolve it?
    Thanks
    arun

    As per your question, your XML has
    <!DOCTYPE Formats SYSTEM "../gui/format.dtd">
    I think, you should have
    <!DOCTYPE Format SYSTEM "../gui/format.dtd">
    and your Root element should also be named as "Format". Does this help?

  • Validating XML against an external DTD

    I've three questions concerning the validation of an XML file on Checkin:
    1. Can the SimpleXMLParser validate an XML file against an external (internal) DTD.
    2. How do I have to construct the !DOCTYPE Reference in my XML file for the parser to find my external DTD
    3. Do I need to have a iFS type definition for my file to get it validated
    null

    Yes, DTD Validation is supported for 1.1
    but its not supported on a Per document basis
    or a per protocol basis.
    There is a System wide Property called
    IfsDefaultDTDValidation which if set to true
    will turn on validation for the entire
    system (all protocols)
    In addition, there is also support for a validate option to be passed to the parser
    (which is currently not exposed for 1.1 through the protocols) but a Custom Parser
    or application can set the validate mode on.
    The validate option setting takes preference
    over the IfsDefaultDTDValidation setting
    null

  • XML-Document with extern DTD

    Hello!
    How can the Oracle XML-Parser parse a XML-Document without the
    XML-Declaration. There is no information about the Version and
    the DTD in the XML-Document. Can I use an extern DTD?
    Thanks,
    Peter
    null

    Peter Roemer (guest) wrote:
    : Hello!
    : How can the Oracle XML-Parser parse a XML-Document without the
    : XML-Declaration. There is no information about the Version and
    : the DTD in the XML-Document. Can I use an extern DTD?
    : Thanks,
    : Peter
    Have you tried oracle.xml.parser.v2.XMLParser.setDoctype(DTD)?
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • XML VALIDATION WITH EXTERNAL DTD

    I've the following problem:
    I've stored a dtd into the xdb repository(with createresource function) and all seems work.
    In this DTD i've declared some element and one entity in this way :
    <!ENTITY emsp "&#x2003;" ><!--=em space-->
    When i try to store or extract my xml (with sql extract function) i get :
    ORA-19202 Error during xml processing
    LPX-00217 : invalid character 8195 (\u2003)
    I've to declare the entity in a different way ?
    Thanks in advance
    Giovanni

    You might want to check out the XML DB forum FAQ rather than ask XML questions on the SQL and PL/SQL forum:
    XML DB FAQ

  • Parsing a xml file

    i need a code for this...
    write a class for "myxmlparser" to parse "*.xml" fileto "*.dtd" file.
    sundar

    You do not parse a XML file into a DTD. The DTD is a tool you may use to constrain the contents of the XML document. In short, the DTD allows you to define whether a given XML document is valid, apart from simply being well-formed.
    You parse XML either in one of three ways:
    SAX: respond to XML parsing events in your Java app.
    DOM: build an in-memory tree of XML data
    Custom: anything goesIf your task is to take an arbitrary XML document and generate an associated DTD (thought this would not be a standard methodology), you would have to write this code yourself and familiarize yourself with both XML and DTD's.
    - Saish
    "My karma ran over your dogma." - Anon

  • Can I validate an XML file using an external DTD

    Hi,
    I'm trying to use an external DTD to validate an XML
    file (which does not refer to this DTD). The java docs that ship
    with the XML parser aren't clear on how exactly to do this (or
    whether it can be done). I'd appreciate any advice on how I
    should perform this operation.
    Here's what I'm doing right now.
    1) The Java file
    import oracle.xml.parser.v2.*;
    public class ParseWithExternalDTD
    public static void main(String args[]) throws Exception
    DOMParser dp=new DOMParser();
    dp.parseDTD
    ("file:d:/jdk1.2/sample/test/family.DTD","family");
    DTD dtd=dp.getDoctype();
    dp.setDoctype(dtd);
    dp.parse("file:d:/jdk1.2/sample/test/family.xml");
    System.out.println("Finished with no errors!");
    2) The family.DTD file
    <!ELEMENT family (member*)>
    <!ATTLIST family lastname CDATA #REQUIRED>
    <!ELEMENT member (#PCDATA)>
    <!ATTLIST member memberid ID #REQUIRED>
    <!ATTLIST member dad IDREF #IMPLIED>
    <!ATTLIST member mom IDREF #IMPLIED>
    3) The family.xml file
    <?xml version="1.0" standalone="no"?>
    <family lastname="Smith">
    <TagToFoilParserValidation>
    </TagToFoilParserValidation>
    <member memberid="m1">Sarah</member>
    <member memberid="m2">Bob</member>
    <member memberid="m3" mom="m1" dad="m2">Joanne</member>
    <member memberid="m4" mom="m1" dad="m2">Jim</member>
    </family>
    4) The output
    Finished with no errors!
    As you can see, the DOMParser failed to validate the family.xml
    file against the family dtd otherwise, it would have reported a
    validation error when it came across the
    TagToFoilParserValidation.
    Any insight as to what I'm doing wrong would be much appreciated.
    Sincerely,
    Keki
    Project Iona
    Manufacturing Applications
    Oracle Corporation
    The views and opinions expressed here are
    my own and do not reflect the views and
    opinions of Oracle Corporation
    null

    Keki Burjorjee (Oracle) (guest) wrote:
    : 2 further questions related to this issue.
    : 1) Say I am using XSLT to transform A.xml into B.xml, and I
    : want to embed a reference to B.dtd within the B.xml file. Is
    : there an XSLT command which will allow me to do this?
    : 2) Is it possible for your team to give me a mechanism whereby
    I
    : can preset the xml parser to validate the next xml file (or
    : inputstream) it receives against a particular DTD? This scheme
    : does not require the dtd to be present within the XML file
    : Thanks,
    : - Keki
    : Oracle XML Team wrote:
    : : What you are doing wrong is not including a reference to the
    : : applicable DTD in your XML document. Without it there is no
    : way
    : : that the parser knows what to validate against. Including
    the
    : : reference is the XML standard way of specifying an external
    : : DTD. Otherwise you need to embed the DTD in your XML
    Document.
    : : Oracle XML Team
    : : http://technet.oracle.com
    : : Oracle Technology Network
    : : Keki Burjorjee (guest) wrote:
    : : : Hi,
    : : : I'm trying to use an external DTD to validate an XML
    : : : file (which does not refer to this DTD). The java docs that
    : : ship
    : : : with the XML parser aren't clear on how exactly to do this
    : (or
    : : : whether it can be done). I'd appreciate any advice on how I
    : : : should perform this operation.
    : : : Here's what I'm doing right now.
    : : : 1) The Java file
    : : : import oracle.xml.parser.v2.*;
    : : : public class ParseWithExternalDTD
    : : : public static void main(String args[]) throws Exception
    : : : DOMParser dp=new DOMParser();
    : : : dp.parseDTD
    : : : ("file:d:/jdk1.2/sample/test/family.DTD","family");
    : : : DTD dtd=dp.getDoctype();
    : : : dp.setDoctype(dtd);
    : : : dp.parse("file:d:/jdk1.2/sample/test/family.xml");
    : : : System.out.println("Finished with no errors!");
    : : : 2) The family.DTD file
    : : : <!ELEMENT family (member*)>
    : : : <!ATTLIST family lastname CDATA #REQUIRED>
    : : : <!ELEMENT member (#PCDATA)>
    : : : <!ATTLIST member memberid ID #REQUIRED>
    : : : <!ATTLIST member dad IDREF #IMPLIED>
    : : : <!ATTLIST member mom IDREF #IMPLIED>
    : : : 3) The family.xml file
    : : : <?xml version="1.0" standalone="no"?>
    : : : <family lastname="Smith">
    : : : <TagToFoilParserValidation>
    : : : </TagToFoilParserValidation>
    : : : <member memberid="m1">Sarah</member>
    : : : <member memberid="m2">Bob</member>
    : : : <member memberid="m3" mom="m1" dad="m2">Joanne</member>
    : : : <member memberid="m4" mom="m1" dad="m2">Jim</member>
    : : : </family>
    : : : 4) The output
    : : : Finished with no errors!
    : : : As you can see, the DOMParser failed to validate the
    : : family.xml
    : : : file against the family dtd otherwise, it would have
    : reported
    : : a
    : : : validation error when it came across the
    : : : TagToFoilParserValidation.
    : : : Any insight as to what I'm doing wrong would be much
    : : appreciated.
    : : : Sincerely,
    : : : Keki
    : : : Project Iona
    : : : Manufacturing Applications
    : : : Oracle Corporation
    : : : The views and opinions expressed here are
    : : : my own and do not reflect the views and
    : : : opinions of Oracle Corporation
    1) No XSLT commands exist that allow you to embed a DTD while
    doing the transformation.
    2) You can use the setDocType() method in the parser, to set a
    DTD based on which the XML document will be validated. The
    parseDTD() method allows you to parse a DTD file separately and
    get a DTD object. Here is a sample code :
    DOMParser domparser = new DOMParser();
    domparser.setValidationMode(true);
    // parse the DTD file
    domparser.parseDTD(new FileReader(dtdfile));
    DTD dtd = domparser.getDocType();
    // Parse XML file - XML file will be validated based on the DTD.
    domparser.setDocType(dtd);
    domparser.parse(new FileReader(xmlfile));
    Document doc = domparser.getDocument();
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

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

  • XML document in CLOB with reference to external DTD

    If you place the xml document in clob using dbms_lob and the document has reference to external (system) DTD then it gives an error 'Error opening external DTD'. Whats the work around. See example below...
    declare
    xmlstring CLOB;
    xmlstring1 CLOB;
    os_file BFILE := bfilename('BFILE_DIR','family.xml');
    > > > rowsp INTEGER; > > > errnum NUMBER; > > > errmsg VARCHAR2(2000);
    > > > time VARCHAR2(20); > > > begin
    > > > select to_char(sysdate,'MM/DD/YYYY HH24:MI:SS')
    > > > into time from dual; > > > dbms_output.put_line(time);
    > > > dbms_lob.createtemporary(xmlstring, true, > > > dbms_lob.session);
    > > > dbms_lob.fileopen(os_file, > > dbms_lob.file_readonly);
    > > > dbms_lob.loadfromfile(xmlstring, os_file,
    > > > dbms_lob.getlength(os_file));
    > > > select to_char(sysdate,'MM/DD/YYYY HH24:MI:SS')
    > > > into time from dual; > > > dbms_output.put_line(time);
    > > > xmlgen.resetOptions; > > > xmlgen.setRowTag('family');
    > > > --xmlgen.setIgnoreTagCase(xmlgen.IGNORE_CASE);
    > > > rowsp := xmlgen.insertXML('family',xmlString);
    > > > dbms_output.put_line(' Rows processed = '&#0124; &#0124; > > > TO_CHAR(rowsp));
    > > > dbms_lob.freetemporary(xmlstring);
    > > > dbms_lob.fileclose(os_file); > > > commit; > > > exception
    > > > when no_data_found then > > > rollback;
    > > > dbms_lob.freetemporary(xmlstring);
    > > > dbms_lob.fileclose(os_file); > > > errnum := abs(SQLCODE);
    > > > errmsg := SQLERRM;
    > > > dbms_output.put_line(errnum&#0124; &#0124;'----'&#0124; &#0124;errmsg); > > > when others then
    > > > rollback; > > > dbms_lob.freetemporary(xmlstring);
    > > > dbms_lob.fileclose(os_file); > > > errnum := abs(SQLCODE);
    > > > errmsg := SQLERRM;
    > > > dbms_output.put_line(errnum&#0124; &#0124;'----'&#0124; &#0124;errmsg); > > > end;

    Can be one of two problems.
    One
    Your database user does not have
    privileges to open a socket inside
    the database. This will prevent
    the XML parser running inside the DB
    from retrieving the DTD which it must
    do to properly parse the document.
    Two
    you are sitting behind a corporate
    firewall and need to properly set
    the Proxy Server host and port to
    properly retrieve the DTD.
    From looking at your code it would appear
    that your job can more easily be done by
    using the OracleXML putXML command line
    utility outside the database.
    You can specify the -D options to your
    JavaVM to set the System properties for
    the proxy server if need be like this:
    java -DproxySet=true -DproxyHost=yourproxyserver OracleXML putXML

  • Validating an xml with DTD external DTD

    Hi
    how can i validate my XML File with an external DTD ?
    thanks for your replies
    serge

    Hi,
    when you use the XML Library, the interface <b>if_ixml_parser</b> has a static method <b>set_validation( )</b> to activate and deactivate a DTD validation.
    There are the follow constants in the if_ixml_parser for the DTD validation-mode:
    <b>if_ixml_parser=>co_no_validation</b>
    Do not validate the XML-Document against the document type definition (DTD)
    <b>if_ixml_parser=>co_validate</b>
    Validate the XML-Document against the document type definition (DTD)
    <b>if_ixml_parser=>co_validate_if_dtd</b>
    Validate the XML-Document against the document type definition (DTD) if a DTD is specified. Otherwise parse the Document in non validating mode.
    see also the SAP online-help:
    <a href="http://help.sap.com/saphelp_webas610/helpdata/de/bb/5766b2dca511d4990b00508b6b8b11/content.htm">Interface if_ixml_parser</a>
    Regards
    Stefan

  • ORA-20100: Error occurred while parsing:Error opening external DTD ( Asap)

    Hi I'm using domsample example. And I have written the program. The xml file at the starting has this string"<!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd">", from which I'm getting error -"ORA-20100: Error occurred while parsing: Error opening external DTD".
    I'm new to xml could you please help me to solve this problem. I assume this is related to DTD for which I need to set base path. But I'm not sure how to do it? I'm getting this xml file through CLOB which I'm able to parse until an extent. where in between got this error.
    Here is my partial code:
    l_doc_id := rec_xml_data.id;
    l_xml_parser := xmlparser.newParser;
    xmlparser.setValidationMode(l_xml_parser, FALSE);
    xmlparser.parseCLOB(l_xml_parser,rec_xml_data.l_xml_data);--PARSING THE CLOB WHICH CONTAINS XML FILE
    l_xml_doc := xmlparser.getDocument(l_xml_parser);
    xmlparser.freeParser(l_xml_parser);
    l_nodelist := xmldom.getElementsByTagName(l_xml_doc, '*');
    l_length := xmldom.getLength(l_nodelist);
    -- loop through elements
    FOR l_rec_xml in 0..l_length-1
    LOOP
    l_node := xmldom.item(l_nodelist, l_rec_xml);
    -- dbms_output.put(xmldom.getNodeName(n) || ' ');
    -- get the text node associated with the element node
    l_nodename:=xmldom.getNodeName(l_node);
    l_node := xmldom.getFirstChild(l_node);
    IF (xmldom.isNull(l_node) = false) THEN
    IF xmldom.getNodeType(l_node) = xmldom.TEXT_NODE THEN
    IF l_nodename = 'purchase-order-number' THEN
    l_po_num:=NULL;
    l_po_num:= xmldom.getNodeValue(l_node);
    -- dbms_output.put_line('Purchaser Order Num : '||l_po_num);
    END IF;
    from here onwards I get the string values
    Now I don't know where to set the DTD basepath or baseurl. I need it asap.
    Regards,
    Naveen.

    The version which I'm working on is 10.2.0.4.
    XML File---
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd">
    <MobileInventoryResponse>
    <message>
    <message-header>
    <message-id>16244182</message-id>
    <transaction-name>ship-advice</transaction-name>
    <partner-name>cbeyond</partner-name>
    <source-url>http://www.brightpoint.com</source-url>
    <create-timestamp>20080826150709</create-timestamp>
    <response-request>1</response-request>
    </message-header>
    <ship-advice>
    <header>
    <customer-id>297859</customer-id>
    <shipment-information>
    <ship-first-name>RA_13Aug_1</ship-first-name>
    <ship-last-name>MIND</ship-last-name>
    <ship-address1>test</ship-address1>
    <ship-city>test</ship-city>
    <ship-state>VA</ship-state>
    <ship-post-code>22102-4931</ship-post-code>
    <ship-country-code>US</ship-country-code>
    <ship-phone1>0040726335068</ship-phone1>
    <ship-email>[email protected]</ship-email>
    <ship-via>FX01</ship-via>
    <ship-request-date>20080826</ship-request-date>
    <ship-request-warehouse>CBY1</ship-request-warehouse>
    </shipment-information>
    <purchase-order-information>
    <purchase-order-number>380928</purchase-order-number>
    <account-description />
    <purchase-order-amount>0.0</purchase-order-amount>
    <currency-code>USD</currency-code>
    </purchase-order-information>
    <order-header>
    <customer-order-number>0002759</customer-order-number>
    <customer-order-date>20080826</customer-order-date>
    <order-sub-total>19.0</order-sub-total>
    <order-discount>0.0</order-discount>
    <order-tax1>0.0</order-tax1>
    <order-tax2>0.0</order-tax2>
    <order-tax3>0.0</order-tax3>
    <order-shipment-charge>18.0</order-shipment-charge>
    <order-total-net>0.0</order-total-net>
    <order-status>Completed</order-status>
    <order-type />
    <brightpoint-order-number>35028788</brightpoint-order-number>
    <warehouse-id>CBY1</warehouse-id>
    <ship-date>20080826</ship-date>
    </order-header>
    </header>
    <detail>
    <line-item>
    <line-no>1</line-no>
    <item-code>SKU1</item-code>
    <universal-product-code>0</universal-product-code>
    <ship-quantity>1.0</ship-quantity>
    <unit-of-measure>EA</unit-of-measure>
    <serial-list>
    <serial-numbers>
    <esn>TIMI000013</esn>
    </serial-numbers>
    </serial-list>
    <line-status />
    <base-price>0.0</base-price>
    <line-discount>0.0</line-discount>
    <line-tax1>0.0</line-tax1>
    <line-tax2>0.0</line-tax2>
    <line-tax3>0.0</line-tax3>
    <bill-of-lading>929406733828</bill-of-lading>
    <scac>FX01</scac>
    </line-item>
    </detail>
    </ship-advice>
    <transactionInfo>
    <eventID>16244182</eventID>
    </transactionInfo>
    </message>
    </MobileInventoryResponse>
    XML FILE END--------------------
    MY PROGRAM IS AS BELOW---
    get_eai_data_prc( x_ret_code OUT NUMBER
    ,p_debug_flag IN VARCHAR2
    IS
    --Local Variables
    l_xml_parser xmlparser.Parser;
    l_xml_doc xmldom.DOMDocument;
    l_xml_data CLOB;
    l_nodelist xmldom.DOMNodeList;
    l_length NUMBER := 0;
    l_num_cnt NUMBER := 0;
    l_node xmldom.DOMNode;
    l_docelem DBMS_XMLDOM.DOMElement; -- XML DOM element.
    l_nodeValue VARCHAR2(30); -- Text value of the node.
    l_nodename VARCHAR2(100);
    l_po_num VARCHAR2(150);
    l_account_desc VARCHAR2(150);
    l_cust_ord VARCHAR2(150);
    l_ship_date VARCHAR2(150);
    l_item_code VARCHAR2(150);
    l_ship_qty VARCHAR2(150);
    l_esn VARCHAR2(150);
    l_cust_channel_type VARCHAR2(150);
    l_cust_grp_acct VARCHAR2(150);
    l_max_doc_id NUMBER;
    l_doc_id NUMBER;
    l_market_id VARCHAR2(150);
    l_record_id VARCHAR2(30);
    TYPE l_esn_table IS TABLE OF VARCHAR2(30)
    INDEX BY BINARY_INTEGER;
    l_data l_esn_table;
    --CURSOR TO GET XML DATA FROM EAI
    CURSOR cur_xml_data(p_doc_id VARCHAR2)
    IS
    SELECT id
         ,document l_xml_data
    FROM tds_xml_store_temp
    WHERE id >= id ;
    BEGIN
    FOR rec_xml_data IN cur_xml_data(l_max_doc_id)
    LOOP
    l_doc_id := rec_xml_data.id;
    l_xml_parser := xmlparser.newParser;
    xmlparser.setValidationMode(l_xml_parser, FALSE);
    xmlparser.parseCLOB(l_xml_parser,rec_xml_data.l_xml_data);
    l_xml_doc := xmlparser.getDocument(l_xml_parser);
    xmlparser.freeParser(l_xml_parser);
    l_nodelist := xmldom.getElementsByTagName(l_xml_doc, '*');
    l_length := xmldom.getLength(l_nodelist);
    -- loop through elements
    FOR l_rec_xml in 0..l_length-1
    LOOP
    l_node := xmldom.item(l_nodelist, l_rec_xml);
    -- dbms_output.put(xmldom.getNodeName(n));
    -- get the text node associated with the element node
    l_nodename:=xmldom.getNodeName(l_node);
    l_node := xmldom.getFirstChild(l_node);
    IF (xmldom.isNull(l_node) = false) THEN
    IF xmldom.getNodeType(l_node) = xmldom.TEXT_NODE THEN
    IF l_nodename = 'purchase-order-number' THEN
    l_po_num:=NULL;
    l_po_num:= xmldom.getNodeValue(l_node);
    -- dbms_output.put_line('Purchaser Order Num : '||l_po_num);
    END IF;--purchase-order-number
    IF l_nodename = 'account-description' THEN
    l_account_desc :=NULL;
    l_account_desc := xmldom.getNodeValue(l_node);
    END IF;
    IF l_nodename = 'customer-channel-type' THEN
    l_cust_channel_type:=NULL;
    l_cust_channel_type:= xmldom.getNodeValue(l_node);
    END IF;
    IF l_nodename = 'customer-group-account' THEN
    l_cust_grp_acct := NULL;
    l_cust_grp_acct := xmldom.getNodeValue(l_node);
    END IF;
    IF l_nodename = 'customer-order-number' THEN
    l_cust_ord:=NULL;
    l_cust_ord:= xmldom.getNodeValue(l_node);
    -- dbms_output.put_line('Customer Order NUm : '||l_cust_ord);
    END IF;--customer-order-number
    IF l_nodename = 'ship-date' THEN
    l_ship_date:=NULL;
    l_ship_date:= xmldom.getNodeValue(l_node);
    -- dbms_output.put_line('Ship Date : '||to_date(l_ship_date,'YYYY-mm-dd'));
    END IF;--ship-date
    IF l_nodename = 'item-code' THEN
    l_item_code:=NULL;
    l_item_code:= xmldom.getNodeValue(l_node);
    -- dbms_output.put_line('Item Code : '||l_item_code);
    END IF;--item-code
    IF l_nodename = 'esn' THEN
    l_esn:=NULL;
    l_num_cnt := l_num_cnt + 1;
    l_esn:=xmldom.getNodeValue(l_node);
    l_data(l_num_cnt) := l_esn;
    -- dbms_output.put_line('Serial Num : '||l_esn);
    END IF;--esn
    IF l_nodename = 'market-id' THEN
    l_market_id := NULL;
    l_market_id := xmldom.getNodeValue(l_node);
    END IF;
    IF l_nodename = 'ship-quantity' THEN
    l_ship_qty:=NULL;
    l_ship_qty:= xmldom.getNodeValue(l_node);
    -- dbms_output.put_line('Ship Quantity : '||l_ship_qty);
    END IF;--ship-quantity
    END IF;--xmldom.TEXT_NODE
    END IF;
    END LOOP;--l_rec_xml
    FOR j in l_data.first..l_data.last
    LOOP
    INSERT INTO cbey_shipment_int_stg( purchase_order_number
    ,account_description
    ,customer_order_number
    ,ship_date
    ,item_code
    ,ship_quantity
    ,esn
    ,customer_channel_type
    ,customer_group_account
    ,market_id
    ,eai_xml_doc_id
    ,record_status
    ,record_id
    VALUES
    ( l_po_num
    ,l_account_desc
    ,l_cust_ord
    ,to_date(l_ship_date,'YYYY-mm-dd')
    ,l_item_code
    ,l_ship_qty
    ,l_data(j)
    ,l_cust_channel_type
    ,l_cust_grp_acct
    ,l_market_id
    ,l_max_doc_id
    ,'NEW'
    ,CBEY_RECORD_ID_SEQ_S.nextval
    END LOOP;--j
    UPDATE cbey_interface_run_log
    SET request_id = l_conc_req_id
    ,lastrun_date = SYSDATE
    ,doc_id = rec_xml_data.id
    WHERE program_id = 'SHIPMENT_INT'
    AND doc_id =l_max_doc_id;
    l_data.delete;
    l_num_cnt :=0;
    END LOOP; --rec_xml_data
    COMMIT;
    END of the Procedure--------------------------
    Now if I load the xml file without the this :- <!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd">
    it works well. But it gives error when this particular thing is there.
    Regards,
    Naveen
    Edited by: MAN on Oct 17, 2008 7:28 AM

  • ORA-31020 when using XML with external DTD or entities

    I'd like to parse XML documents against a modular DTD that references other DTDs. This works fine with Oracle 9i. But after upgrading to 11g, the parsing of XML-instances fails and DBMS_XMLPARSER.parseClob produces ORA-31020.
    The same error occurs even if I simply try to store XML with a reference to an external DTD as xmltype:
    SQL> select xmltype('<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE ewl-artikel SYSTEM "http://www.foo.com/example.dtd"><test>123</test>') from dual;
    ERROR:
    ORA-31020: Der Vorgang ist nicht zulässig, Ursache: For security reasons, ftp
    and http access over XDB repository is not allowed on server side
    ORA-06512: in "SYS.XMLTYPE", Zeile 310
    ORA-06512: in Zeile 1
    How can I use external DTDs on remote servers in order to parse XML in an 11g database??? Any ideas for a workaround? Thanks in advance!

    This is my PL/SQL validation procedure:
    procedure validatexml (v_id in number default 0) is
    PARSER DBMS_XMLPARSER.parser;
    DTD_SOURCE clob;
    DTD_DOCUMENT xmldom.DOMDocumentType;
    XML_INSTANCE xmltype;
    BEGIN
    -- load DTD from XDB repository
    SELECT httpuritype('http://example.foo.de/app1/DTD1.dtd').getclob() into DTD_SOURCE from dual;
    -- load XML instance
    select co_xml into XML_INSTANCE from tb_xmltab where co_id=v_id;
    -- parse XML instance
    PARSER := DBMS_XMLPARSER.newParser;
    xmlparser.setValidationMode( PARSER , false);
    xmlparser.parseDTDClob( PARSER , DTD_SOURCE , 'myfirstnode' );
    DTD_DOCUMENT := xmlparser.getDoctype( PARSER );
    xmlparser.setValidationMode( PARSER , true );
    xmlparser.setDoctype( PARSER , DTD_DOCUMENT );
    DBMS_XMLPARSER.parseClob( PARSER , v_xml );
    DBMS_XMLPARSER.freeParser(PARSER);
    htp.print('<P>XML instance succesfully validated!<P>');
    end validatexml;

  • Use external DTD in 11g

    Hi,
    I try to parse an XML file within a CLOB column. In Oracle 9i and 10g the code work, but in 11 I get a lot of errors.
    First I got
    ORA-31020: Der Vorgang ist nicht zulässig, Ursache: For security reasons, ftp and http access over XDB repository is not allowed on server side (-31020)
    The XML file contains a reference to an external DTD, which is accessible per HTTP on a remote webserver.
    As I have understood, I have to register all my DTDs within the Oracle Database. I found
    dbms_xmlschema.registerURI()
    to do the job. This is very unpractical, because there are a lot of DTDs, which can be referenced by the XML-CLOBs. So I have to register all the DTDs manually.
    Normally the XML generator adds the matching DTD reference and so I can validate the XML with the parser without any knowledge about the type of the DTD.
    To figure out the problem I read a lot of documents on severyl websites. I have tried
    select HTTPURITYPE('http://mywebserver.domain/schema/mydtd-v1.0.dtd').getCLob() from dual;
    to load the DTD content. Surprise, surprise I got a lot of ACL errors. To solve that, I have added some network acls. At the moment the statement above
    returns my DTD within a CLOB now, so it seems, that I can load the external file from the remote webserver.
    Back to registerURI():
    dbms_xmlschema.registerURI(
          schemaURL => 'http://mywebserver.domain/schema/mydtd-v1.0.dtd',
          schemaDocUri => 'http://mywebserver.domain/schema/mydtd-v1.0.dtd',
          local => false);
    returns now (error messages in German)
    ORA-31011: XML-Parsing nicht erfolgreich
    ORA-19202: Fehler bei XML-Verarbeitung
    LPX-00247: Ungültige Dokument-Typ-Deklaration (DTD)
    Error at line 5
    aufgetreten
    ORA-06512: in "XDB.DBMS_XMLSCHEMA_INT", Zeile 20
    ORA-06512: in "XDB.DBMS_XMLSCHEMA", Zeile 199
    ORA-06512: in Zeile 12
    The same error occurs on
    dbms_xmlschema.registerschema(
          schemaURL => 'http://mywebserver.domain/schema/mydtd-v1.0.dtd',
          schemaDoc => HTTPURITYPE('http://mywebserver.domain/schema/mydtd-v1.0.dtd').getCLob()
    How I can get more information about the underlying error? I have tried to enable tracing for some XDB events, but in the udump directory
    exist only old files. I think, the DTD is correct, also the reference within the XML CLOB (because it works on the old database instances).
    It seems to be a security or character-set(?) issue.
    Any ideas?
    Thanks a lot
    Andre

    As I have understood, I have to register all my DTDs within the Oracle Database.
    Not exactly.
    DBMS_XMLSchema procedures deal with XML schemas, not DTDs.
    You can have Oracle resolve the DTD by loading it into the XML DB repository at the same uri referenced by the XML file.
    Or, if you don't actually need to use those DTDs to validate XML documents, you can also disable DTD validation altogether at session or instance level.

  • "Error while parsing SOAP XML payload: no element found" received when invoking Web Service

    Running PB 12.1 Build 7000.  Using Easysoap.  Error ""Error while parsing SOAP XML payload: no element found" received when invoking Web Service".  This error does not appear to be coming from the application code.  Noticed that there were some erroneous characters showing up within the header portion of the XML ("&Quot;").  Not sure where these are coming from.  When I do a find within the PB code for ""&quot;" it gets located within two objects, whereas they both reference a "temp_xml_letter".  Not sure where or what temp_xml_letter resides???   The developer of this is no longer with us and my exposure to WSDL and Web Services is rather limited.  Need to get this resolved...please.
    This is the result of the search.  Notice the extraneous characters ("&quot;"):
    dar1main.pbl(d_as400_mq_xml)
    darlettr.pbl(d_email_xml)
    ---------- Search: Searching Target darwin for 'temp_xml'    (9:52:41 AM)
    ---------- 2 Matches Found On "temp_xml":
    dar1main.pbl(d_as400_mq_xml).d_as400_mq_xml:  export.xml(usetemplate="temp_xml_letter" headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0  template=(comment="" encoding="UTF-8" name="temp_xml_letter" xml="<?xml version=~"1.0~" encoding=~"UTF-16LE~" standalone=~"yes~"?><EmailServiceTransaction xmlns=~"http://xml.xxnamespace.com/Utility/Email/EmailService" ~" xmlns:imc=~"http://xml.xxnamespace.com/IMC~" xmlns:xsi=~"http://www.w3.org/2001/XMLSchema-instance~" xmlns:root=~"http://xml.xxnamespace.com/RootTypes~" xmlns:email=~"http://xml.xxnamespace.com/Utility/Email~" xsi:schemaLocation=~"http://xml.xxnamespace.com/Utility/Email/EmailService http://dev.xxnamespace.com/Utility/Email/EmailService/V10-TRX-EmailService.xsd~"><EmailServiceInformation><EmailServiceDetail __pbband=~"detail~"><ApplicationIdentifier> applicationidentifier </ApplicationIdentifier><AddresseeInformation><AddresseeDetail><Number> number </Number></AddresseeDetail></AddresseeInformation><EmailMessageInformation><Ema
    darlettr.pbl(d_email_xml).d_email_xml:  export.xml(usetemplate="temp_xml_letter" headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0  template=(comment="" encoding="UTF-8" name="temp_xml_letter" xml="<?xml version=~"1.0~" encoding=~"UTF-16LE~" standalone=~"yes~"?><EmailServiceTransaction xmlns=~"http://xml.xxnamespace.com/Utility/Email/EmailService" ~" xmlns:imc=~"http://xml.xxnamespace.com/IMC~" xmlns:xsi=~"http://www.w3.org/2001/XMLSchema-instance~" xmlns:root=~"http://xml.xxnamespace.com/RootTypes~" xmlns:email=~"http://xml.xxnamespace.com/Utility/Email~" xsi:schemaLocation=~"http://xml.xxnamespace.com/Utility/Email/EmailService http://dev.xxnamespace.com/Utility/Email/EmailService/V10-TRX-EmailService.xsd~"><EmailServiceInformation><EmailServiceDetail __pbband=~"detail~"><ApplicationIdentifier> applicationidentifier </ApplicationIdentifier><AddresseeInformation><AddresseeDetail><Number> imcnumber </Number></AddresseeDetail></AddresseeInformation><EmailMessageInformation><Ema
    ---------- Done 2 Matches Found On "temp_xml":
    ---------- Finished Searching Target darwin for 'temp_xml'    (9:52:41 AM)

    Maybe "extraneous" is an incorrect term.  Apparantly, based upon the writeup within Wiki, the parser I am using does not interpret the "&quot;"?  How do I find which parser is being utilized and how to control it?
    <<<
    If the document is read by an XML parser that does not or cannot read external entities, then only the five built-in XML character entities (see above) can safely be used, although other entities may be used if they are declared in the internal DTD subset.
    If the document is read by an XML parser that does read external entities, then the five built-in XML character entities can safely be used. The other 248 HTML character entities can be used as long as the XHTML DTD is accessible to the parser at the time the document is read. Other entities may also be used if they are declared in the internal DTD subset.
    >>>

Maybe you are looking for

  • SAP: SystemCommand=N*TACODE. Is there a Way to export to Excel directly?

    Hi! Im Using a SAP-Desktop-Link to login automatically, start a transaction, passing values to dynpro fields. That works Fine. The mylink.sap opened in an texteditor looks like this: SystemCommand=N*FBL3N -dynprofield1=foo;-dynprofield2=bar is there

  • Espn web site rendered in a linear fashion

    The ESPN Mlb site is not rendered as it should. I have the problem in both normal and safe mode. For safe mode, I have copied the error console's error messages that are relevant to this in the troubleshooting buffer.

  • Go_Block problem

    hi to all using form6i and run in client server: i have a button and trigger when button pressed. go_block('a'); go_Block('b'); the problem is when i click the button only one block appear. my canvas type is stacked and i changed the width and height

  • "Print & Fax" preference pane is GONE!!!

    I have been having trouble printing to my USB connected printer on my Imac from my G4 powerbook. In looking into the problem, I have noticed that the "print & fax" preference pane in System Preferences is missing on both computers. I have a strange f

  • How to spool oracle data faster

    Hi, I'm retrieving data from oracle database. There are around more than 308501 rows in every file which I'm retiring which is taking around 10hrs to retrieve all these rows. Is there is any way so that i can minimize the data retrieval time. appreci