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

Similar Messages

  • Can't convert stack XML file using report RPT_MOPZ_COPY_STACK for upgrade

    Hello Colleagues/ SAP Experts,
    Here is a background. 2 weeks ago, we have generated an XML stack file using MOPZ in solman 7.1 for the following systems (P6D which is DEV,
    P6Q which is quality, P6R which is regression and P1P which is production). We were at our technical cutover rehearsal phase and the system that we were rehearsing was P6R. But AFTER our technical cutover, a new java component, which is seeburger as2 adapter, was installed in P1P, PRODUCTION. Thus, the landscape  of P1P has changed as a new component was introduced and we believe that the generated XML file 2 weeks ago will no longer be valid for P1P. Instead of generating another xml file thru mopz for P1P, we would like to use report RPT_MOPZ_COPY_STACK_XML to convert the XML file OF P6R to map it toP1P.  I have uploaded P6R XML and the target is P1P. So as you can see, P6R XML (source) --> P1P target.
    Actions already done are the following:
    1) Fulfilled and followed the resolution in note: 1711612
    RPT_MOPZ_COPY_STACK_XML Report Troubleshooting
    2) SAP-OSS is working in SM59
    Basically, program RPT_MOPZ_COPY_STACK does not convert the Regression system's xml to the target, which is production. Kindly see attached screenshot. *the screenshot shows only 1 component in error but upon clicking the 'next difference' button, it will still show other components. I have checked my lmdb settings, will there be workaround for the issue?
    Regards,
    Meinard

    Hello Divyanshu Srivastava / Reagan Benjamin ,
    Thank you  for your replies. Yes I noticed that a new higher patch for one java component was already present when I have regenerated recently for production using mopz. Anyways, SAP has returned a message wherein they edited the xml file themselves. Most of errors were eliminated only error was kernel versions was not matched. We need to upgrade kernel of our production and test if it works. Hopefully it will. Thanks though at first we did not edit the xml as according to one sap note I read it will not be supported by SAP. Closing this thread now

  • Validate a XML file against multiple schema files

    Hello everybody!
    How can I validate a XML file against multiple schema files?
    I have the following XML file:
    <?xml version="1.0" encoding="UTF-8"?>
    <bulkCmConfigDataFile xmlns:es="SpecificAttributes.3.0.xsd"
                             xmlns:xn="genericNrm.xsd"
    xmlns="configData.xsd">
    <fileHeader fileFormatVersion="32.615 V4.2" vendorName=""/>
    <configData dnPrefix="Undefined">
    <xn:SubNetwork id="3G">
    <xn:SubNetwork id="RNC01">
    <xn:MeContext id="RNC01">
    <xn:VsDataContainer id="RNC01">
    <xn:attributes>
    <xn:vsDataType>vsDataMeContext</xn:vsDataType>
    <xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
    <es:vsDataMeContext>
    <es:userLabel>RNC01</es:userLabel>
    <es:ipAddress>172.21.3.17</es:ipAddress>
    <es:neMIMversion>vF.5.0</es:neMIMversion>
    </es:vsDataMeContext>
                                  </xn:attributes>
    </xn:VsDataContainer>
    </xn:MeContext>
    </xn:SubNetwork>
    </xn:SubNetwork>
    </configData>
    <fileFooter dateTime="2006-11-24T11:56:07Z"/>
    </bulkCmConfigDataFile>
    I want to load this file into a table, validate it (against SpecificAttributes.3.0.xsd, genericNrm.xsd and configData.xsd) and query that table. How would the INSERT .. and the SELECT ... for userLabel attribute look like?
    Many thanks!

    Hi Peter,
    Please use the validateXML BPEL Property : This property validates incoming and outgoing XML documents. If set to true, the Oracle BPEL Process Manager applies schema validation for incoming and outgoing XML documents. This property is applicable to both durable and transient processes. The default value is false.
    Cheers
    A

  • How can i write a XML file with oracle data ?

    How can i write a XML file using PL/SQL.
    Can i do as follows.
    1.Open a file using UTL_FILE.FOPEN(LC_DIR_LOC,'abc.xml','W')     ;
    2.write all the required tag and value using UTL.put_line
    that is enough. Is not, please guide me to write.
    gk

    Having Oracle 9i.
    One more doubt. In the speck, some constand values are there, When i write the same into file, How can i write ?.
    1. l_str := ' "E27" '
    or
    2. l_str := ' E27 '
    UTL_FILE.PUT_LINE(L_FILE_POI,l_str,TRUE);          
    1 case : in XML file : "E27"
    In 2 case : E27
    When we write a XML file through editors , we have to define the constant within quote . is it?      
    Which one can i use ? Or any other way is there ..
    Thanks and Regards
    gopi

  • How to use Xerces to validate an XML file against a DTD

    Hi, can anybody tell me how to use Xerces to validate an XML file against a DTD. its urgent. post some sample code. it would be helpful for my project. isupposed to use SAX parser(Xerces)
    Thanx in advance

    Come on, I googled "xerces validate" and the first link is the Xerces FAQ:
    http://xerces.apache.org/xerces-j/faq-general.html
    And of course "how to validate" is a Xerces FAQ. Help yourself by doing a little research instead of waiting for other people.

  • How can we get  tag of XML file using SAX

    Hi ,
    I'm parsing one SAX parser , I'have almost done this parsing. i have faced problem for one case, i'e how can we get tag from XML file using SAX parser?
    XML file is
    <DFProperties>
    <AccessType>
    <Get/>
    </AccessType> <Description>
    gdhhd
    </Description>
    <DFFormat>
    <chr/>
    </DFFormat>
    <Scope>
    <Permanent/>
    </Scope>
    <DFTitle>gsgd</DFTitle>
    <DFType>
    <MIME>text/plain</MIME>
    </DFType>
    </DFProperties>
    I want out like GET and Permanent... means this one tag which is present inside of another tag.
    Handler class like
    public void startElement(String namespaceURI, String localName,
                   String qName, Attributes atts) throws SAXException {
    if(_ACCESSTYPE.equals(localName)){
                   accessTypeElement=ACCESSTYPE;
    public void characters(char[] ch, int start, int length)
                   throws SAXException {
    if (_ACCESSTYPE.equals(_accessTypeElement)) {
                   String strValue = new String(ch, start, length);
                   System.out.println("Accestype-----------------------------> " + strValue);
                   //System.out.println(" " + strValue);
    public void endElement(String namespaceURI, String localName, String qName)
                   throws SAXException {
    if (_ACCESSTYPE.equals(localName)) {
                   _accessTypeElement = "";
    . please any body help me

    Hi ,
    I have one problem,Please help me.
    1. How can I'll identify where exactly my Node is ended,means how how can we find corresponding nodename? in partcular place
    <Node> .............starttag1
    <NodeName>Test</NodeName>
    <Node>................starttag2
    <nodeName>test1</NodeName>
    </Node>..................endtag2
    <Node>.....................starttag3
    <NodeName><NodeName>
    <Node> .........................starttag4
    <NodeName>test4</NodeName>
    </Node>.......enddtag4
    </Node>...........end tag3
    </Node>............endtag1
    my code is below
    private final String _NODENAME = "NodeName";
    private final String _NODE = "Node";
    private String _nodeElement = "";
         private String _NodeNameElement = "";
    public void startElement(String namespaceURI, String localName,
                   String qName, Attributes atts) throws SAXException {
    if (_NODENAME.equals(localName)) {
                   NodeNameElement = NODENAME;
    if(_NODE.equals(localName)){
         System.out.println("start");
         if (_NODENAME.equals(localName)) {
                   NodeNameElement = NODENAME;
    public void characters(char[] ch, int start, int length)
                   throws SAXException {
    if (_NODENAME.equals(_NodeNameElement)) {
                   String strValue = new String(ch, start, length);
                   String sttt=strValue;
                   System.out.println("NODENAME: ************* " + strValue);
    if(_NODE.equals(_nodeElement)){
                   if (_NODENAME.equals(_NodeNameElement)) {
                        String strValue = new String(ch, start, length);
                        String sttt=strValue;
                        System.out.println("nodevalue********** " + strValue);
    public void endElement(String namespaceURI, String localName, String qName)
                   throws SAXException {
    if (_NODENAME.equals(localName)) {
                   _NodeNameElement = "";
    if(_NODE.equals(localName)){
                   System.out.println("NODENAME: %%%%%%%%%");
    please help me. How can I figure node ending for particular nodename

  • Where can I find an example of a vi which reads a xml file using the Labview schema (LVXMLSchema.xsd)?

    Where can I find an example of a vi which reads a xml file using the Labview schema (LVXMLSchema.xsd)?
    �Unflatten From XML� is of little use in parsing because it requires the data type. So it seems that the user has to parse each data value, and then �Unflatten From XML� can help a little.
    I would like to see NI provide a VI for parsing it�s own schema.

    LabVIEW's XML functions are another way of saving data from controls and indicators that is in a more standardized format. If you look at the Unflatten From XML shipping example, it shows taking the data that you would normally send to a Digital Wveform Graph and converting it to XML instead. This data is then unflattend from XML and wired to the graph. Since you know what you wrote to the file, this is an easy thing to do. If what you are looking for is a way to look at any data in any LabVIEW XML file, then you are right, there is not a VI for that. However, I do not believe that that was the intention of the XML functions in the first place.
    By wiriting data in XML, this allows other applications outside of LabVIEW to parse and recognize the dat
    a. In LabVIEW, you would already know the types and can place a generic item of that type. The issue of knowing the type is that you need to know the type of the wire that comes out of the Unflatten function so that the VI will compile correctly. You could always choose a variant value to unflatten and then do some parsing to take the variant a part. Maybe this will help you out.
    See this example for using the Microsoft parser for XML. (http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B123AE0CB9FE111EE034080020E74861&p_node=DZ52050&p_submitted=N&p_rank=&p_answer=)
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • How can we validate a XML against his external schema XSD

    Hi;
    I use the XML library for create my XML file, I’m extracting the data
    from R3 and building the XML document.
    I wish to validate this document against his schema XSD built by third party (government organization) before i transfer this data (xml file)
    to the external entity.
    In my abap program:
    ¿How can i reach this validation level and if any
    error exists then how can i get or trap the detail information?
    this is a sample file XML with the external schema reference, as you can see in this part of the code.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <Comprobante xmlns="http://www.sat.gob.mx/cfd/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/2 http://www.sat.gob.mx/sitio_internet/cfd/2/cfdv2.xsd" version="2.0" serie="A" folio="0000238" fecha="2006-09-01T19:32:03-05:00" sello="o4kAzhytaTKThSk9tbTQGg5OGacAltWZwxQPZuMg1XhfjMq5jJ0GyO7w2//bf8aTuHnbqwpkR7rIgIehGLy88Xb3Ck0EDsWZEAC1QUuqRq2iWKAnGQPS4l9s0QrJHt0Ziojjd0GQFek6BYXPdlmdTjLZ2x+J8ffYEGpIQZRB8=" noAprobacion="2755" anoAprobacion="2006" formaDePago="En una sola exhibicion" noCertificado="00001000000000806462" condicionesDePago="Neto a 30 días sin DPPP" subTotal="2531.99" descuento="0.00" total="2912.90" tipoDeComprobante="ingreso">
      <DomicilioFiscal calle="AVE. UNIVERSIDAD" noExterior="992 NTE." colonia="COL. CUAUHTEMOC" municipio="SAN NICOLAS DE LOS GARZA" estado="N.L." pais="MEXICO
    We are using SAP R/3 46C
    Thanks in Advance for your help.
    Alejandro Pérez

    Hi, Alejandro
    Did you found something on SAP side in order to generated this XML.
    Currently I´m trying to find out some on SAP but nothing at this moment.
    The company that I´m working needs to implement "Factura Electonica" also.
    Probably we will use external broker to do this for us, and we will send just Idoc to the broker.
    Please, let me know your progress on SAP side.
    Regards, Fabio

  • How to read the attribute of the xml file using jaxb

    Thanks,
    Buddy as i have a issue i have to read the xml file using jaxb and xml file contains this data and i have read the attribute like name , desc and action for a particular menu name pls tell the code how to do this it will be a great favour to me
    thanx in advance
    Rasool
    <contextmenu>
    <menu name='Lead' >
    <menuitem name='newlead' desc='New Lead' action='/leads.do?dispatch=insert' />
    <menuitem name='editlead' desc='Edit Lead' action='' />
    <menuitem name='leadinfo' desc='Lead Information' action='' />
    </menu>
    <menu name='Cases' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    <menu name='Contact' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    </contextmenu>

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • Manipulating  XML file using flex 2.0

    Hi,
    how to add contents in to xml file using flex 2.0, ie i
    actually wants to write data in to a xml file, so that data to be
    appended at the end of the file.
    Kumar

    You can't! Well, at least Flex cannot do this. All Flex can
    do is send this data -- any data -- to the server and it's up to
    you how you want to append this data to a file on the server.
    You see, flex can't write to local files. If you looking for
    client side file manipulation, take a look at Flex's desktop
    brother call AIR!
    ATTA

  • Creating XML file Using Call Transformation

    Hello Friends,
          I have searched before posting thread, couldnt find anything.
          I am creating an XML file using Call Transformation. My internal table has 3 date fields and some other fields.  For some records I dont have values for the date fields. In that case my XML file is giving the date value as 0000-00-00 since I declared it as Date type.  This value 0000-00-00  is not accepted by the middle ware as the valid date.  I can not change it as String type as per the suggestion.
    In that case I am advised to skip printing the date field tag if it doesnt have value.
         Is there any way to skip the date field if it is empty. Any Suggestions please ?.
    Thanks
    Lakshmi.

    Hi,
    I had exactly the same problem before. When you call a transformation there is an option called initial_components. According to SAP if you use initial_components = 'SUPRESS' the empty fields should not being generated on the XML.
    Now, this didn't work for me and I have seen some people with the same problem. Here is how I solved this (maybe not the best way but it worked):
    First: My fields are all CHAR in my table
    Second: In the transformation, you can use conditional transformation to not display a tag if field is empty, here a piece of my transformation (I am using simple transformations):
       <tt:root name="ROOT"/>
         <tt:cond s-check="not-initial(ref('ROOT.L1_NM')) or not-initial(ref('ROOT.L2_NM'))">
              <TRNMTR_NM>
                <tt:cond s-check="not-initial(ref('ROOT.L1_NM'))">
                  <l1_nm>
                    <tt:value ref="ROOT.L1_NM"/>
                  </l1_nm>
                </tt:cond>
                <tt:cond s-check="not-initial(ref('ROOT.L2_NM'))">
                  <l2_nm>
                    <tt:value ref="ROOT.L2_NM"/>
                  </l2_nm>
                </tt:cond>
              </TRNMTR_NM>
            </tt:cond>
    As you can see, I first check if the fields have values.
    Hope it helps
    Edited by: carlosrv on Oct 4, 2011 8:22 PM

  • Creating XML File Using xmldom Package

    How can I create an XML file from scratch using the PL/SQL xmldom package?
    I want to create an XML file using the xmldom package instead of building the individual tags as strings of VARCHAR2 character data. There is quite a bit of documentation regarding manipulating input XML files using DOM -- but not for creating XML files from scratch given known "tagnames" (<lastName>) and retrieved database "values" ("Smith").
    <person>
    <lastName>Smith</lastName>
    </person>
    Is there any documentation that you can recommend?
    Thank you.

    Here is an example.
    The create_file procedure creates the file.
    The other procedures are generic procs that can be used with any XML.
    PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
    pi_root_tag IN VARCHAR2,
                                            po_root_element OUT xmldom.domelement,
                                            po_root_node OUT xmldom.domnode,
                                            pi_doctype_url IN VARCHAR2) IS
    xmldoc xmldom.DOMDocument;
    root xmldom.domnode;
    root_node xmldom.domnode;
    root_element xmldom.domelement;
    record_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
    -- Create the root --
    root := xmldom.makeNode(xmldoc);
    -- Create the root element in the file --
    create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
    po_xmldoc := xmldoc;
    po_root_node := root_node;
    po_root_element := root_element;
    END create_file_with_root;
    PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
    pi_element_name IN VARCHAR2,
                                            pi_parent_node IN xmldom.domnode,
                                            po_new_element OUT xmldom.domelement,
                                            po_new_node OUT xmldom.domnode) IS
    element xmldom.domelement;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    element := xmldom.createElement(pi_xmldoc, pi_element_name);
    child_node := xmldom.makeNode(element);
    -- Append the new node to the parent --
    newelenode := xmldom.appendchild(pi_parent_node, child_node);
    po_new_node := child_node;
    po_new_element := element;
    END create_element_and_append;
    FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
    pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
    parent_node xmldom.domnode;                                   
    child_node xmldom.domnode;
    child_element xmldom.domelement;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
    parent_node := child_node;
    -- Create a text node --
    textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
    child_node := xmldom.makeNode(textele);
    -- Link the text node to the new node --
    compnode := xmldom.appendChild(parent_node, child_node);
    RETURN newelenode;
    END create_text_element;
    PROCEDURE create_file IS
    xmldoc xmldom.DOMDocument;
    root_node xmldom.domnode;
    xml_doctype xmldom.DOMDocumentType;
    root_element xmldom.domelement;
    record_element xmldom.domelement;
    record_node xmldom.domnode;
    parent_node xmldom.domnode;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
    xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
    parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
    parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
    -- write the newly created dom document into the buffer assuming it is less than 32K
    xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
    EXCEPTION
    WHEN xmldom.INDEX_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
    WHEN xmldom.DOMSTRING_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'String Size error');
    WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
    WHEN xmldom.WRONG_DOCUMENT_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
    WHEN xmldom.INVALID_CHARACTER_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
    WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
    WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
    WHEN xmldom.NOT_FOUND_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not found error');
    WHEN xmldom.NOT_SUPPORTED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
    WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
    WHEN OTHERS THEN
    dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
    END create_file;

  • Creating XML file using data from database table

    I have to create an xml file using the data from multiple table. The problem That i am facing is the data is huge it is in millions so I was wondering that is there any efective way of creating such an xml file.
    It would be great if you can suggest some approach to achieve my requirement.
    Thanks,
    -Vinod

    An example from the forum: Re: How to generate xml file from database table
    Edited by: Marco Gralike on Oct 18, 2012 9:41 PM

  • Generation of XML file using DMEE format tree

    Hi Experts,
                     Can you please provide all the steps to generate a XML file using a DMEE format tree.
    Thanks in adavance!!!
    Regards,
    Vishal.

    Hi,
    you can do it exaclty the same way like creating ordinary flat file.
    You can find also some examples made by SAP. Search format tree with this pattern: XML

Maybe you are looking for