Sizing DOM trees created by Oracle Java XML parser (v2)

Hello,
Has anyone seen/got any formulas that can be used to calculate the DOM tree memory requirements for a given XML document.
My team has developed some software that, acts like an XSLT, and it runs out of memory for bigger documents. I am able to allocate more memory (usuing java -Xmx<larger figure>) to the process but it would be nice to go to my team leader and say that a file of a given structure would require so much memory.
At the moment, we are guessing and using the Runtime.getRuntime().freeMemory() and Runtime.getRuntime().TotalMemory()
to provide some very rough estimates.
XSLTs wouldnt be able to do what we want. If I could give the team leader some figures then he may be able to justify converting the code to use JDOM instead of a DOM tree.
Thanks in Advance.
Mark Robbins

Can you paste your java code here ? I assume, you must have tried type-casting.

Similar Messages

  • Java XML Parser:Null Pointer exception in EntityReader

    I got NullPointer Exception when trying to parse a XML file which
    is pointed by a net URL, (say "http://www..."). The code causing
    problem is like:
    parser.parse(new URL("http://www.../demo.xml"));
    the exception I got is:
    java.lang.NullPointerException
    java.lang.NullPointerException
    at oracle.xml.parser.EntityReader.initXMLInput(Compiled
    Code)
    at
    oracle.xml.parser.EntityReader.<init>(EntityReader.java:64)
    at oracle.xml.parser.XMLParser.parse(XMLParser.java:245)
    at DemoXML.main(DemoXML.java:47)
    The very same code works fine with a simple local file URL and we
    also know that the URL exists in correct in XML format because we
    can open the URL with IE5.
    Another question - where can we get the source for the Java XML
    Parser.
    null

    This bug has already been reported and will be fixed in our next
    release.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Fiona Lu (guest) wrote:
    : I got NullPointer Exception when trying to parse a XML file
    which
    : is pointed by a net URL, (say "http://www..."). The code
    causing
    : problem is like:
    : parser.parse(new URL("http://www.../demo.xml"));
    : the exception I got is:
    : java.lang.NullPointerException
    : java.lang.NullPointerException
    : at oracle.xml.parser.EntityReader.initXMLInput
    (Compiled
    : Code)
    : at
    : oracle.xml.parser.EntityReader.<init>(EntityReader.java:64)
    : at oracle.xml.parser.XMLParser.parse
    (XMLParser.java:245)
    : at DemoXML.main(DemoXML.java:47)
    : The very same code works fine with a simple local file URL and
    we
    : also know that the URL exists in correct in XML format because
    we
    : can open the URL with IE5.
    : Another question - where can we get the source for the Java
    XML
    : Parser.
    null

  • URGENT! SEGV-errors when using Oracle C XML Parser for Solaris

    I often (not always) got SEGV-error with core dump when I use Oracle Oracle C XML Parser for Solaris. This Error is always got in the call of the the function xmlinit(...) with all params as NULL but the first required for the error code and the second which i assign a macro that evaluates to "US-ASCII". Does anyone knows about this problem?
    I am using a very short, wellformed and validated XML document.
    I would be very glad for some help about this!
    null

    Please provide a sample program along with the version number of the XML parser.

  • Oracle java XML API - extract

    I am using XML oracle Java API, I need to extract tge DOC value, its not working for me
    XMLTYPE xml ="
    <PurchaseOrder>
    <Reference>ADAMS-20011127121040988PST</Reference>
    <DOC>SCOTT</DOC>
    <Date>2002-03-31</Date>
    </PurchaseOrder>";
    System.out.println("Testing extract() ...");
    try {
    System.out.println(" length of text in DOC tag " + (xml.extract("/PurchaseOrder/Reference/DOC/text()",null).getStringVal()));
    catch (SQLException e) {
    System.out.println("Thin driver Expected exception: " + e);
    Throwing java.sql.SQLException
    any help please? is there anyother way to extract the value?

    I guess this might help you..
    Use XPATH if you are reading for a single value in xml .
    It will be more cleaner...
    String doc= "//PurchaseOrder/Reference/DOC/text()";
    Call this in your class using some value
    Suppose
    setting_to_some_variable.setWhateverDoc(getNodeValueFromDocUsingXPath(doc));
              address
    private String getNodeValueFromDocUsingXPath(String xpathString) {
              try {
                   XPath xpath = xPathFactory.newXPath();
                   XPathExpression expr = xpath.compile(xpathString);
                   Node aNode = (Node) expr.evaluate(doc, XPathConstants.NODE);
                   if (aNode != null) {
                        return aNode.getNodeValue();
              } catch (XPathExpressionException xpe) {
                   xpe.printStackTrace(System.out);
              return null;
         }

  • Java XML Parser v2 xpath problem

    I have a lot of trouble using the xpath functionality. I want to get the name of different elements. I'm using some xpath expressions which in my opinion should work (see http://www.w3.org/TR/xpath ), but they don't. I'm calling XMLNode.selectSingleNode.
    For example :
    /*/name()
    name(/*[1])
    name(/*)
    name()
    I've tried those with Saxon and they do work. Using the Oracle implementation an exception is thrown on most expressions. So what's wrong here?
    Bye,
    Jan

    Consider this example
    --- Test.java -----
    import java.io.*;
    import javax.xml.transform.sax.SAXSource;
    import net.sf.saxon.sxpath.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    import org.xml.sax.InputSource;
    public class Test
    public Test() {
    try {
    DOMParser domParser = new DOMParser();
    domParser.parse(new FileReader("test.xml"));
    XMLDocument document = domParser.getDocument();
    InputSource is = new InputSource(new File("test.xml").toURL().toString());
    SAXSource source = new SAXSource(is);
    testXPathOracle(document,"count(//*)");
    testXPathOracle(document,"name(/*)");
    testXPathOracle(document,"name(/root)");
    testXPathOracle(document,"/*/name()");
    testXPathSaxon(source,"count(//*)");
    testXPathSaxon(source,"name(/*)");
    testXPathSaxon(source,"name(/root)");
    testXPathSaxon(source,"/*/name()");
    } catch(Exception e) {
    System.out.println(e.getMessage());
    public void testXPathOracle(XMLNode context, String xpath) {
    try {
    Node node = context.selectSingleNode(xpath);
    System.out.println(node.getNodeValue());
    } catch(Exception e) {
    System.out.println(e.getMessage());
    public void testXPathSaxon(SAXSource source, String xpath) {
    try {
    XPathEvaluator xpe = new XPathEvaluator();
    XPathExpression exp = xpe.createExpression(xpath);
    Object object = exp.evaluateSingle(source);
    System.out.println(object);
    } catch(Exception e) {
    System.out.println(e.getMessage());
    public static void main(String[] args) {
    Test test = new Test();
    --- test.xml -----
    <root>
         <element/>
    </root>
    Result is on my computer:
    Unknown expression at EOF: (count(//*))[1].
    Unknown expression at EOF: (name(/*))[1].
    Unknown expression at EOF: (name(/root))[1].
    Error in expression: '(/*/name())[1]'.
    2
    root
    root
    root
    I think the xpath expressions are valid. So what's wrong?

  • Oracle and XML Parser

    Hi friends
    I'm trying to load xmlparserv2.jar into the database using loadjava..it is creating and loading the classes successfully but while resolving it's giving an error i.e. referenced object SCOTT.oracle/xml/parser/v2/<ClassName> could not be resolved..
    When i tried to resolve the class using the Alter Java Class command it's resolving..but while using the class in a program...at the time of compilation it shows The class is not resolved..
    Please Help...If there is any other way to resolve a class...or to load a parser in to the database..
    Thanks

    What are the specific ORA-XXX error messages you're getting?

  • Creating chart leads in XML Parsing Error: mismatched tag. Expected: /svg

    Hello ALL,
    I searched this forum but unfortunately I find not a solution for the following use case:
    described in steps
    1.) create a region with chart (typ = line) -> o.k.
    2.) create a sql statement to have data in the chart -> o.k.
    3.) running report with this created region and chart -> vizualisation o.k.
    3.) create a data picker item ":P21_END_DATE"
    4.) replaced the where clause "WHERE a_timestamp >= To_date ('01.02.2007', 'dd/mm/yyyy HH24:MI') -1/24" with WHERE a_timestamp >= To_date (:P21_END_DATE, 'dd/mm/yyyy HH24:MI') -1/24
    5.) running report with this created region and chart and data picker item -> vizualisation not o.k. I get the attached error message.
    I read already in the forum and knows that the end tag of the svg section is lost put I only changed in my query the described value. Does any body can help me please ??
    king regards
    XML Parsing Error: mismatched tag. Expected: </svg>.
    Location: http://localhost:7777/pls/htmldb/f?p=103:9:8795066316806762442:FLOW_SVG_CHART_R2476324075306576_de
    Line Number 22, Column 1455:</style><script xlink:href="/i/javascript/svg_js_includes/svg_common/oracle.svgInit.js"/><script xlink:href="/i/javascript/svg_js_includes/svg_common/oracle.svgNodes.js"/><script type="text/ecmascript"><![CDATA[function svgSync(){window.reload();}function htmldb_Load(){try{oracleSvgInit(evt);throw "old version" }catch(er){}}]]></script><rect id="background" x="1" y="1" width="1022" height="398"/><text x="20" y="20" class="title">Chart 1</text><text id="XAxisTitle" x="50%" y="390">Minute</text><text id="YAxisTitle" x="15" style="writing-mode:lr;" y="200" transform="rotate(-90,15,200)" text-anchor="middle">Messages</text><g id="legend" transform="translate(0,25)"><rect class="legend" x="1" y="0" width="1022" height="60"/><g class="legenditem" transform="translate(20,18)"><line x1="0" y1="-5" x2="-15" y2="-5" class="data1"/><text class="legend" y="0" x="2">ALL</text></g><g class="legenditem" transform="translate(20,36)"><line x1="0" y1="-5" x2="-15" y2="-5" class="data2"/><text class="legend" y="0" x="2">SMS</text></g><g class="legenditem" transform="translate(20,54)"><line x1="0" y1="-5" x2="-15" y2="-5" class="data3"/><text class="legend" y="0" x="2">LL</text></g></g><svg width="1024" height="400" viewBox="-5 -5 1024 400" preserveAspectRatio="none"> <text class="nodatafound" x="40" y="20">No data found.</text><text class="nodatafound" x="40" y="20">no data found</text><text class="nodatafound" x="40" y="20">no data found</text></g></svg><g id="infobubble" transform="translate(0,0)" style="visibility:hidden"><rect id="infobackground" rx="2" ry="2" x="0" y="0" width="100" height="20" fill-opacity=".9" fill="#FFFFFF" stroke="#000000" stroke-width="1"/><text id="infotext" x="5" y="12">-</text></g><!-- USER FOOTER--></svg>
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^

    I found the solution:
    No data resulting to the query !!

  • Oracle 8i XML Parser for PL/SQL

    Hi,
    Using "Building Oracle XML Applications" by O'reilly, I am
    trying to get XML working on an Oracle 8i database. I have done the following steps:
    1) verify oracle.xml.parser.v2.DOMParser class is running;
    select substr(dbms_java.longname(object_name),1,30) as class, status
    from all_objects
    where object_type = 'JAVA CLASS'
    and object_name = dbms_java.shortname('oracle/xml/parser/v2/DOMParser');
    CLASS STATUS
    oracle/xml/parser/v2/DOMParser VALID
    OK
    2) Check for Oracle XML Parser for PL/SQL is installed:
    DESCRIBE xmlparser
    ERROR:
    ORA-04043: object xmlparser does not exist
    So apparently i need to download the Oracle XML Parser for PL/SQL.
    I cannot locate this download on the oracle site for version 8i (8.1.7.4 specifically).
    Any helpers out there?

    You can use the latest version.

  • Any buglist available for Oracle C XML parser?

    Anyone who knows?
    Thank you
    null

    Please provide a sample program along with the version number of the XML parser.

  • Any Oracle/Java/XML developers in Houston, TX interested in getting together ?

    I was just looking for some new collegues and friends. I am currenlty working in Houston, TX and I am interested in getting together with other professionals. If anyone is interested email me at [EMAIL][email protected][EMAIL] .
    Jason Long
    Enterprise Web Developer
    BS Physics
    MS Chemical Engineering
    null

    Does anyone know of any oraganizations in Houston, TX where I can meet other developers? I am currenlty working for a company that only supports Microsoft products and I am trying to switch over. I am sick of Microsoft letting me debug their applications. I would like to develop using standards based products. If anyone on here is from Houston please get it touch with me.

  • Java XMl parsing problems

    i have an xml sturcture as shown below:
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
    <cnv:roottag support="yes" destag="xfw:script">
    <cnv:addattr name="debug" value="no" />
    <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
    </cnv:roottag>
    <xsql:query support="yes" destag="xfw:genxml">
    <connection support="no" />
    <row-element support="yes" destag="row-name" />
    <rowset-element support="yes" destag="rowset-name" />
    <id-attribute support="no" />
    <tag-case support="no" />
    <null-indicator support="no" />
    <cnv:addattr name="debug" value="yes" />
    <cnv:addattr name="Attribute1" value="Value1" />
    </xsql:query>
    <xsql:no-rows-query support="no" child="no" />
    <responsedata support="no" child="yes" />
    <responsedata2 support="no" child="yes" />
    <page destag="page1" support="yes">
    <connection support="no" /> <debug destag="MyDebug" />
    <cnv:addattr name="tt" value="t1" />
    </page>
    <xsql:set-page-param support="yes" destag="setpageparam">
    <name destag="myname" />
    </xsql:set-page-param>
    <xsql:set-page-param-local support="yes" destag="Myset-page-param-local">
    <name destag="mylocalname" />
    </xsql:set-page-param-local>
    </cnv:conversion>
    I want this xml to be validated by the dom parser which i had done and its showing it as valid XML.
    If there are any repeating tags like:
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
    <cnv:roottag support="yes" destag="xfw:script">
    <cnv:addattr name="debug" value="no" />
    <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
    </cnv:roottag>
    <xsql:query support="yes" destag="xfw:genxml">
    <connection support="no" />
    <row-element support="yes" destag="row-name" />
    <rowset-element support="yes" destag="rowset-name" />
    <id-attribute support="no" />
    <tag-case support="no" />
    <null-indicator support="no" />
    <cnv:addattr name="debug" value="yes" />
    <cnv:addattr name="Attribute1" value="Value1" />
    </xsql:query>
    <xsql:no-rows-query support="no" child="no" />
    <responsedata support="no" child="yes" />
    <responsedata2 support="no" child="yes" />
    <page destag="page1" support="yes">
    <connection support="no" /> <debug destag="MyDebug" />
    <cnv:addattr name="tt" value="t1" />
    </page>
    <xsql:set-page-param support="yes" destag="setpageparam">
    <name destag="myname" />
    </xsql:set-page-param>
    <xsql:set-page-param-local support="yes" destag="Myset-page-param-local">
    <name destag="mylocalname" />
    </xsql:set-page-param-local>
    </cnv:conversion>
    </cnv:conversion>
    or like this....................
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
    <cnv:roottag support="yes" destag="xfw:script">
    <cnv:addattr name="debug" value="no" />
    <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
    </cnv:roottag>
    <cnv:roottag support="yes" destag="xfw:script">
    <cnv:addattr name="debug" value="no" />
    <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
    </cnv:roottag>
    <xsql:query support="yes" destag="xfw:genxml">
    <connection support="no" />
    <row-element support="yes" destag="row-name" />
    <rowset-element support="yes" destag="rowset-name" />
    <id-attribute support="no" />
    <tag-case support="no" />
    <null-indicator support="no" />
    <cnv:addattr name="debug" value="yes" />
    <cnv:addattr name="Attribute1" value="Value1" />
    </xsql:query>
    <xsql:no-rows-query support="no" child="no" />
    <responsedata support="no" child="yes" />
    <responsedata2 support="no" child="yes" />
    <page destag="page1" support="yes">
    <connection support="no" /> <debug destag="MyDebug" />
    <cnv:addattr name="tt" value="t1" />
    </page>
    <xsql:set-page-param support="yes" destag="setpageparam">
    <name destag="myname" />
    </xsql:set-page-param>
    <xsql:set-page-param-local support="yes" destag="Myset-page-param-local">
    <name destag="mylocalname" />
    </xsql:set-page-param-local>
    </cnv:conversion>
    My java code is shown below :
    import java.io.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.*;
    public class sample2
    public void processXML(String path)
    File docFile=new File(path);
    Document doc=null;
    try
    DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); DocumentBuilder db=dbf.newDocumentBuilder();
    doc=db.parse(docFile);
    catch(IOException ioe)
    System.out.println("cant find file");
    catch(Exception e)
    System.out.println("Error has occured");
    Element root=doc.getDocumentElement();
    NodeList children=root.getChildNodes();
    StringBuffer sbuf=new StringBuffer();
    for(Node child=root.getFirstChild(); child!=null; child=child.getNextSibling())
    if(child.getNodeType()==child.TEXT_NODE) sbuf.append(child.getNodeValue()) ;
    else if(child.getNodeType()==child.ELEMENT_NODE) if(child.getChildNodes()!=null)
    getnodes(child, sbuf);
    public void getnodes(Node Child, StringBuffer sbf)
    NodeList children=Child.getChildNodes();
    if(children.getLength() > 0)
    System.out.println(children.getLength() + Child.getNodeName());
    for(Node child=Child.getFirstChild(); child!=null;child=child.getNextSibling())
    if(child.getNodeType()==child.TEXT_NODE) sbf.append((child.getNodeValue()).trim());
    else if(child.getNodeType()==child.ELEMENT_NODE)
    if(child.getChildNodes()!=null)
    getnodes(child, sbf); sbf.append(";");
    public static void main(String[] args)
    testxml txml=new testxml();
    txml.processXML("E:\\Naresh\\conversion_fxsql.xml");
    can any body tell me how to validate the repeating tags (as i dont have dtd for this xml )with the given code.... if any one of the tags are repeating it should raise an exception thats its not a valid xml
    Thanks in advance
    Regards
    Bunny

    I suggest you create a DTD or a XSD file to validate your existing XML document, because it's easier that i looks, and will help in future changes.
    If you want to do it in Java code, you can always store each line of the XML file in some form (like a class) in a List, and the each time you read a line, you compare with everything on the list.
    But don't go that way, make a XSD file

  • JAVA XML Parsing

    i have an xml sturcture as shown below:
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
         <cnv:roottag support="yes" destag="xfw:script">
              <cnv:addattr name="debug" value="no" />
              <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
         </cnv:roottag>
         <xsql:query support="yes" destag="xfw:genxml">
              <connection support="no" />
              <row-element support="yes" destag="row-name" />
              <rowset-element support="yes" destag="rowset-name" />
              <id-attribute support="no" />
              <tag-case support="no" />
              <null-indicator support="no" />
              <cnv:addattr name="debug" value="yes" />
              <cnv:addattr name="Attribute1" value="Value1" />
         </xsql:query>
         <xsql:no-rows-query support="no" child="no" />
         <responsedata support="no" child="yes" />
         <responsedata2 support="no" child="yes" />
         <page destag="page1" support="yes">
              <connection support="no" /> <debug destag="MyDebug" />
              <cnv:addattr name="tt" value="t1" />
         </page>
         <xsql:set-page-param support="yes" destag="setpageparam">
              <name destag="myname" />
         </xsql:set-page-param>
         <xsql:set-page-param-local support="yes" destag="Myset-page-param-local">
              <name destag="mylocalname" />
         </xsql:set-page-param-local>
    </cnv:conversion>
    I want this xml to be validated by the dom parser which i had done and its showing it as valid XML.
    If there are any repeating tags like:
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
         <cnv:roottag support="yes" destag="xfw:script">
              <cnv:addattr name="debug" value="no" />
              <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
         </cnv:roottag>
         <xsql:query support="yes" destag="xfw:genxml">
              <connection support="no" />
              <row-element support="yes" destag="row-name" />
              <rowset-element support="yes" destag="rowset-name" />
              <id-attribute support="no" />
              <tag-case support="no" />
              <null-indicator support="no" />
              <cnv:addattr name="debug" value="yes" />
              <cnv:addattr name="Attribute1" value="Value1" />
         </xsql:query>
         <xsql:no-rows-query support="no" child="no" />
         <responsedata support="no" child="yes" />
         <responsedata2 support="no" child="yes" />
         <page destag="page1" support="yes">
              <connection support="no" /> <debug destag="MyDebug" />
              <cnv:addattr name="tt" value="t1" />
         </page>
         <xsql:set-page-param support="yes" destag="setpageparam">
              <name destag="myname" />
         </xsql:set-page-param>
         <xsql:set-page-param-local support="yes" destag="Myset-page-param-local">
              <name destag="mylocalname" />
         </xsql:set-page-param-local>
    </cnv:conversion>
    </cnv:conversion>
    or like this....................
    <cnv:conversion xmlns:cnv="urn:ssis-conv" xmlns:xsql="urn:oracle-xsql">
         <cnv:roottag support="yes" destag="xfw:script">
              <cnv:addattr name="debug" value="no" />
              <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
         </cnv:roottag>
    <cnv:roottag support="yes" destag="xfw:script">
              <cnv:addattr name="debug" value="no" />
              <cnv:addattr name="xmlns:xfw" value="urn:scb-xfw-v2" />
         </cnv:roottag>
         <xsql:query support="yes" destag="xfw:genxml">
              <connection support="no" />
              <row-element support="yes" destag="row-name" />
              <rowset-element support="yes" destag="rowset-name" />
              <id-attribute support="no" />
              <tag-case support="no" />
              <null-indicator support="no" />
              <cnv:addattr name="debug" value="yes" />
              <cnv:addattr name="Attribute1" value="Value1" />
         </xsql:query>
         <xsql:no-rows-query support="no" child="no" />
         <responsedata support="no" child="yes" />
         <responsedata2 support="no" child="yes" />
         <page destag="page1" support="yes">
              <connection support="no" /> <debug destag="MyDebug" />
              <cnv:addattr name="tt" value="t1" />
         </page>
         <xsql:set-page-param support="yes" destag="setpageparam">
              <name destag="myname" />
         </xsql:set-page-param>
         <xsql:set-page-param-local support="yes" destag="Myset-page-param-local">
              <name destag="mylocalname" />
         </xsql:set-page-param-local>
    </cnv:conversion>
    or any row is being repeated it not a valid XML....
    my java code is :
    My java code is shown below :
    import java.io.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.*;
    public class sample2
         public void processXML(String path)
              File docFile=new File(path);
              Document doc=null;
              try
                   DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();                     DocumentBuilder db=dbf.newDocumentBuilder();
                   doc=db.parse(docFile);
              catch(IOException ioe)
                   System.out.println("cant find file");
              catch(Exception e)
                   System.out.println("Error has occured");
              Element root=doc.getDocumentElement();
              NodeList children=root.getChildNodes();
              StringBuffer sbuf=new StringBuffer();
              for(Node child=root.getFirstChild(); child!=null; child=child.getNextSibling())
                   if(child.getNodeType()==child.TEXT_NODE)                sbuf.append(child.getNodeValue()) ;
                   else if(child.getNodeType()==child.ELEMENT_NODE)                if(child.getChildNodes()!=null)
                   getnodes(child, sbuf);
    public void getnodes(Node Child, StringBuffer sbf)
         NodeList children=Child.getChildNodes();
         if(children.getLength() > 0)
              System.out.println(children.getLength() + Child.getNodeName());
         for(Node child=Child.getFirstChild(); child!=null;child=child.getNextSibling())
              if(child.getNodeType()==child.TEXT_NODE) sbf.append((child.getNodeValue()).trim());
         else if(child.getNodeType()==child.ELEMENT_NODE)
         if(child.getChildNodes()!=null)
              getnodes(child, sbf); sbf.append(";");
    public static void main(String[] args)
         testxml txml=new testxml(); txml.processXML("E:\\Naresh\\conversion_fxsql.xml");
    can any body tell me how to validate the repeating tags with the given code.... if any one of the tags are repeating it should raise an exception thats its not a valid xml
    Thanks in advance
    Regards
    Bunny

    The first problem about this document is that it contains a space at the very first position whereas <?xml... must appear at the very beginning of a document. I think this was the cause of the parsing fault.
    Also you have a dash before the root element of the document, which is illegal.

  • Best Way to Create Generic PL/SQL XML Parser

    I have an application that stores xml documents in a table. For each product sold in the system, a different XML document can exist for custom data about that product.
    The schemas are stored in another table and not with the xml document. I am looking for a way to parse the nodes at a minium and save the xml fragment for each node or possibly take each node and store each non-repeating elment in another table to make it easier for end users to query the data.
    Any suggestions on how to address this?
    Thanks

    I've been testing XML DB (XMLType Tables and Columns) a few months ago with very good results, this might help. http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb03usg.htm#BABDGDJG

  • Java + XML = parsing error

    I am recieving this message when application is parsing an xml file, but only in specific cases which i can't determinate. Seems like xml file structure is the same in the cases when all is ok, and when i get that message below. I dont use any schema.
    DefaultValidationEventHandler: [ERROR]: Unexpected element {}:ALRT
    Location:
    javax.xml.bind.UnmarshalException: Unexpected element {}:ALRT
    My xml file structure in most occasions is like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <SHOP_answer id="shop_response">
    - <WAREHOUSE>
    <Warehouse_client Id="C1">Gate</Warehouse_client>
    <Warehouse_server Id="TS1">SHOP SERVER</Warehouse_server>
    <Warehouse_transaction Id="0">Test</Warehouse_transaction>
    <Warehouse_language Id="LV">Latvieshu</Warehouse_language>
    <Warehouse_currency Id="EUR">Euro</Warehouse_currency>
    </WAREHOUSE>
    - <STORE>
    - <ITM id="1">
    - <GDS nbr="100">
    <gds_descr>live animals</gds_descr>
    <gds_ind>3</gds_ind>
    </GDS>
    - <LOC>
    <loc_area_id>NL</loc_area_id>
    <loc_area_descr>Nid</loc_area_descr>
    </LOC>
    - <EMA id="1">
    <EMA_id code="3">ABC</EMA_id>
    - <PRICE id="026">
    - <Price_element>
    <Price_b>0.42</Price_b>
    <Price_r>0.418</Price_r>
    <Price_a>0.18</Price_a>
    <bee_code>271</bee_code>
    </Price_element>
    - <Price_element>
    <Price_b>0.00</Price_b>
    <Price_r>2.227</Price_r>
    <Price_a>0.00</Price_a>
    <bee_code>272</bee_code>
    </Price_element>
    </PRICE>
    </EMA>
    </ITM>
    </STORE>
    </SHOP_answer>

    The first problem about this document is that it contains a space at the very first position whereas <?xml... must appear at the very beginning of a document. I think this was the cause of the parsing fault.
    Also you have a dash before the root element of the document, which is illegal.

  • Java XML parsing with Xerces in Eclipse using Oxygen problem

    Hey everybody,
    Got me a stickler of a prob here and i'm hoping sum one out there will be able to help. I am trying to parse XML files into JDom objects so i can use them in the rest of my project with ease, but i'm having trouble parsing anything wihtout getting these errors
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : Document root element "personnel", must match DOCTYPE root "null".
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : Document is invalid: no grammar found.
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'personnel'.
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'personnel'.
    The are the files are ones that come in Oxygens samples folder so they should be correct. The code is as follows
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              factory.setValidating(true);
    SchemaFactory sFact = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    Schema schema = sFact.newSchema(schemaFile);
    factory.setSchema(schema);
    DocumentBuilder dommer = factory.newDocumentBuilder();          
    Document doco = dommer.parse(xmlFile.getAbsolutePath());None of these errors appears to be fatal, i can still use the doco object and extract the information i require, but i want to understand where the errors are coming from. There must be a parser setting or sumthing i've missed somewhere.
    Can anyone help?
    Any ideas/surgestions/critique welcome.
    Tom

    When we are parsing this xml: "<CustomerInfo><VCID/>77888</CustomerInfo>".
    See comments in following code.
    Element docEle = d.getDocumentElement(); // Returns "CustomerInfo" element node.
    NodeList childNodes2 = docEle.getChildNodes(); // Returns two nodes: <VCID/> element node and 77888 text node.
    Node item4 = childNodes2.item( 0 ); // First node (element node) of the "CustomerInfo" tag. <VCID/>
    Node item5 = childNodes2.item( 1 ); // Second node (text node) of the "CustomerInfo" tag is 77888. Look this text is not child of VCID, it's second child node of "CustomerInfo" tag.
    NodeList childNodes3 = item4.getChildNodes(); // Returns null because <VCID/> node is empty.
    String nodeValue = item5.getNodeValue(); // Returns 77888 ( text node ).               Regards,
    S&#322;awomir Wojtasiak

Maybe you are looking for

  • Why is the flash player (plugin) getting slower?

    I just upgraded from the current release of 10.1 to a beta that I downloaded last December. A vast improvement!! The platform is Windows XP SP/3, the host is an Acer AR1600 (Intel Atom 230 + nVidia ION LE). The content provider is Hulu. The video is

  • Adobe Connect 8: Recording Pausing after 32 Minutes

    Hi, We have a Recording which references a PPT file from user's Content area. There are 71 Slides in the PPT. They played fine in the live event. But in the Recording the playback pauses after minute 32. No amount of going forward or backward can mak

  • Viewable locked pdf files

    reposting because I get a notification : It appears you're not allowed to view what you requested. You might contact your administrator if you think this is a mistake Im reposting this because someone obviously deleted the original post for some odd

  • OAF Parameterized Popup Issue (12.1.3)

    I am unable to access the parameters set by the parameterized popup within the base page PR method.  The popup page controller PR method has no problem accessing the parameters but I need to access them in the base page controller PR method as I beli

  • Suspicious file that has appeared on Macintosh HD

    Hey there, I've just opened 'Macintosh HD' to find a file called 'gmon.out' sitting there in the main directory. I was wondering whether anyone has come across this before and has any advice about what I should do with it. I have linked a screenshot