Character skips during XML Parsing
Hi,
I am SAX Parser for parsing XML files.
During parsing some times it skips the character.
e.g. if date come as 20091201 then it takes it as 091201.
During parsing in character I am storing this date into string variable
please do the helpful.
Thanks
Plain old programming, basic ordinary logic. If you want to collect all character data for an element:
(1) at the start of the element create an empty StringBuilder
(2) for each chunk of character data, append that to the StringBuilder (there's a convenient form of the append method whose parameters match the parameters of the characters method)
(3) at the end of the element, the StringBuilder contains all of the character data.
Similar Messages
-
Memory Utilization during XML Parsing
We have a slow response time during XML Parsing.
Description of the problem:
During XML parsing, memory is used and discarded so frequently that garbage collection
is occurring multiple times per minute, impacting performance. In order to better
understand the source of the memory usage issue, we used JProbe Memory Debugger.
JProbe Memory Debugger was run in Aggregate mode in order to determine which classes
were using the most total or aggregate memory (the sum of the memory required
to instantiate not just a given object, but all the objects it uses.) The result
was that weblogic.apache. xerces.impl.xs.dom.DocumentImpl and weblogic.apache.xerces.jaxp
comprise 23.8% and 15.4%, respectively, of total memory on a heap of 121MB. In
additional tests, the larger the heap, the greater these percentages were.
This results in slow response time.
The following are the details of software and Hardware configurations used:
Server: weblogic 8.1
OS: Solaris 8
System Configuration: Sun Microsystems sun4u Sun Fire 6800
System clock frequency: 150 MHz
Memory size: 8192 Megabytes
Please let me know if there is any work around or patches available.We have a slow response time during XML Parsing.
Description of the problem:
During XML parsing, memory is used and discarded so frequently that garbage collection
is occurring multiple times per minute, impacting performance. In order to better
understand the source of the memory usage issue, we used JProbe Memory Debugger.
JProbe Memory Debugger was run in Aggregate mode in order to determine which classes
were using the most total or aggregate memory (the sum of the memory required
to instantiate not just a given object, but all the objects it uses.) The result
was that weblogic.apache. xerces.impl.xs.dom.DocumentImpl and weblogic.apache.xerces.jaxp
comprise 23.8% and 15.4%, respectively, of total memory on a heap of 121MB. In
additional tests, the larger the heap, the greater these percentages were.
This results in slow response time.
The following are the details of software and Hardware configurations used:
Server: weblogic 8.1
OS: Solaris 8
System Configuration: Sun Microsystems sun4u Sun Fire 6800
System clock frequency: 150 MHz
Memory size: 8192 Megabytes
Please let me know if there is any work around or patches available. -
Memory Utilization during XML Parsing - Response time is high
Slow response time while xml parsing is done.
Description of the problem:
During XML parsing, memory is used and discarded so frequently that garbage collection
is occurring multiple times per minute, impacting performance. In order to better
understand the source of the memory usage issue, we used JProbe Memory Debugger.
JProbe Memory Debugger was run in Aggregate mode in order to determine which classes
were using the most total or aggregate memory (the sum of the memory required
to instantiate not just a given object, but all the objects it uses.) The result
was that weblogic.apache. xerces.impl.xs.dom.DocumentImpl and weblogic.apache.xerces.jaxp
comprise 23.8% and 15.4%, respectively, of total memory on a heap of 121MB. In
additional tests, the larger the heap, the greater these percentages were.
This results in slow response time.
The following are the details of software and Hardware configurations used:
Server: weblogic 8.1
OS: Solaris 8
System Configuration: Sun Microsystems sun4u Sun Fire 6800
System clock frequency: 150 MHz
Memory size: 8192 Megabytes"Kris" <[email protected]> wrote in message news:40f2fcda$1@mktnews1...
Sorry, I overlooked it.
yes we do have 8 GB RAM. And as far as xml usage, we are parsing the xml to DOM
(including validation) and then applying transformation. But its the parsing stuff
which is eating the memory.1. Can you run JProbe to find out real CPU utilization/bottlenecks?
2. Apache Xerses implementation that is used in weblogic has a design
flaw that results in serialization of memory allocation by the transformer,
that makes it impossible to use for intense multithreaded transformations.
Consider using other transformers.
Regards,
Slava Imeshev
>
>
"Slava Imeshev" <[email protected]> wrote:
Please answer my questions.
Regards,
Slava Imeshev
"Krisna" <[email protected]> wrote in message news:40f299ae$1@mktnews1...
Thanks Slava for youe response. Coming back to response time, thisprocess is part
of a big task. So i cant really tell what response time i can allocatejust for
this piece alone. Might be, roughly it should be less than 0.4 seconds.what the
major concenr is the memory utilization by these packages. So whatmakes it to
use this kind of memory and whether its a known issue ?
"Slava Imeshev" <[email protected]> wrote:
"kris" <[email protected]> wrote in message news:40eaddce$1@mktnews1...
Slow response time while xml parsing is done.
Description of the problem:
During XML parsing, memory is used and discarded so frequently thatgarbage collection
is occurring multiple times per minute, impacting performance. In
order
to better
understand the source of the memory usage issue, we used JProbe
Memory
Debugger.
JProbe Memory Debugger was run in Aggregate mode in order to determinewhich classes
were using the most total or aggregate memory (the sum of the memoryrequired
to instantiate not just a given object, but all the objects it uses.)The result
was that weblogic.apache. xerces.impl.xs.dom.DocumentImpl and weblogic.apache.xerces.jaxp
comprise 23.8% and 15.4%, respectively, of total memory on a heap
of
121MB. In
additional tests, the larger the heap, the greater these percentageswere.
Large heap means longer garbage collections. Anyway, DOM is very heavy
on memory and you can not escape it. What's is your usage patternfor
XML
processing? Do you use XSL?
This results in slow response time.What do you consider as acceptable/inacceptable responce time?
The following are the details of software and Hardware configurationsused:
Server: weblogic 8.1
OS: Solaris 8
System Configuration: Sun Microsystems sun4u Sun Fire 6800
System clock frequency: 150 MHz
Memory size: 8192 MegabytesDoes this mean you got 8GB RAM on 150Mhz box?
Regards,
Slava Imeshev -
Error during XML Parser Sample building.
I tried to build your sample for XML Parser for C++ v.2 for Solaris.
I had some errors :
c++ -o DOMSample -I../include DOMSample.cpp -L../lib -lxml8 -lcore8 -lnls8 -lcore8 -lnls8 -lcore8 -lnsl -lsocket
Undefined first referenced
symbol in file
Node::getFirstChild void) /var/tmp/ccxhDPf2.o
Node::getValue(void) /var/tmp/ccxhDPf2.o
Node::hasChildNodes(void) /var/tmp/ccxhDPf2.o
Node::getChildNode(unsigned int) /var/tmp/ccxhDPf2.o
Node::getName(void) /var/tmp/ccxhDPf2.o
Node::numChildNodes(void) /var/tmp/ccxhDPf2.o
Node::getType(void) /var/tmp/ccxhDPf2.o
ld: fatal: Symbol referencing errors. No output written to DOMSample
collect2: ld returned 1 exit status
make: *** [DOMSample] Error 1
I use Solaris version 2.7 and c++ (gcc)version 2.95.
I tried with the -G compilation option.(for comptability with other compilers.
It compiled but the executable doesnot run.
Please, could you give the right compilation options.
nullI think url in XML is creating problem here.
<FileLocator
url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=PubMed&term=23-95-0[ECNO]+OR+"~"[MH]">MEDLINE</FileLocator>
Is there any way to parse this XML using <fx:XML/> ??
Thanks. -
hi,
i need to parse an xml file.
when i used an xml file of encoding type encoding="UTF-8", i could parse the file with the following syntax..
DocumentBuilder docBuilder = new DocumentBUilder();
Document doc = docBuilder.parse( path of the file name );
when i used an xml file of encoding type encoding="UTF-16" and encoding="ISO..", i could not parse the file with the above syntax..
i got the following exception
Wrong XML file structure: Character conversion error: "UTF-8 encoding of character 0x001acba4 can't be converted to Unicode." (line number may be too low).
java.lang.NullPointerException
at packageName.XMLParse.main(XMLParse.java:48)
Exception in thread "main"
Thanks in advance...hi,
i need to parse an xml file.
when i used an xml file of encoding type encoding="UTF-8", i could parse the file with the following syntax..
DocumentBuilder docBuilder = new DocumentBUilder();
Document doc = docBuilder.parse( path of the file name );
when i used an xml file of encoding type encoding="UTF-16" and encoding="ISO..", i could not parse the file with the above syntax..
i got the following exception
Wrong XML file structure: Character conversion error: "UTF-8 encoding of character 0x001acba4 can't be converted to Unicode." (line number may be too low).
java.lang.NullPointerException
at packageName.XMLParse.main(XMLParse.java:48)
Exception in thread "main"
Thanks in advance... -
OS: Oracle Database 11.1.0.7.0 on Windows XP
Analytic Workspace Manager: 11.1.0.7.0A
When expanding the Analytic Workspace in AWM I am getting the error below. I was able to create and populate the dimensions/cubes using XML Template and did not come across any errors during that process.
I tried deleting the schema and recreated the AW but still get the same error. Are there any solutions to fix this problem?
Errors have occurred during xml parse
<Line 105, Column 22>: Encountered "(" at line 1, column 175.
Was expecting one of:
"DIMENSION" ...
at oracle.olapi.xml.TagHandler.createRootException(Unknown Source)
at oracle.olapi.xml.TagHandler.getRootException(Unknown Source)
at oracle.olapi.xml.TagHandler.reportException(Unknown Source)
at oracle.olapi.xml.TagHandler.processException(Unknown Source)
at oracle.olapi.metadata.BaseMetadataXMLReader.resolveDeferredProperties(Unknown Source)
at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
at oracle.olapi.xml.TagHandler.endElement(Unknown Source)
at org.xml.sax.helpers.ParserAdapter.endElement(ParserAdapter.java:626)
at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:211)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1326)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:340)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:307)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:212)
at org.xml.sax.helpers.ParserAdapter.parse(ParserAdapter.java:405)
at oracle.olapi.xml.XMLProcessor.parse(Unknown Source)
at oracle.olapi.metadata.MetadataFetcher.processXML(Unknown Source)
at oracle.olapi.metadata.MetadataFetcher.fetchBaseMetadataObjects(Unknown Source)
at oracle.olapi.metadata.BaseMetadataProvider.fetchMetadataObjects(Unknown Source)
at oracle.olapi.metadata.MetadataListProperty.getObjects(Unknown Source)
at oracle.olapi.metadata.BaseMetadataObjectState.getPropertyListValues(Unknown Source)
at oracle.olapi.metadata.BaseMetadataObject.getPropertyListValues(Unknown Source)
at oracle.olapi.metadata.mdm.MdmSchema.getCubes(Unknown Source)
at oracle.olapi.metadata.deployment.AW.getCubes(Unknown Source)
at oracle.olapi.metadata.deployment.AW.getPersistentLanguages(Unknown Source)
at oracle.olap.awm.dataobject.aw.WorkspaceDO.getULanguages(Unknown Source)
at oracle.olap.awm.dataobject.olapi.ULanguageDO.<init>(Unknown Source)
at oracle.olap.awm.navigator.node.WorkspaceNode.getUnifiedChildren(Unknown Source)
at oracle.olap.awm.navigator.node.WorkspaceNode.getChildren(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNodeModel.refreshData(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNodeModel.dTreeItemExpanding(Unknown Source)
at oracle.bali.ewt.dTree.DTreeDeferredParent.__fireExpansionChanging(Unknown Source)
at oracle.bali.ewt.dTree.DTreeDeferredParent.setExpanded(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNode.expandHelper(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNode.access$400(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNode$ExpansionThread.run(Unknown Source)I am also experiencing this error when attaching an AW:
Errors have occurred during xml parse
<Line 43, Column 47>: Error during parse: "java.lang.NullPointerException"
<Line 159, Column 19>: Error during parse: "Errors have occurred during xml parse
<Line 41, Column 34>: Error during parse: "java.lang.NullPointerException"
<Line 44, Column 55>: Error during parse: "java.lang.NullPointerException"
<Line 50, Column 55>: Error during parse: "java.lang.NullPointerException"
<Line 60, Column 34>: Error during parse: "java.lang.NullPointerException"
<Line 63, Column 55>: Error during parse: "java.lang.NullPointerException"
<Line 69, Column 55>: Error during parse: "java.lang.NullPointerException"
<Line 79, Column 34>: Error during parse: "java.lang.NullPointerException"
<Line 82, Column 55>: Error during parse: "java.lang.NullPointerException"
<Line 88, Column 55>: Error during parse: "java.lang.NullPointerException"
<Line 98, Column 34>: Error during parse: "java.lang.NullPointerException"
<Line 101, Column 55>: Error during parse: "java.lang.NullPointerException"
<Line 107, Column 55>: Error during parse: "java.lang.NullPointerException""
<Line 396, Column 47>: Error during parse: "java.lang.NullPointerException"
<Line 694, Column 47>: Error during parse: "java.lang.NullPointerException"
at oracle.olapi.xml.TagHandler.createRootException(Unknown Source)
at oracle.olapi.xml.TagHandler.getRootException(Unknown Source)
at oracle.olapi.xml.TagHandler.reportException(Unknown Source)
at oracle.olapi.xml.TagHandler.processException(Unknown Source)
at oracle.olapi.metadata.BaseMetadataXMLReader.resolveDeferredProperties(Unknown Source)
at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
at oracle.olapi.xml.TagHandler.endElement(Unknown Source)
at org.xml.sax.helpers.ParserAdapter.endElement(Unknown Source)
at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:211)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1326)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:340)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:307)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:212)
at org.xml.sax.helpers.ParserAdapter.parse(Unknown Source)
at oracle.olapi.xml.XMLProcessor.parse(Unknown Source)
at oracle.olapi.metadata.MetadataFetcher.processXML(Unknown Source)
at oracle.olapi.metadata.MetadataFetcher.fetchBaseMetadataObjects(Unknown Source)
at oracle.olapi.metadata.BaseMetadataProvider.fetchMetadataObjects(Unknown Source)
at oracle.olapi.metadata.MetadataListProperty.getObjects(Unknown Source)
at oracle.olapi.metadata.BaseMetadataObjectState.getPropertyListValues(Unknown Source)
at oracle.olapi.metadata.BaseMetadataObject.getPropertyListValues(Unknown Source)
at oracle.olapi.metadata.mdm.MdmSchema.getCubes(Unknown Source)
at oracle.olapi.metadata.deployment.AW.getCubes(Unknown Source)
at oracle.olapi.metadata.deployment.AW.getPersistentLanguages(Unknown Source)
at oracle.olap.awm.dataobject.aw.WorkspaceDO.getULanguages(Unknown Source)
at oracle.olap.awm.dataobject.olapi.ULanguageDO.<init>(Unknown Source)
at oracle.olap.awm.navigator.node.WorkspaceNode.getUnifiedChildren(Unknown Source)
at oracle.olap.awm.navigator.node.WorkspaceNode.getChildren(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNodeModel.refreshData(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNodeModel.dTreeItemExpanding(Unknown Source)
at oracle.bali.ewt.dTree.DTreeDeferredParent.__fireExpansionChanging(Unknown Source)
at oracle.bali.ewt.dTree.DTreeDeferredParent.setExpanded(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNode.expandHelper(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNode.access$400(Unknown Source)
at oracle.olap.awm.navigator.node.BaseNode$ExpansionThread.run(Unknown Source)
This is on DB 11.1.0.7.0 with CPU 25 (9392335) using AWM 11.1.0.7.0B with all components VALID
Oracle Enterprise Manager 11.1.0.7.0 VALID
OWB 11.1.0.7.0 VALID
Oracle Application Express 3.0.1.00.12 VALID
Oracle Ultra Search 11.1.0.7.0 VALID
OLAP Catalog 11.1.0.7.0 VALID
Spatial 11.1.0.7.0 VALID
Oracle Multimedia 11.1.0.7.0 VALID
Oracle XML Database 11.1.0.7.0 VALID
Oracle Text 11.1.0.7.0 VALID
Oracle Expression Filter 11.1.0.7.0 VALID
Oracle Rules Manager 11.1.0.7.0 VALID
Oracle Workspace Manager 11.1.0.7.0 VALID
Oracle Database Catalog Views 11.1.0.7.0 VALID
Oracle Database Packages and Types 11.1.0.7.0 VALID
JServer JAVA Virtual Machine 11.1.0.7.0 VALID
Oracle XDK 11.1.0.7.0 VALID
Oracle Database Java Packages 11.1.0.7.0 VALID
OLAP Analytic Workspace 11.1.0.7.0 VALID
Oracle OLAP API 11.1.0.7.0 VALID -
Deserialization error: XML parsing error: Illegal XML character
Hi All,
Anybody knows what caused this? This error occured at the client side when the server returned an object that contains other objects to client during a jaxrpc call. It worked before, something is definitely changed, I reversed my changes but still the same.
Please help, thanx a lot.
[java] java.rmi.RemoteException: Runtime exception; nested exception is:
[java] deserialization error: deserialization error: deserialization error: XML parsing error: com.sun.xml.rpc.sp.ParseException:2: Illegal XML character:
[java] at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:234)
[java] at com.ummq.ME_Stub.getMsg(MsgExpertIF_Stub.java:1333)
[java] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
[java] at javax.swing.AbstractButton$ForwardActionEvents.actionPerforme
d(AbstractButton.java:1817)
[java] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
[java] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
[java] at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
[java] at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1109)
[java] at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mous
eReleased(BasicMenuItemUI.java:943)
[java] at java.awt.Component.processMouseEvent(Component.java:5093)
[java] at java.awt.Component.processEvent(Component.java:4890)
[java] at java.awt.Container.processEvent(Container.java:1566)
[java] at java.awt.Component.dispatchEventImpl(Component.java:3598)
[java] at java.awt.Container.dispatchEventImpl(Container.java:1623)
[java] at java.awt.Component.dispatchEvent(Component.java:3439)
[java] at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
[java] at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
[java] at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
[java] at java.awt.Container.dispatchEventImpl(Container.java:1609)
[java] at java.awt.Window.dispatchEventImpl(Window.java:1585)
[java] at java.awt.Component.dispatchEvent(Component.java:3439)
[java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
[java] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
[java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
[java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
[java] Caused by: deserialization error: deserialization error: deserialization error: XML parsing error: com.sun.xml.rpc.sp.ParseException:2: Illegal XML character:
[java] at com.sun.xml.rpc.encoding.SOAPDeserializationContext.deseriali
zeMultiRefObjects(SOAPDeserializationContext.java:65)
[java] before getMsg
[java] at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:175)
[java] ... 30 more
[java] java.rmi.RemoteException: Runtime exception; nested exception is:
[java] deserialization error: deserialization error: deserialization error: XML parsing error: com.sun.xml.rpc.sp.ParseException:2: Illegal XML character:
[java] at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:234)
[java] at javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1161)
[java] at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1218)
[java] at javax.swing.JComboBox.contentsChanged(JComboBox.java:1265)
[java] at javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:100)
[java] at javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.java:88)
[java] at javax.swing.JComboBox.setSelectedItem(JComboBox.java:551)
[java] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
[java] at javax.swing.AbstractButton$ForwardActionEvents.actionPerforme
d(AbstractButton.java:1817)
[java] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
[java] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
[java] at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
[java] at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1109)
[java] at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mous
eReleased(BasicMenuItemUI.java:943)
[java] at java.awt.Component.processMouseEvent(Component.java:5093)
[java] at java.awt.Component.processEvent(Component.java:4890)
[java] at java.awt.Container.processEvent(Container.java:1566)
[java] at java.awt.Component.dispatchEventImpl(Component.java:3598)
[java] at java.awt.Container.dispatchEventImpl(Container.java:1623)
[java] at java.awt.Component.dispatchEvent(Component.java:3439)
[java] at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
[java] at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
[java] at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
[java] at java.awt.Container.dispatchEventImpl(Container.java:1609)
[java] at java.awt.Window.dispatchEventImpl(Window.java:1585)
[java] at java.awt.Component.dispatchEvent(Component.java:3439)
[java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
[java] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
[java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
[java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
[java] Caused by: deserialization error: deserialization error: deserializa
tion error: XML parsing error: com.sun.xml.rpc.sp.ParseException:2: Illegal XML character:
[java] at com.sun.xml.rpc.encoding.SOAPDeserializationContext.deseriali
zeMultiRefObjects(SOAPDeserializationContext.java:65)
[java] at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:175)
[java] ... 39 moreWhat type of encoding are you using? Do you transform a string in an array of bytes or viceversa?
Marco -
XML parser not detecting character encoding
Hi,
I am using Jdeveloper 9.0.5 preview and the same problem is happening in our production AS 9.0.2 release.
The character encoding of an xml document is not correctly being detected by the oracle v2 parser even though the xml declaration correctly contains
<?xml version="1.0" encoding="ISO-8859-1" ?>
instead it treats the document as UTF8 encoding which is fine until a document comes along with an extended character which then causes a
java.io.UTFDataFormatException: Invalid UTF8 encoding.
at oracle.xml.parser.v2.XMLUTF8Reader.checkUTF8Byte(XMLUTF8Reader.java:160)
at oracle.xml.parser.v2.XMLUTF8Reader.readUTF8Char(XMLUTF8Reader.java:187)
at oracle.xml.parser.v2.XMLUTF8Reader.fillBuffer(XMLUTF8Reader.java:120)
at oracle.xml.parser.v2.XMLByteReader.saveBuffer(XMLByteReader.java:448)
at oracle.xml.parser.v2.XMLReader.fillBuffer(XMLReader.java:2023)
at oracle.xml.parser.v2.XMLReader.tryRead(XMLReader.java:972)
at oracle.xml.parser.v2.XMLReader.scanXMLDecl(XMLReader.java:2589)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:485)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:192)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:144)
as you can see it is explicitly casting the XMLUTF8Reader to perform the read.
I can get around this by hard coding the xml input stream to be processed by a reader
XMLSource = new StreamSource(new InputStreamReader(XMLInStream,"ISO-8859-1"));
however the manual documents that the character encoding is automatically picked up from the xml file and casting into a reader is not necessary, so I should be able to write
XMLSource = new StreamSource(XMLInStream)
Does anyone else experience this same problem?
having to hardcode the encoding causes my software to lose flexibility.
Jarrod Sharp.An XML document should be created with 'ISO-8859-1' encoding to be parsed as 'ISO-8859-1' encoding.
-
Hi all,
In my SQL Server 2012 Management Studio, I executed the following code:
CREATE TABLE Products(
sku INT Primary KEY,
product_desc VARCHAR(30));
INSERT INTO Products (sku, product_desc)
SELECT X.product.query('SKU').value('.', 'INT'),
X.product.query('Desc').value('.', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'H:\ZenProducts.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('Products/Product') AS X(product);
SELECT sku, product_desc
FROM Products;
I got the following message:
Msg 9455, Level 16, State 1, Line 5
XML parsing: line 3, character 12, illegal qualified name character
I have no ideas why the "product" in the statement "SELECT X.product.query('SKU').value('.','INT')" is not legal qualified name charcter!!!??? Please kindly help, advise and respond.
Thanks in advance,
Scott ChangHi Manish, Thanks for your response.
Here is a copy of my ZenProducts.xml:
<Products>
<Product>
<SKU>1<</SKU>
<Desc>Book</Desc>
</Product>
<Product>
<SKU>2<</SKU>
<Desc>DVD</Desc>
</Product>
<Product>
<SKU>3<</SKU>
<Desc>Video</Desc>
</Product>
I found the wrong "<<" in my xml file and changed it to the right "<" for the statement<SKU>1</sku>. I executed the corrected code and I got the following new message:
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'Products' in the database.
I don't know how to remove the old, existing the 'Products' object in the database and execute the corrected code again. Please kindly help, advise and tell me how to resolve this new problem.
Many Thanks,
Scott Chang
P. S. I played with another project to get the 'Products' object in my database before. Frankly, I don't know where the old 'Products' object and the database are. Please enlighten me in resolving this matter more clearly.
You welcome Scott, As Olaf mentioned in this post, there was already a table exists , so need to drop your Products table.
Apart from this, I guess either you did not pasted the full XML file or what, I needed to have the ( </Products>)closing tag in your XML file as follows.
<Products>
<Product>
<SKU>1</SKU>
<Desc>Book</Desc>
</Product>
<Product>
<SKU>2</SKU>
<Desc>DVD</Desc>
</Product>
<Product>
<SKU>3</SKU>
<Desc>Video</Desc>
</Product>
</Products>
You can use following script to drop if your
Products table is already existing.
if exists(select 1 from sys.tables where name ='Products')
drop table Products
CREATE TABLE Products(
sku INT Primary KEY,
product_desc VARCHAR(30));
INSERT INTO Products (sku, product_desc)
SELECT X.product.query('SKU').value('.', 'INT'),
X.product.query('Desc').value('.', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'H:\ZenProducts.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('Products/Product') AS X(product);
SELECT sku, product_desc
FROM Products;
Let us know if you face any other problem.
Thanks
Manish
Please click Mark as Answer if my post solved your problem and click
Vote as Helpful if this post was useful. -
Xml parsing error: invalid character
We started receving below error while opening PDF forms in the browser , its started happening from today for several users. They were using IE and Adobe Reader 10.1
Any one saw this error before?
xml parsing error: invalid character number (error code 14), line 3 , column 264 of file....We can see this issue only in Adobe Reader XI (11.0.01), X (10.1.5) And 9.5.3 in OS Win XP and 7.0. This happens only in IE. Fire Fox it works fine.
We rolled back to Adobe Reader 10.1.3 , works perfect. -
XI XML Parser: tag content with "'", single apostrophe: invalid character
Hi all,
we import XML-documents with the file adapter in a sender channel. everything works well.
But if one of the XML-tag contents contains a single apostrophe ( ' ), then the XML parser stops with an error "An invalid character was found inside an entity reference. ". The message can not be processed. If I test the message content in the mapping -> no error.
When the single apostrophe is dereferenced by an additional single apostrophe the XML-File can be processed.
Question: does anybody know how this can be handled because it is not very nice of SAP XI to send single apostrophes in outgoing messages but cannot handle it in incoming messages from other systems? special adapter settings?
Thank you very much
regards
Hanscheck bhavesh reply
Suppress Special Character
also check
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/9420 [original link is broken] [original link is broken] [original link is broken]
Implementing a Java Mapping in SAP PI to remove Escape Sequences from a file -
XML Parser - Character Encoding
Hi,
I am trying to parse a XML document containing Korean characters. Using XSL stylesheet to generate HTML output in Java Servlet.
How can i do to make it work?
I'm using WintNT with IIS - ServletExec3.1 for servlet engine.
Here's the error messages...
java.io.UTFDataFormatException: Invalid UTF8 encoding
at oracle.xml.parser.v2.XMLUTF8Reader.checkUTF8Byte(XMLUTF8Reader.java:65)
at oracle.xml.parser.v2.XMLUTF8Reader.readUTF8Char(XMLUTF8Reader.java:162)
at oracle.xml.parser.v2.XMLUTF8Reader.fillLastBuffer(XMLUTF8Reader.java:142)
at oracle.xml.parser.v2.XMLByteReader.fillByteBuffer(XMLByteReader.java:300)
at oracle.xml.parser.v2.XMLUTF8Reader.fillBuffer(XMLUTF8Reader.java:108)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:277)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:163)
Thanks...
TN
nullYes, I did.
I tried with:
1. encoding="EUC-KR"
2. encoding="IOS2022KR"
3. encoding="UTF-8"
4. and some ...
but it still return the same error.
Any ideas,
Thanks,
Tuan
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by oracle xml team:
Have you set your encoding in the header of xml file?<HR></BLOCKQUOTE>
null -
Error in parsing: SAX2 driver class com.sun.xml.parser not found
Hi I have this exception
Error in parsing: SAX2 driver class com.sun.xml.parser not found
when I try to run the examples from the book xml and java
I have added the following jar files to the class path that i have download form java.sun.com
xml.jar
xalan.jar
jaxp.jar
crimson.jar
Please can anyone tell me what is missing or wrong..the code must be right since written by oreilly... please have u any ideA
XMLReaderFactory.createXMLReader(
// "org.apache.xerces.parsers.SAXParser");
"com.sun.xml.parser");//
I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..to com.sun.xml.parser
THIS IS THE ALL CODE
import java.io.IOException;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.*;
* <b><code>SAXParserDemo</code></b> will take an XML file and parse it using SAX,
* displaying the callbacks in the parsing lifecycle.
* @author Brett McLaughlin
* @version 1.0
public class SAXParserDemo {
* <p>
* This parses the file, using registered SAX handlers, and output
* the events in the parsing process cycle.
* </p>
* @param uri <code>String</code> URI of file to parse.
public void performDemo(String uri) {
System.out.println("Parsing XML File: " + uri + "\n\n");
// Get instances of our handlers
ContentHandler contentHandler = new MyContentHandler();
ErrorHandler errorHandler = new MyErrorHandler();
try {
// Instantiate a parser
XMLReader parser =
XMLReaderFactory.createXMLReader(
// "org.apache.xerces.parsers.SAXParser");
"com.sun.xml.parser");// I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..
// Register the content handler
parser.setContentHandler(contentHandler);
// Register the error handler
parser.setErrorHandler(errorHandler);
// Parse the document
parser.parse(uri);
} catch (IOException e) {
System.out.println("Error reading URI: " + e.getMessage());
} catch (SAXException e) {
System.out.println("Error in parsing: " + e.getMessage());
* <p>
* This provides a command line entry point for this demo.
* </p>
public static void main(String[] args) {
// if (args.length != 1) {
// System.out.println("Usage: java SAXParserDemo [XML URI]");
// System.exit(0);
//String uri = args[0];
SAXParserDemo parserDemo = new SAXParserDemo();
parserDemo.performDemo("content.xml");
* <b><code>MyContentHandler</code></b> implements the SAX
* <code>ContentHandler</code> interface and defines callback
* behavior for the SAX callbacks associated with an XML
* document's content.
class MyContentHandler implements ContentHandler {
/** Hold onto the locator for location information */
private Locator locator;
* <p>
* Provide reference to <code>Locator</code> which provides
* information about where in a document callbacks occur.
* </p>
* @param locator <code>Locator</code> object tied to callback
* process
public void setDocumentLocator(Locator locator) {
System.out.println(" * setDocumentLocator() called");
// We save this for later use if desired.
this.locator = locator;
* <p>
* This indicates the start of a Document parse - this precedes
* all callbacks in all SAX Handlers with the sole exception
* of <code>{@link #setDocumentLocator}</code>.
* </p>
* @throws <code>SAXException</code> when things go wrong
public void startDocument() throws SAXException {
System.out.println("Parsing begins...");
* <p>
* This indicates the end of a Document parse - this occurs after
* all callbacks in all SAX Handlers.</code>.
* </p>
* @throws <code>SAXException</code> when things go wrong
public void endDocument() throws SAXException {
System.out.println("...Parsing ends.");
* <p>
* This will indicate that a processing instruction (other than
* the XML declaration) has been encountered.
* </p>
* @param target <code>String</code> target of PI
* @param data <code>String</code containing all data sent to the PI.
* This typically looks like one or more attribute value
* pairs.
* @throws <code>SAXException</code> when things go wrong
public void processingInstruction(String target, String data)
throws SAXException {
System.out.println("PI: Target:" + target + " and Data:" + data);
* <p>
* This will indicate the beginning of an XML Namespace prefix
* mapping. Although this typically occur within the root element
* of an XML document, it can occur at any point within the
* document. Note that a prefix mapping on an element triggers
* this callback <i>before</i> the callback for the actual element
* itself (<code>{@link #startElement}</code>) occurs.
* </p>
* @param prefix <code>String</code> prefix used for the namespace
* being reported
* @param uri <code>String</code> URI for the namespace
* being reported
* @throws <code>SAXException</code> when things go wrong
public void startPrefixMapping(String prefix, String uri) {
System.out.println("Mapping starts for prefix " + prefix +
" mapped to URI " + uri);
* <p>
* This indicates the end of a prefix mapping, when the namespace
* reported in a <code>{@link #startPrefixMapping}</code> callback
* is no longer available.
* </p>
* @param prefix <code>String</code> of namespace being reported
* @throws <code>SAXException</code> when things go wrong
public void endPrefixMapping(String prefix) {
System.out.println("Mapping ends for prefix " + prefix);
* <p>
* This reports the occurrence of an actual element. It will include
* the element's attributes, with the exception of XML vocabulary
* specific attributes, such as
* <code>xmlns:[namespace prefix]</code> and
* <code>xsi:schemaLocation</code>.
* </p>
* @param namespaceURI <code>String</code> namespace URI this element
* is associated with, or an empty
* <code>String</code>
* @param localName <code>String</code> name of element (with no
* namespace prefix, if one is present)
* @param rawName <code>String</code> XML 1.0 version of element name:
* [namespace prefix]:[localName]
* @param atts <code>Attributes</code> list for this element
* @throws <code>SAXException</code> when things go wrong
public void startElement(String namespaceURI, String localName,
String rawName, Attributes atts)
throws SAXException {
System.out.print("startElement: " + localName);
if (!namespaceURI.equals("")) {
System.out.println(" in namespace " + namespaceURI +
" (" + rawName + ")");
} else {
System.out.println(" has no associated namespace");
for (int i=0; i<atts.getLength(); i++)
System.out.println(" Attribute: " + atts.getLocalName(i) +
"=" + atts.getValue(i));
* <p>
* Indicates the end of an element
* (<code></[element name]></code>) is reached. Note that
* the parser does not distinguish between empty
* elements and non-empty elements, so this will occur uniformly.
* </p>
* @param namespaceURI <code>String</code> URI of namespace this
* element is associated with
* @param localName <code>String</code> name of element without prefix
* @param rawName <code>String</code> name of element in XML 1.0 form
* @throws <code>SAXException</code> when things go wrong
public void endElement(String namespaceURI, String localName,
String rawName)
throws SAXException {
System.out.println("endElement: " + localName + "\n");
* <p>
* This will report character data (within an element).
* </p>
* @param ch <code>char[]</code> character array with character data
* @param start <code>int</code> index in array where data starts.
* @param end <code>int</code> index in array where data ends.
* @throws <code>SAXException</code> when things go wrong
public void characters(char[] ch, int start, int end)
throws SAXException {
String s = new String(ch, start, end);
System.out.println("characters: " + s);
* <p>
* This will report whitespace that can be ignored in the
* originating document. This is typically only invoked when
* validation is ocurring in the parsing process.
* </p>
* @param ch <code>char[]</code> character array with character data
* @param start <code>int</code> index in array where data starts.
* @param end <code>int</code> index in array where data ends.
* @throws <code>SAXException</code> when things go wrong
public void ignorableWhitespace(char[] ch, int start, int end)
throws SAXException {
String s = new String(ch, start, end);
System.out.println("ignorableWhitespace: [" + s + "]");
* <p>
* This will report an entity that is skipped by the parser. This
* should only occur for non-validating parsers, and then is still
* implementation-dependent behavior.
* </p>
* @param name <code>String</code> name of entity being skipped
* @throws <code>SAXException</code> when things go wrong
public void skippedEntity(String name) throws SAXException {
System.out.println("Skipping entity " + name);
* <b><code>MyErrorHandler</code></b> implements the SAX
* <code>ErrorHandler</code> interface and defines callback
* behavior for the SAX callbacks associated with an XML
* document's errors.
class MyErrorHandler implements ErrorHandler {
* <p>
* This will report a warning that has occurred; this indicates
* that while no XML rules were "broken", something appears
* to be incorrect or missing.
* </p>
* @param exception <code>SAXParseException</code> that occurred.
* @throws <code>SAXException</code> when things go wrong
public void warning(SAXParseException exception)
throws SAXException {
System.out.println("**Parsing Warning**\n" +
" Line: " +
exception.getLineNumber() + "\n" +
" URI: " +
exception.getSystemId() + "\n" +
" Message: " +
exception.getMessage());
throw new SAXException("Warning encountered");
* <p>
* This will report an error that has occurred; this indicates
* that a rule was broken, typically in validation, but that
* parsing can reasonably continue.
* </p>
* @param exception <code>SAXParseException</code> that occurred.
* @throws <code>SAXException</code> when things go wrong
public void error(SAXParseException exception)
throws SAXException {
System.out.println("**Parsing Error**\n" +
" Line: " +
exception.getLineNumber() + "\n" +
" URI: " +
exception.getSystemId() + "\n" +
" Message: " +
exception.getMessage());
throw new SAXException("Error encountered");
* <p>
* This will report a fatal error that has occurred; this indicates
* that a rule has been broken that makes continued parsing either
* impossible or an almost certain waste of time.
* </p>
* @param exception <code>SAXParseException</code> that occurred.
* @throws <code>SAXException</code> when things go wrong
public void fatalError(SAXParseException exception)
throws SAXException {
System.out.println("**Parsing Fatal Error**\n" +
" Line: " +
exception.getLineNumber() + "\n" +
" URI: " +
exception.getSystemId() + "\n" +
" Message: " +
exception.getMessage());
throw new SAXException("Fatal Error encountered");I have seen this error when I'm executing inside one of the (j2ee sun reference implementation) server containers (either web or ejb). I believe its caused by "something" having previously loaded the "sax 1 driver class". In my case, I think the container or server is loading the sax parser from a jar that contains a sax 1 version. If you can, ensure that nothing is loading the sax 1 parser from another jar on your system. Verify that you are loading the sax parser from a jar containing the latest version so that you get the sax 2 compliant parser. Good luck!
-
Problem in XML Parsing via oracle procedure...
Hi,
I wrote one oracle procedure for xml parsing.
I have one valid xml file which has "encode UTF-8". The XML file contains some comments also. While we are parsing the xml file at that time it is not parse successfully and also it is not giving any error. After the following line it is skip rest of the codes(lines).
dbms_xmlparser.parseclob(l_parser, l_clob);
At the end of the xml file there are some comments which is like "<!-- abc --> ".
When I am changing the "encode UTF-8 to ISO-88596-1" & removing the comments which wrote on bottom of the file then its working fine, but the files which we are getting from the system is contains the encode UTF-8 and we don't want to preprocess on that xml files. Even if we will do that via shell script or perl script then it will be overhead to the system and in a single stroke our system will parse more than 5k xml files, so if we will do some preprocess on it, it will take some more time approx 1-2 minutes extra.
So, If someone knows any solution of this problem, then please guide & help me on this.
My xml file structure is as follows:-
<?xml version="1.0" encoding="UTF-8"?>
<mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
<child>
<child1>32.401 V5.5</child1>
<child2>ZoneGate</child2>
</child>
<mc>
<newid>
<id>12</id>
</newid>
<mindex>
<date>20111102180000</date>
<mt>abc1</mt>
<mt>abc2</mt>
<mvalue>
<r>val_1</r>
<r>val_2</r>
</mvalue>
</mindex>
</mc>
</mcd>
<!--
ALARM STATUS
morning 10
afternoon 14
evening 18
night 22
-->
<!--
PARAM:EID = 1
PARAM:GId = 3
PARAM:GSId = 0
--!>
And my oracle procedure is as follows:-
create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
-- Defining the variables
ecode NUMBER;
emesg VARCHAR2(200);
l_bfile BFILE;
l_clob CLOB;
l_dest_offset INTEGER:=1;
l_src_offset INTEGER:=1;
l_Char_set_id NUMBER := NLS_CHARSET_ID('UTF8');
l_lang_context INTEGER := dbms_lob.default_lang_ctx;
l_warning INTEGER;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl1 dbms_xmldom.DOMNodeList;
l_nl2 dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
node1 dbms_xmldom.DOMNode;
colid integer ; -- column id used for identifying which column it belongs.
l_xmltype XMLTYPE;
sub_xmltype XMLTYPE;
num_nodes number;
l_index PLS_INTEGER;
l_subIndex PLS_INTEGER;
starttime Date;
temp_datatime VARCHAR(25);
columnname varchar2(300);
columnvalue varchar2(300);
-- creating a Type which is a type of "test_hem" table RowType, which I created in SVN server
TYPE tab_type IS TABLE OF test_hem%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
-- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
l_bfile := BFileName('MY_FILES', xmlfile);
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
--dbms_lob.loadFromFile(dest_lob => l_clob,
-- src_lob => l_bfile,
-- amount => dbms_lob.getLength(l_bfile));
dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
dbms_lob.close(l_bfile);
-- make sure implicit date conversions are performed correctly
dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
dbms_output.put_line('Date format set');
-- Create a parser.
l_parser := dbms_xmlparser.newParser;
dbms_output.put_line('output 1');
-- Parse the document and create a new DOM document.
dbms_xmlparser.parseclob(l_parser, l_clob);
dbms_output.put_line(' passed parsing');
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_output.put_line(' passed getdocument');
-- Free resources associated with the CLOB and Parser now they are no longer needed.
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
-- Get a list of all the EMP nodes in the document using the XPATH syntax.
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
-- Loop through the list and create a new record in a tble collection
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
l_n := dbms_xmldom.item(l_nl1, cur_sel);
t_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
-- putting the state and vendorname into the table rowtype
dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
END LOOP;
-- getting the version and putting into the table rowtype
l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
-- selecting the nodes whose starting tag is "mindex"
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
-- checking the total number of nodes whose starting through "mi"
num_nodes := dbms_xmldom.getLength(l_nl1);
l_index := 1;
-- For loop to iterate the nodes.
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
-- whole current node is selected and storing into the node1 variable
node1 := dbms_xmldom.item(l_nl1, cur_sel);
-- setting the xmltype as AL32UTF8
l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
-- if selecting parent node containing the mt child node then only proceed else skip that parent node.
IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
-- fetch the datatime, convert it into to_date format and store it into table rowtype
temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
l_subIndex := 1;
while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
-- getting mt and corresponging mvalue/r values
dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
l_subIndex := l_subIndex + 1;
-- getting the column to which this mapping belongs.
select columnid into colid from abc_table where columnname=name;
CASE colid
WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
END CASE; -- end of case statement.
END LOOP;
-- Insert data into the real table from the table collection.
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO test_hem VALUES t_tab(i);
END IF;
l_index := l_index + 1;
COMMIT;
END LOOP;
commit;
EXCEPTION
WHEN OTHERS THEN
ecode := SQLCODE;
emesg := SQLERRM;
dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;Sorry Odie,
I am new to this site as well as PL/SQL. I am giving additional details which you had mentioned in your last comments.
our Oracle Database version is "10.2.0.4.0"
The structure of target table Instrument_Details is as follows:
Create table Instrument_Details (
instrument_id Integer Primary Key,
provider_name Varchar2(32),
version_number Varchar2(32),
location_id Integer,
installation_date Date,
granularity Integer,
time_out Integer );
Note:- Here test_hem is alias of Instrument_details.
Here instrument_id is a primary key.
provider_name contains the child2 xml tag value.
version_number contains the child1 xml tag value.
location_id contains the newid/id value which is map to other table which fetching the location name corresponding to the location_id.
installation_date contains the date xml tag value.
Now we have created one mapping tables where we mapped the xml tag values "mt" with table column name means "abc1 = granularity", "abc2 = time_out" in that table.
these table column value are written under mvalue xml tag.
_Our Database Character set is_:-
NLS_CHARACTERSET WE8ISO8859P1
Now as you suggest me to format your code. I am writing the xml code and procedure code again.
My xml file structure is as follows:-
<?xml version="1.0" encoding="UTF-8"?>
<mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
<child>
<child1>32.401 V5.5</child1>
<child2>ZoneGate</child2>
</child>
<mc>
<newid>
<id>12</id>
</newid>
<mindex>
<date>20111102180000</date>
<mt>abc1</mt>
<mt>abc2</mt>
<mvalue>
<r>val_1</r> -- here val_1 and val_2 are numeric values
<r>val_2</r>
</mvalue>
</mindex>
</mc>
</mcd>
<!--
ALARM STATUS
morning 10
afternoon 14
evening 18
night 22
-->
<!--
PARAM:EID = 1
PARAM:GId = 3
PARAM:GSId = 0
--!> And my oracle procedure is as follows:-
create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
-- Defining the variables
ecode NUMBER;
emesg VARCHAR2(200);
l_bfile BFILE;
l_clob CLOB;
l_dest_offset INTEGER:=1;
l_src_offset INTEGER:=1;
l_Char_set_id NUMBER := NLS_CHARSET_ID('UTF8');
l_lang_context INTEGER := dbms_lob.default_lang_ctx;
l_warning INTEGER;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl1 dbms_xmldom.DOMNodeList;
l_nl2 dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
node1 dbms_xmldom.DOMNode;
colid integer ; -- column id used for identifying which column it belongs.
l_xmltype XMLTYPE;
sub_xmltype XMLTYPE;
num_nodes number;
l_index PLS_INTEGER;
l_subIndex PLS_INTEGER;
starttime Date;
temp_datatime VARCHAR(25);
columnname varchar2(300);
columnvalue varchar2(300);
-- creating a Type which is a type of "Instrument_Details" table RowType, which I created in SVN server
TYPE tab_type IS TABLE OF Instrument_Details%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
-- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
l_bfile := BFileName('MY_FILES', xmlfile);
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
--dbms_lob.loadFromFile(dest_lob => l_clob,
-- src_lob => l_bfile,
-- amount => dbms_lob.getLength(l_bfile));
dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
dbms_lob.close(l_bfile);
-- make sure implicit date conversions are performed correctly
dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
dbms_output.put_line('Date format set');
-- Create a parser.
l_parser := dbms_xmlparser.newParser;
dbms_output.put_line('output 1');
-- Parse the document and create a new DOM document.
dbms_xmlparser.parseclob(l_parser, l_clob);
*-- Below lines are skipping....*
dbms_output.put_line(' passed parsing');
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_output.put_line(' passed getdocument');
-- Free resources associated with the CLOB and Parser now they are no longer needed.
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
-- Get a list of all the EMP nodes in the document using the XPATH syntax.
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
-- Loop through the list and create a new record in a tble collection
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
l_n := dbms_xmldom.item(l_nl1, cur_sel);
t_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
-- putting the state and vendorname into the table rowtype
dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
END LOOP;
-- getting the version and putting into the table rowtype
l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
-- selecting the nodes whose starting tag is "mindex"
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
-- checking the total number of nodes whose starting through "mi"
num_nodes := dbms_xmldom.getLength(l_nl1);
l_index := 1;
-- For loop to iterate the nodes.
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
-- whole current node is selected and storing into the node1 variable
node1 := dbms_xmldom.item(l_nl1, cur_sel);
-- setting the xmltype as AL32UTF8
l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
-- if selecting parent node containing the mt child node then only proceed else skip that parent node.
IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
-- fetch the datatime, convert it into to_date format and store it into table rowtype
temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
l_subIndex := 1;
while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
-- getting mt and corresponging mvalue/r values
dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
l_subIndex := l_subIndex + 1;
-- getting the column to which this mapping belongs.
select columnid into colid from abc_table where columnname=name;
CASE colid
WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
END CASE; -- end of case statement.
END LOOP;
-- Insert data into the real table from the table collection.
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO test_hem VALUES t_tab(i);
END IF;
l_index := l_index + 1;
COMMIT;
END LOOP;
commit;
EXCEPTION
WHEN OTHERS THEN
ecode := SQLCODE;
emesg := SQLERRM;
dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;Thanks in advance for your help... -
Attempt to process file failed with Exception in XML Parser-format problem
Hi all,
Iam getting an unusual error in the J2EE stack in XI.
And the message is:
006-11-30 17:31:07 Error Attempt to process file failed with Exception in XML Parser (format problem?):'com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0xf(:main:, row:1, col:1044002)(:main:, row=1, col=1044002) -> com.sap.engine.lib.xml.parser.ParserException: Invalid char #0xf(:main:, row:1, col:1044002)' 2006-11-30 17:31:07 Error Exception caught by adapter framework: null 2006-11-30 17:31:07 Error Delivery of the message to the application using connection AFW failed, due to: RecoverableException.
My scenerio iam posting IDOC to a flat file with content conversion in the receiver side,the mapping got executed successfully and in the audit log i found that the error was after the 'Start converting XML document content to plain text'.
This means that error occured during content conversion of XML to the prescribed file format.
Can anyone suggest any better approach using which we may trace the junk data in IDoc. Manual adhoc approach could take time and is error prone.
Thanks in advance...
karunHi Bhavesh,
Thanks for the early reply. I checked the mapping and everything is fine and the output is also in valid XML format.
The audit log shows that the mapping got executed successfully and the error is after the step 'Start converting XML document content to plain text '. Is there any constraint in the file adapter regarding the message size for parsing.
2006-11-30 17:30:50 Success Transfer: "BIN" mode, size 2912595 bytes, character encoding -
2006-11-30 17:30:50 Success Start converting XML document content to plain text
2006-11-30 17:31:07 Error Attempt to process file failed with Exception in XML Parser (format problem?):'com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0xf(:main:, row:1, col:1044002)(:main:, row=1, col=1044002) -> com.sap.engine.lib.xml.parser.ParserException: Invalid char #0xf(:main:, row:1, col:1044002)'
2006-11-30 17:31:07 Error Exception caught by adapter framework: null
2006-11-30 17:31:07 Error Delivery of the message to the application using connection AFW failed, due to: RecoverableException.
2006-11-30 17:31:07 Success The asynchronous message was successfully scheduled to be delivered at Thu Nov 30 17:36:07 GMT 2006.
2006-11-30 17:31:07 Success The message status set to WAIT.
2006-11-30 17:31:08 Success Acknowledgement creation triggered for type: SystemErrorAck
2006-11-30 17:31:08 Success Acknowledgement sent successfully for type: SystemErrorAck
2006-11-30 17:36:08 Success Retrying to deliver message to the application. Retry: 1
Maybe you are looking for
-
Error SHM starting ECC 6.0 on Solaris
Hello We are working in a customer installation. ECC 6.0 SR1 , Oracle 10.2.0 in Solaris 10. Installation process is finished, but SAP doesn't start . It seems a problem with memory segment. Only message server, collector, sender , icman and igs keep
-
After upgrading to iOS 8.0.2, my iPhone5 won't sync with my Mac. When I connect the two with my USB cable, the phone connects for an instant then disconnects then reconnects and continues with this loop indefinitely. Incidentally, I can no longer t
-
HT204291 AirPlay mirroring with iPad 2
Since updating my Apple TV software, I can't use airplay mirroring with my iPad 2. I need it for a presentation in a couple of hours. Why doesn't this work anymore?!
-
Photoshop Color Settings for Wide Gamut Monitor
Hey guys, I have a wide gamut monitor (HP LP2475w) which has already been calibrated. My question isn't so much about that, but the settings I should be using inside of Photoshop (CS5). As far as color settings (ctrl+shift+k) goes, what am I supposed
-
hi can anyone help me with creation of framework page useful answers will be rewarded Regards JM