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.
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.
nullThis 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 -
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,
JanConsider 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? -
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
BunnyI 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 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.
TomWhen 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ławomir Wojtasiak -
ORA-29534 when loading Java XML Parser
Hi. I'm trying to install the Java and PL/SQL parsers into an 8i database, following the instructions in Steve Muench's O'Reilly book.
It looks like loadjava is loading the classes, but when it tries to resolve them I get the ORA-29534 error for each class. We're running 8.1.5 on the database, and the parser is 2.0.10 (I think - I downloaded it from OTN today, and I'm installing the Java parser from the Java XDK not the PL/SQL XDK).
Any help is appreciated.
Thanks in advance,
Craig Drabik
Lead Programmer/Analyst
Univeristy at Buffalo
[email protected]That's 2.0.2.10 not 2.0.10
-Craig
null -
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 RobbinsCan you paste your java code here ? I assume, you must have tried type-casting.
-
XmlNode.selectSingleNode(String pattern) - Java xml parser v.2
Hi,
I cannot understand how this method is supposed to be used :(
I use it so:
xmlNode.selectSingleNode("element[@name='some_name']") and I don't get a node as a result although I know such node exists. What the format of the pattern argument is supposed to be? The documentation is quite poor on this topic :(Your syntax is 100% correct.
If the current node that your "xmlNode" variable refers to is the <XXXX> element below:
<XXX>
<element name="some_name"/>
</XXX>
Then xmlNode.selectSingleNode("element[@name='some_name']") will select the <element> element child. -
Hi,
I would like to distribute the Java XML parser with my product (which does not include an Oracle database).
Do you have an idea, if this can be done ?
The license agreement is "for a single developer". My local reseller has no clue if I can use for free, or how much does it cost.
Any idea ?Free runtime redistribution. visit the latest download page for the production version to see the verbage.
-
Create document with PL/SQL xml parser
Hello,
I'm trying to create a document with PL/SQL package xmldom on 8.1.7 and write to a file.
The problem is that my file is empty when it's created.
Can anyone send me an example of this simple problem or fullfill my example so it's works.
As you understand I'm new in using XML. :)
My example is:
declare
doc xmldom.DOMDocument;
n xmldom.DOMNode;
e xmldom.domelement;
t xmldom.domtext;
begin
doc := xmldom.newdomdocument;
t := xmldom.createtextnode(doc, 'ROOT');
n := xmldom.makenode(t);
doc := xmldom.makedocument(n);
xmldom.writetofile(doc, 'd:\orant\xdk\plsql\demo\test.xml');
end;
Regards
HekanYour problem may be memory for the JavaVM. Remember, the PL/SQL
parser uses the Java XML Parser APIs which run in a VM instance.
Are you running Oracle 8i? If you are you can access our Java
XML parser loaded in 8i's VM directly from your PL/SQL code.
That is in fact how our PL/SQL Parser does it.
Finally, we have no experience loading other XML Parsers into
Oracle.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Premal Mehta (guest) wrote:
: Hi,
: I asked about his a few days back. Pl/SQL parser does not
work
: for XML files of size greater then 500Kb. You replied saying
: that there were no such problem.
: However whenever I try, either I get some exception or
Pl/SQL
: crashes due to memory error. I am clueless. Is there some
: setting that I can do to get away with the problem? Please
: guide...
: Also, tell me about the alternatives.
: Can I write code in Java and load these class filesin Oracle
: and then reference these classes from Pl/SQL code. Can I load
: any other parser for Java in Oracle.
: Looking forward for help...
: Premal.
null -
XML parser working with MediaWiki API
I have a little helper for a MediaWiki server. It intended to work the following way:
Client side [GWT] ←rpc→ Server side [GWT] JWBF ←http→ MediaWiki API+
GWT - Google Web Toolkit 2.0.4
JWBF - Java Wiki Bot Framework 1.3.2
MediaWiki 1.16 XML
JDK1.6.0_21
GWT sends and receive utf-8 data between client and server well. But the second half fails to work with its own xml traffic.
JWBF gets the xml file via HTTP (log4j logging):
[DefaultClientConnection ] Receiving response: HTTP/1.1 200 OK
[headers ] << HTTP/1.1 200 OK
[headers ] << Date: Thu, 09 Sep 2010 17:36:34 GMT
[headers ] << Server: Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8e PHP/5.2.4
[headers ] << X-Powered-By: PHP/5.2.4
[headers ] << Cache-Control: private
[headers ] << Vary: Accept-Encoding
[headers ] << Content-Length: 1177
[headers ] << Keep-Alive: timeout=5, max=95
[headers ] << Connection: Keep-Alive
[headers ] << Content-Type: text/xml; charset=utf-8
[DefaultRequestDirector ] Connection can be kept alive for 5000 ms
[wire ] << "<?xml version="1.0"?><api><query><pages><page pageid="103" ns="0" title="Bronenosets Potyomkin"><revisions><rev revid="503" parentid="502" user="Anton" timestamp="2010-09-09T09:26:34Z" comment="Undo revision 502" xml:space="preserve">[\n]"
[wire ] << "The Battleship Potemkin ([0xd0][0x91][0xd1][0x80][0xd0][0xbe][0xd0][0xbd][0xd0][0xb5][0xd0][0xbd][0xd0][0xbe][0xd1][0x81][0xd0][0xb5][0xd1][0x86] [0xc2][0xab][0xd0][0x9f][0xd0][0xbe][0xd1][0x82][0xd1][0x91][0xd0][0xbc][0xd0][0xba][0xd0][0xb8][0xd0][0xbd][0xc2][0xbb]) is a film.[\n]"
[wire ] << "[\n]"
[wire ] << "The Odessa Steps sequence editing.</rev></revisions></page></pages></query><query-continue><revisions rvstartid="502" /></query-continue></api>"
[SingleClientConnManager ] Releasing connection org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter@dfb098And Java XML parser fails to understand this xml and returns the string as it was ISO-8859-1. After the xml bases a class with SAXBuilder, name in brackets, the one within "rev" element, becomes:
ÐÑоненоÑ�ÐµÑ Â«ÐоÑÑмкин»while it should be
Броненосец «Потёмкин»The whole system (Apache, MediaWiki plus JWBF, GWT, client HTML) is set to utf-8, but Java parser (default settings) still does not agree.
Dear specialists, where could be the error?The problem's been found thanks to DrClap ( [XML converted to string - encoding lost?|http://forums.sun.com/thread.jspa?threadID=610257] ).
JWBF read the HTTP stream using system's default encoding:
+Line 216 in jwbf-1.3.2-262\src\net\sourceforge\jwbf\core\actions\HttpActionClient.java+
BufferedReader br = new BufferedReader(new InputStreamReader(res.getEntity().getContent()));From here the whole chain got the wrongly encoded string, including XML parser.
So, the solution is to define the encoding explicitly:
BufferedReader br = new BufferedReader(new InputStreamReader(res.getEntity().getContent(), "UTF-8"));Thank to the community. -
XML parser for C 2.0.2
I would like to get the parser for C 2.2 for NT from somewhere. On the product listing on technet it is liste, but when I go to the download page, I can only find version 2.0.1!! Where can I find the latest version please?
nullI never received a reply to my last question about the bug being fixed in 2.0.3. Now we've tried 2.0.4 and are still not able to parse XML files with our dtd using the XML Parser for C unless we use the 2.0.0 version.
The results we get using the xml command provided with 2.0.4 are as follows:
xml -w -x [URL=http://www.nlm.nih.gov/databases/dtd/testora.xml]http://www.nlm.nih.gov/databases/dtd/testora.xml[/URL]
StartDocument
Message 9 not found; product=ORACORE; facility=LPX
Message 9 not found; product=ORACORE; facility=LPX
Message 10 not found; product=ORACORE; facility=LPX
Message 10 not found; product=ORACORE; facility=LPX
LPX-00208: expected "<![DOCTYPE" at the start of a tagWe're not sure why the messages are not coming out, but the end result (LPX-00208) is the same. This document parses with the Oracle Java XML parser and with other parsers. Unfortunately, for our task, we need to use the C XML parser. When will this bug be fixed?
Can someone from the Oracle xmlteam please respond to this!
Thanks! -- John.
null -
XML parser for C 2.0.2 - LPX-00208
We are getting the following error when using the 2.0.2 XML parser for C:
StartDocument
In line 3 of /u03/dnelson/testora.xml:
In line 31 of http://www.nlm.nih.gov/databases/dtd/nlmmedline_000509.dtd:
In line 25 of medlinecitation_000509.dtd [parameter entity "MedlineCitation"]:
In line 1 of nlmcommon_000509.dtd [parameter entity "NlmCommon"]:
LPX-00208: expected "<![DOCTYPE" at the start of a tag
Parse failed, code 208
Our xml file parses ok with the 2.0.0 parser, but we wish to upgrade in order to be able to use the url dtd reference capability of the 2.0.2 parser. Our document also validates ok with other parsers. Why are we getting this error?
We're using the sax parser. A sample XML that produces the above error is at: [URL=http://www.nlm.nih.gov/databases/dtd/testora.xml]http://www.nlm.nih.gov/databases/dtd/testora.xml
Thanks!
John Butler
National Library of MedicineI never received a reply to my last question about the bug being fixed in 2.0.3. Now we've tried 2.0.4 and are still not able to parse XML files with our dtd using the XML Parser for C unless we use the 2.0.0 version.
The results we get using the xml command provided with 2.0.4 are as follows:
xml -w -x [URL=http://www.nlm.nih.gov/databases/dtd/testora.xml]http://www.nlm.nih.gov/databases/dtd/testora.xml[/URL]
StartDocument
Message 9 not found; product=ORACORE; facility=LPX
Message 9 not found; product=ORACORE; facility=LPX
Message 10 not found; product=ORACORE; facility=LPX
Message 10 not found; product=ORACORE; facility=LPX
LPX-00208: expected "<![DOCTYPE" at the start of a tagWe're not sure why the messages are not coming out, but the end result (LPX-00208) is the same. This document parses with the Oracle Java XML parser and with other parsers. Unfortunately, for our task, we need to use the C XML parser. When will this bug be fixed?
Can someone from the Oracle xmlteam please respond to this!
Thanks! -- John.
null -
Hi,
I am beginning work on a new application in a week or so, and part of it includes parsing data from an XML file. I have been looking at the options for XML integration with Java and wondered if anyone could give me some recommendations?
Apache have http://xml.apache.org/xerces2-j/index.html - their xerces java XML parser. Sun have http://java.sun.com/xml/xml_jaxp.html - JAXP. I reckon the JAXP implementation would be preferable, but does anyone have any recommendations? I am using the Sun JDK 1.3, the XML parsing will be server-side, speed is an issue as is complexity. I am afraid I have been given no indication of the size or shape of the XML files.
Thanks in advance,
Ciaran.Since you don't have much idea of the problem space, I'd recommend experimenting with them yourself. Advice has a short shelf-life, these things are changing rapidly.
Maybe you are looking for
-
Instance does not open, because of corrupted datafile
Hi I am running 10gR2. For a test I have corrupted the header of an test datafile of a non system tablespace when instance was closed. Now when I started the instance it does not open with an alert entry Errors in file c:\oracle\oracle\product\10.2.0
-
Check battery error with new and old batteries.
I came back from vacation last month, and the battery on my late 2006 Macbook would not charge. The Apple store said the magsafe connector was bad, and replaced it for $98. The next day I had the same problem, and when I took it back they said that n
-
Performance Analysis in Oracle Enterprise Manger console..
Hi, Following is a findings of performance analysis section of Oracle Enterprise Manager. SQL statements consuming significant database time were found. ====== While clicking on above link system opens another page and it should following details. Ac
-
!!! I want source codes about Calculator. !!!
If you have, please send me... [email protected] Thank you
-
Hello, we are trying to export a content server, according to SAP note 962019. First we are trying with a QA-system. There is not much load on it, DB size is about 200GB. What makes me worry is the speed of about 2GB/h, or about 155GB since Friday. I