XML document creation using reflection

Hi all,
I'm tyring to write a class which creates an XML document from objects passed in. For example, you call the add(Object) method and it takes your object, uses reflection, then outputs XML like this...
<fieldName>fieldValue<fieldName>
The only problem is that after looking through this forum I am a little concerned about the performance of my proposed solution (using reflection).
The class will be used in a batch process which processes millions of objects (to generate a whopping XML file that'll be sent on for further processing by a third party).
Is there a better way to do this than by using reflection?
This class is going to be used by multiple batch processes hence there will be lots of different object types passed (they'll also be new ones in the future that we don't even know about yet) hence my reflection choice.
Thanks,
Chris

The only problem is that after looking through this
forum I am a little concerned about the performance of
my proposed solution (using reflection).The only way that you'll know for sure is if you try it out. Write the code, test it, then run it in a profiler to find out where the performance problems (if any) are.
Is there a better way to do this than by using
reflection?Probably not, if you want to pass any arbitrary object to it.
One possible alternative is to have "XML aware" objects: define an interface WritesXML, that defines a method toXML(). You then check to see whether the given object implements this interface, and if it does you simply call the method, otherwise you use reflection.
Another alternative, assuming that your objects follow the Bean pattern, is to create "XML-ifiers" on the fly, similar to the way an app-server handles JSPs. First time you see an object you create a class that will write it to XML, then compile this class and invoke it for all subsequent objects. This will require that you have a JDK installed on the runtime machine, that the objects follow the Bean pattern, and that the number of instances of a given class are very high.
This class is going to be used by multiple batch
processes hence there will be lots of different object
types passed (they'll also be new ones in the future
that we don't even know about yet) hence my reflection
choice.Sounds like a good reason to use reflection.

Similar Messages

  • Xml document validation using Schema

    I want to validate XML Document using XML Schema...
    does any body have an idea how to do it.
    Every time i m running my java file by using different XML FILE AND XSD FILE in command line i m getting same error.
    error is:
    Exception in thread "main" org.xml.sax.SAXException: Error: URI=null Line=2: s4s-elt-schema-ns: The namespace of element 'catalog' must be from the schema name space.
    at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1115)
    at SAXLocalNameCount.main(SAXLocalNameCount.java:117)
    Below is my java code with xml file and schema file.
    plz get back to me as soon as possible it is urgent.
    thanx
    java File
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import java.util.*;
    import java.io.*;
    public class SAXLocalNameCount extends DefaultHandler {
    /** Constants used for JAXP 1.2 */
    static final String JAXP_SCHEMA_LANGUAGE =
    "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    static final String W3C_XML_SCHEMA =
    "http://www.w3.org/2001/XMLSchema";
    static final String JAXP_SCHEMA_SOURCE =
    "http://java.sun.com/xml/jaxp/properties/schemaSource";
    /** A Hashtable with tag names as keys and Integers as values */
    private Hashtable tags;
    // Parser calls this once at the beginning of a document
    public void startDocument() throws SAXException {
    tags = new Hashtable();
    // Parser calls this for each element in a document
    public void startElement(String namespaceURI, String localName,
    String qName, Attributes atts)
         throws SAXException
    String key = localName;
    Object value = tags.get(key);
    if (value == null) {
    // Add a new entry
    tags.put(key, new Integer(1));
    } else {
    // Get the current count and increment it
    int count = ((Integer)value).intValue();
    count++;
    tags.put(key, new Integer(count));
    System.out.println("TOTAL NUMBER OF TAG IN FILE = "+count);
    // Parser calls this once after parsing a document
    public void endDocument() throws SAXException {
    Enumeration e = tags.keys();
    while (e.hasMoreElements()) {
    String tag = (String)e.nextElement();
    int count = ((Integer)tags.get(tag)).intValue();
    System.out.println("Local Name \"" + tag + "\" occurs " + count
    + " times");
    static public void main(String[] args) throws Exception {
    String filename = null;
    String schemaSource = null;
    // Parse arguments
    schemaSource = args[0];
    filename = args[1];
    // Create a JAXP SAXParserFactory and configure it
    SAXParserFactory spf = SAXParserFactory.newInstance();
    // Set namespaceAware to true to get a parser that corresponds to
    // the default SAX2 namespace feature setting. This is necessary
    // because the default value from JAXP 1.0 was defined to be false.
    //spf.setNamespaceAware(true);
    // Validation part 1: set whether validation is on
    spf.setValidating(true);
    // Create a JAXP SAXParser
    SAXParser saxParser = spf.newSAXParser();
    System.out.println(" saxparser "+saxParser);
    // Validation part 2a: set the schema language if necessary
    if (true) {
    try {
    saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
    System.out.println(" saxparser ");
    } catch (SAXNotRecognizedException x) {
    // This can happen if the parser does not support JAXP 1.2
    System.err.println(
    "Error: JAXP SAXParser property not recognized: "
    + JAXP_SCHEMA_LANGUAGE);
    System.err.println(
    "Check to see if parser conforms to JAXP 1.2 spec.");
    System.exit(1);
    // Validation part 2b: Set the schema source, if any. See the JAXP
    // 1.2 maintenance update specification for more complex usages of
    // this feature.
    if (schemaSource != null) {
    saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File(schemaSource));
    System.out.println(" saxparser 123");
    // Get the encapsulated SAX XMLReader
    XMLReader xmlReader = saxParser.getXMLReader();
    System.out.println(" XML READER "+xmlReader);
    // Set the ContentHandler of the XMLReader
    xmlReader.setContentHandler(new SAXLocalNameCount());
    System.out.println(" XML READER 345 ");
    // Set an ErrorHandler before parsing
    xmlReader.setErrorHandler(new MyErrorHandler(System.err));
    System.out.println(" XML READER 67878 ");
    // Tell the XMLReader to parse the XML document
    xmlReader.parse(filename);
    System.out.println(" XML READER ");
    // Error handler to report errors and warnings
    private static class MyErrorHandler implements ErrorHandler {
    /** Error handler output goes here */
    private PrintStream out;
    MyErrorHandler(PrintStream out) {
    this.out = out;
    * Returns a string describing parse exception details
    private String getParseExceptionInfo(SAXParseException spe) {
    String systemId = spe.getSystemId();
    if (systemId == null) {
    systemId = "null";
    String info = "URI=" + systemId +
    " Line=" + spe.getLineNumber() +
    ": " + spe.getMessage();
    return info;
    // The following methods are standard SAX ErrorHandler methods.
    // See SAX documentation for more info.
    public void warning(SAXParseException spe) throws SAXException {
    out.println("Warning: " + getParseExceptionInfo(spe));
    public void error(SAXParseException spe) throws SAXException {
    String message = "Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    public void fatalError(SAXParseException spe) throws SAXException {
    String message = "Fatal Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    xml file(books.xml)
    <?xml version="1.0"?>
    <catalog>
    <book id="bk101">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    <genre>Computer</genre>
    <price>44.95</price>
    <publish_date>2000-10-01</publish_date>
    <description>An in-depth look at creating applications
    with XML.</description>
    </book>
    <book id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-12-16</publish_date>
    <description>A former architect battles corporate zombies,
    an evil sorceress, and her own childhood to become queen
    of the world.</description>
    </book>
    <book id="bk103">
    <author>Corets, Eva</author>
    <title>Maeve Ascendant</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-11-17</publish_date>
    <description>After the collapse of a nanotechnology
    society in England, the young survivors lay the
    foundation for a new society.</description>
    </book>
    <book id="bk104">
    <author>Corets, Eva</author>
    <title>Oberon's Legacy</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2001-03-10</publish_date>
    <description>In post-apocalypse England, the mysterious
    agent known only as Oberon helps to create a new life
    for the inhabitants of London. Sequel to Maeve
    Ascendant.</description>
    </book>
    <book id="bk105">
    <author>Corets, Eva</author>
    <title>The Sundered Grail</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2001-09-10</publish_date>
    <description>The two daughters of Maeve, half-sisters,
    battle one another for control of England. Sequel to
    Oberon's Legacy.</description>
    </book>
    <book id="bk106">
    <author>Randall, Cynthia</author>
    <title>Lover Birds</title>
    <genre>Romance</genre>
    <price>4.95</price>
    <publish_date>2000-09-02</publish_date>
    <description>When Carla meets Paul at an ornithology
    conference, tempers fly as feathers get ruffled.</description>
    </book>
    <book id="bk107">
    <author>Thurman, Paula</author>
    <title>Splish Splash</title>
    <genre>Romance</genre>
    <price>4.95</price>
    <publish_date>2000-11-02</publish_date>
    <description>A deep sea diver finds true love twenty
    thousand leagues beneath the sea.</description>
    </book>
    <book id="bk108">
    <author>Knorr, Stefan</author>
    <title>Creepy Crawlies</title>
    <genre>Horror</genre>
    <price>4.95</price>
    <publish_date>2000-12-06</publish_date>
    <description>An anthology of horror stories about roaches,
    centipedes, scorpions and other insects.</description>
    </book>
    <book id="bk109">
    <author>Kress, Peter</author>
    <title>Paradox Lost</title>
    <genre>Science Fiction</genre>
    <price>6.95</price>
    <publish_date>2000-11-02</publish_date>
    <description>After an inadvertant trip through a Heisenberg
    Uncertainty Device, James Salway discovers the problems
    of being quantum.</description>
    </book>
    <book id="bk110">
    <author>O'Brien, Tim</author>
    <title>Microsoft .NET: The Programming Bible</title>
    <genre>Computer</genre>
    <price>36.95</price>
    <publish_date>2000-12-09</publish_date>
    <description>Microsoft's .NET initiative is explored in
    detail in this deep programmer's reference.</description>
    </book>
    <book id="bk111">
    <author>O'Brien, Tim</author>
    <title>MSXML3: A Comprehensive Guide</title>
    <genre>Computer</genre>
    <price>36.95</price>
    <publish_date>2000-12-01</publish_date>
    <description>The Microsoft MSXML3 parser is covered in
    detail, with attention to XML DOM interfaces, XSLT processing,
    SAX and more.</description>
    </book>
    <book id="bk112">
    <author>Galos, Mike</author>
    <title>Visual Studio 7: A Comprehensive Guide</title>
    <genre>Computer</genre>
    <price>49.95</price>
    <publish_date>2001-04-16</publish_date>
    <description>Microsoft Visual Studio 7 is explored in depth,
    looking at how Visual Basic, Visual C++, C#, and ASP+ are
    integrated into a comprehensive development
    environment.</description>
    </book>
    </catalog>
    (books.xsd)
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="catalog">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="book" minOccurs="0" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="author" type="xsd:string"/>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="genre" type="xsd:string"/>
    <xsd:element name="price" type="xsd:float"/>
    <xsd:element name="publish_date" type="xsd:date"/>
    <xsd:element name="description" type="xsd:string"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>

    Add xmlns:xsi attribute to the root element <catalog>.
    <catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation='books.xsd'>

  • XML document creation

    Does anyone know of a Javascript or PHP script that will
    allow a client to create new and update existing xml documents that
    can be used with the Spry Dataset, through an admin area?

    I don't know of such a system. We do have a script that can
    convert queries to XML:
    http://labs.adobe.com/technologies/spry/samples/utils/query2xml.html
    And I know there are PHP scripts for inserting and updating
    records in a database, which might be easier.
    Hope this helps,
    Donald Booth
    Adobe Spry Team

  • Delivery Document creation using buffered data?

    We're using BAPIs to create an STO with estimated volumes/dates.
    But, when the Actual information comes in, we first update the STO with actual volume, then create a delivery document. The problem is that the delivery document is using the estimated volume even though we've committed the volume change and can pull up the STO to see it prior to Delivery create.
    For STO, we're using:
    BAPI_PO_CREATE1 and
    BAPI_PO_CHANGE
    For Delivery creation, we're using:
    BAPI_OUTB_DELIVERY_CREATE_STO
    It seems that the Delivery is reading buffered information rather than what's actually been committed to the DB. Is there a way to bypass the buffer when calling this BAPI?
    thanks,
    Robert

    Found a note that has addressed the issue
    2008537 - Short dump while changing a replenishment delivery multiple times in one transaction

  • How to declare the namespace of XML document to use in oracle DB?

    I have an XML Schema file( 'Hospital.xsd' ) that reference the XML document ('Hospitals.xml' ).
    That I use JDeveloper to build them up.
    JDeveloper had set the default namespace as 'http://www.example.org'
    like this :
    <?xml version="1.0" encoding="UTF-8" ?>
    <Hospitals xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.example.org src/Hospital.xsd"
    xmlns="http://www.example.org">
    If I want these two files ('Hospital.xsd' and 'Hospitals.xml') placed into
    the table in the oracle database.
    1. Should I create two tables? one for XSD and another for XML.
    2. Should I keep the XSD file in the oracle database?
    3. What is the namespace to declare in the heading of XML file?
    The database name or my website URL?
    Thank you very much.
    Kanokporn P.

    Sounds a lot like this question, only with less details.
    how to read data from XML  variable and insert into table variable
    We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us.  Plenty of examples abound on the forums that cover the topics you seek as well.

  • Billng document creation using bdc

    hi experts,
    I've been using bapi for sales order and outbound delivery creation. But for billing document i'm using BDC. it's simpler. The creation of sales order and outbound delivery has no problem. The problem is upon creation of the billing document, it only creates the last entry in the item level. Example, if item has 10,20, and 30; it will only create item 30 in the billing document level. But no problem with the sales order and outdel. What could i be missing here?
    Thank you in advance!

    Hi,
    Im actually not very particular on where in the bdc code the line items are being processed. the only variable that I see here is the outbound del number which is g_odnum. Here is the BDC code.
    f_bdc_dynpro 'SAPMV60A' '0102'.
          f_bdc_field  'BDC_CURSOR' 'KOMFK-VBELN(01)'.
          f_bdc_field  'BDC_OKCODE' '/00'.
          f_bdc_field  'KOMFK-VBELN(01)' g_odnum.
          f_bdc_dynpro 'SAPMV60A' '0104'.
          f_bdc_field  'BDC_CURSOR' 'VBRK-FKART'.
          f_bdc_field  'BDC_OKCODE' '=SICH'.
          f_bdc_transaction 'VF01'.
    Can you help me identify where it is in this BDC code?
    Thanks for you help!

  • Problem in XML Message creation using ABAP Proxy

    Hi,
    I am trying to send the data from ECC to CRM when post goods issue is done for a delivery from ECC side using ABP Proxy. I called my proxy method in BADI : DELIVERY_PUBLISH.
    And after calling the method, I used commit work also.
    But the problem is, some times it is working fine. and some times the XML messages are not getting created. When I go in debug, looks everything is fine.
    I am unable to understand why this inconsistency.
    Could you please help me out, do I need to take any more precautions.
    Thanks,
    Sandeep

    Hi,
    There is no problem in the proxy. Some small problem in the database update.
    It is solved.
    cheers
    san

  • Delivery document creation using vl01n

    Hi,
    I want to create a delivery document using VL01n.i need to create the doc for a particular selected item if there are many items for the order.i want to delete the remaining documents.
    how to handle this in BDC.

    just mention along with order ...
    from item
    as well as
    to item fields ....

  • Sales document creation using bapi

    Hi Experts ,
    When i try create sales order using bapi " BAPI_SALESDOCU_CREATEFROMDATA'" , it says error like this , Please enter sold to party and ship to party, even though we are sending partner number it shows same error , if we pass values directly in se37 we get the correct result , but when we are calling it in program it says error.
    Error on this field : partner Number
    Thanks & Regards
    Siva Krishna

    Hi shiva,
               Please go through the documentation,
    Sales document type is checked with sales and distribtion document type.
    You must at least enter order header data (using the structure ORDER_HEADER_IN) and partner data (using the table ORDER_PARTNERS).
    Furthermore, you must enter the business object for which the sales document is to be created:
                   - BUS2030 for inquiries
                   - BUS2031 for quotations
                   - BUS2032 for sales orders
    I think ur program,
    does not pass business object , kindly check

  • Extracting data from an XML document that uses namespaces

    Hello all,
    Firstly, please let me wish you all a very happy and prosperous 2013!
    I have a piece of XML containing namespaces (retrieved from a web service) and I am having difficulty extracting values
    (If you're interested this is the webservice: http://api.worldbank.org/countries/FRA/indicators/NY.GDP.MKTP.CD?date=2009)
    Here is some test code with two cases -
    1) where I leave in the namespace and
    2) where I strip out all references to the namespace
    Case 1 doesn't work, whereas Case 2 works well.
    I would prefer a more elegant solution than simply stripping out the namespace.
    I have probably just misunderstood something about how to work with namespaces in PL/SQL.
    Do any of you have suggestions about how best to approach this?
    Many thanks in advance.
    Niall.
    set serveroutput on
    set define off
    DECLARE
    v_xml XMLTYPE;
    v_clob CLOB;
    v_country VARCHAR2(255);
    BEGIN
    v_clob := '<?xml version="1.0" encoding="utf-8"?>
    <wb:data page="1" pages="1" per_page="50" total="1" xmlns:wb="http://www.worldbank.org">
    <wb:data>
    <wb:indicator id="NY.GDP.MKTP.CD">GDP (current US$)</wb:indicator>
    <wb:country id="FR">France</wb:country>
    <wb:date>2009</wb:date>
    <wb:value>2619685000757.11</wb:value>
    <wb:decimal>0</wb:decimal>
    </wb:data>
    </wb:data>';
    v_xml := XMLTYPE(v_clob);
    SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
    INTO v_country
    FROM dual;
    dbms_output.put_line(' ');
    dbms_output.put_line('*** Case 1');
    dbms_output.put_line('*** '||nvl(v_country,'nothing'));
    dbms_output.put_line(v_xml.getStringVal());
    v_xml := XMLTYPE(replace(v_clob,'wb:')); -- strip out wb:
    SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
    INTO v_country
    FROM dual;
    dbms_output.put_line(' ');
    dbms_output.put_line('*** Case 2');
    dbms_output.put_line('*** '||nvl(v_country,'nothing'));
    dbms_output.put_line(v_xml.getStringVal());
    END;
    /

    Your case 1 query should be
    (not tested)
    SELECT extractvalue(v_xml,'/wb:data/wb:data[1]/wb:country', 'xmlns:wb="http://www.worldbank.org/"')If the XML is going to be small, you could also do it this way purely in PL/SQL
    [url http://anononxml.blogspot.com/2010/06/xml-parsing-with-namespaces-via-plsql.html]XML Parsing with Namespaces via PL/SQL. Ignore the DOMDocument examples (first two) in there.
    If the XML will be large and you are on 11.1 or greater, then it would be faster to insert the XML into a column in a DB table (could be a global temporary table) where the column is XMLType and the storage is SECUREFILE BINARY (default on 11.2.0.2+). Then you could use XMLTable, like
    [url http://anononxml.blogspot.com/2010/08/xml-parsing-with-namespaces-via.html]XML Parsing with Namespaces via XMLTable 

  • Best class to use to cache an XML document

    Hello all,
    I have an utility class representing an XML document, used withing a web application. This document shall be cached in the session since within a request and during the sessions I read it often and to several other things like XPath and XSLT.
    But I am having problems due to this Bug:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6322678
    and keep bad file descriptor errors due to these stream "specialities". There is a standard way of using cached+precompiled XSL templates and I wonder if there is a similar things for XML documents.
    So I need an internal variable in my class containing the raw XML document - so using streams is not an ideal solution in regards of the bug - i am getting "bad file descriptor" errors from time to time.
    I am playing with the idea of storing the XML document within a simple String and create the required Class from it for the according operations like XPath evaluation and XSL transformation. But I think that is quite more resource hungry than reading the XML document from the filesystem each time...
    Has anyone some hints on how to keep an XML document in memory internally?
    Thanks and regards,
    Timo

    Rehi,
    So, everything works really fine! Thanks. As promised, here some examples
    with bad indentations etc...:
    Doing XSL transformation:
    import java.io.StringWriter;
    import org.w3c.dom.Document;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.Templates;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.stream.StreamResult;
    TransformerFactory tFac = TransformerFactory.newInstance();
    Templates compiledXslt = tFac.newTemplates(sheet);
    Transformer transformer = compiledXslt.newTransformer();
    StringWriter sw = new StringWriter();
    StreamResult sr = new StreamResult(sw);
    transformer.transform(new DOMSource(this.doc), sr);
    System.err.println(sw.toString());************************
    Doing XPath was a surprise and was originally my problem (I called evaluate() with an InputStream that occassioannly failed), I tried also here with new DOMSource() what also failed although not being null or so... funny: evaluate() can directly be called w/ dom.Document:
    import javax.xml.xpath.XPath;
    import javax.xml.xpath.XPathFactory;
    import org.w3c.dom.Document;
    (this.doc is a org.w3c.dom.Document)
    public String getXPathEvaluationAsString(String expr) {
         try {
              XPath xp = XPathFactory.newInstance().newXPath();
              return (String)xp.evaluate(
                   expr,
                   this.doc,
                   XPathConstants.STRING
         } catch(Exception e) {
              e.printStackTrace();
         return " ";
    }Thanks and regards,
    Timo

  • Loading/breaking large files containing multiple XML documents using plsql

    Hi I have a requirement where in the client sends the multiple xml payloads/documents in a single text file. I need to load that into the xmltype varialbe. How to do this?
    I'm able to load the entire document into a clob object, here.. all the xml payloads are loaded into a single row. When I try to access this I get a error
    ORA-31001: Invalid resource handle or path name "/MobileInventoryResponse.dtd"
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    This error is due to the dtd present in the xml document : <!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd">
    But if I load the data into a clob after removing the doctype reference then I get the following error. Here to mulitple xml documents are loaded into a single clob row.
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00209: PI names starting with XML are reserved
    Error at line 81
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    When try to access this by using select xmltype(x) from t
    where x is column type of clob.
    Please let me know any method or type loading the multiple xml documents by using plsql. Only plsql method. There is a way by using SAX Loader. But can it be used in plsql or its a java method of loading.
    Regards,
    Naveen
    Edited by: MAN on Oct 18, 2008 9:21 PM

    sorry for that...
    There was enter character between some tags. From there I'm not receiving that particular error.
    Now what I get is
    ORA-31001: Invalid resource handle or path name "/MobileInventoryResponse.dtd"
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    ORA-06512: at line 39
    This is because there is a doctype at the start of the xml payload.
    But if there is no <!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd"> this statement then it works fine.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd">
    <MobileInventoryResponse>
    And this exercise I'm doing in my Windows xp loaded operating system with a local instance of oracle ... Do i need to do any other setting.
    Along with that I followed your method mentioned @ Re: LPX-00209: PI names starting with XML are reserved
    ignore:=dbms_xdb.createResource('/MobileInventoryResponse.dtd',bfilename('XML_DIR','MobileInventoryResponse.dtd'));
    And I'm not getting how it will refer the this resource.
    this above partilcular statement . should it be executed when ever we insert into the table ? But in the dtd there is no word saying "MobileInventoryResponse".
    got this error.
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00104: Warning: element "MobileInventoryResponse" is not declared in the DTD
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    ORA-06512: at line 21
    This is how I'm doing in the block
    DECLARE
    l_filehandle UTL_FILE.FILE_TYPE;
    l_filename VARCHAR2(50):='test.xml';
    l_rec_data VARCHAR2(500);
    l_rec_trim_data VARCHAR2(500);
    l_rec_trim_upper VARCHAR2(500);
    l_rec_full_data CLOB;
    ignore boolean;
    BEGIN
    l_filehandle := UTL_FILE.FOPEN('XML_DIR',l_filename,'R');
    --dbms_xdb.deleteResource('/MobileInventoryResponse.dtd',dbms_xdb.DELETE_RESOURCE   );
    LOOP
    ignore:=dbms_xdb.createResource('/MobileInventoryResponse.dtd',bfilename('XML_DIR','MobileInventoryResponse.dtd'));
    commit;
    UTL_FILE.GET_LINE(l_filehandle, l_rec_data);
    --dbms_output.put_line('l_rec_data : '|| l_rec_data);
    -- Trim the record to remove spaces
    l_rec_trim_data := TRIM(l_rec_data);
    l_rec_trim_upper := UPPER(l_rec_trim_data);
    l_rec_full_data := l_rec_full_data||l_rec_data;
    IF l_rec_trim_upper LIKE '</MOBILEINVENTORYRESPONSE>' THEN
    dbms_output.put_line('l_rec_full_data : '||l_rec_full_data);
    INSERT INTO library_xml VALUES(xmltype(l_rec_full_data));
    l_rec_full_data:=NULL;
    END IF;
    dbms_xdb.deleteResource('/MobileInventoryResponse.dtd',dbms_xdb.DELETE_RESOURCE );
    commit;
    END LOOP;
    UTL_FILE.FCLOSE(l_filehandle);
    COMMIT;
    --exception just for testing purpose
    EXCEPTION
    WHEN no_data_found THEN
    NULL;
    commit;
    END;
    Edited by: MAN on Oct 21, 2008 2:47 AM

  • No default attributes while Parsing XML document

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

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

  • Multiple XML documents in one SWF

    Hi, i'm trying to create a mix and match clothing application
    using flash for a school project but am having trouble with xml
    documents. Using an online tutorial, i found it was quite easy to
    load up one xml document, example of code below.
    I thought it would be as simple as copying all the code and
    changing the variable names to load a second xml document but i
    find when i run the code, that only the last xml document in the
    code loads, could anyone give me any tips? Thanks
    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    image = [];
    description = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    image
    = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
    description
    = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
    firstImage();
    } else {
    content = "file not loaded!";
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("images.xml");

    Hi, i checked my text and description boxes in my document,
    and it is in fact loading the separate xml document, the problem
    seems to stem from the fact that it is not displaying the xml image
    within the movie clip.
    I have two separate mc's on the stage, with different
    instance names, flash displays the description of each separate xml
    document, however, it only shows one of the movie clips images, if
    i delete one from the actionscript, it shows the other, so it must
    be something to do with them overwriting each other, i used a
    trace, so i know the data is in flash for the images which arent
    being shown, it just isn't showing for some reason.

  • Indices configuration for XML document analysis (indexing time problems)

    Hi all,
    I'm currently developing a tool for XML Document analysis using XQuery. We have a need to analyse the content of a large CMS dump, so I am adding all documents to a berkeley DB xml to be able to run xqueries against it.
    In my last run I've been running to indexing speed problems, with single documents (typically 10-20 K in size) taking around 20 sec to be added to the database after 6000 documents (I've got around 20000 in total). The time needed for adding docs to the database drops with the number of documents.
    I suspect my index configuration to be the reason for this performance drop. Indeed, I've been very generous with indexes, as we have to analyse the data and don't know the structure in advance.
    Currently my index configuration includes:
    - 2 default indicess: edge-element-presence-none and edge-attribute-presence-none to be able to speed up every possible xquery to analyse data patterns: ex. collection()//table//p[contains(.,'help')]
    - 8 edge-attribute-substring-string indices on attributes we use often (id, value, name, ...)
    - 1 edge-element-substring-string index on the root element of the xml documents to be able to speed up document searches: ex. collection()//page[contains(.,'help')]
    So here my questions:
    - Are there any possible performance optimisations in Database config (not index config)? I only set the following:
    setTransactional(false);
    envConf.setCacheSize(1024*64);
    envConf.setCacheMax(1024*256);
    - How can I test various index configuration on the fly? Are there any db tools that allow to set/remove indexes?
    - Is my index config suspect? ;-)
    Greetings,
    Nils

    Hi Nils,
    The edge-element-substring-string index on the document element is almost certainly the cause of the slow document inserts - that's really not a good idea. Substring indexes are used to optimize "=", contains(), starts-with() and ends-with() when they are applied to the named element that has the substring index, so I don't think that index will do what you want it to.
    John

Maybe you are looking for

  • Why will itunes not open on my macbook pro

    i recently got a new charger for my macbook pro because my old one had stopped working, so my computer had not been charged for about a week or a little longer. once i started up my computer i noticed that it started to freeze alot and itunes would n

  • Window s 8 consumer problem with hp laserjet p1005

    hello everyone today my second day with consumer preview  my printer was working will with developer preview but now i installed the software of hp full package and the printer where installed then i am trying to printing any page at give's me a side

  • How to use a SANYO HD flash memory camera with a Mac

    If you have a Sanyo camera similar to the XACTI that takes HD video in the h.264 format, you may get a green or black screen when you try to run the video. This happened to me, but I found a solution. --THIS IS FOR LEOPARD OR LOWER (NOT tested on Sno

  • How to define interface of IDOC?

    IDoc outbound:  In step 1, a new file is generated with the transferred IDocs by the IDoc Interface. In the second step, the program ¡°rfcexec¡± (synchronous RFC) with the path to an executable program is called (here: ¡°out.script¡±) and also the pa

  • TS3274 delete button doesn't work

    I have been trying to delete multiple photos that I imported from my Macbook. It will let me select the photos, but when I touch the red delete button it does nothing. What should I do?