Does JMS parse xml content in TextMessages
Hi
I am working on WLS 6.1sp2 and I am using jms TextMessage type of message to
send XML messages from one subsystem to another. I have added an XML registry
for my version of XML parser. Now I do not have any entries for the entity declarations
nor for the parser entries in the registry.
When I send in an XML message in a TextMessage envelope I find the following
errors in the log.
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML document.
Failed to retrieve PUBLIC id. The root element is required in a well-formed docu
ment.>
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to open XML document. Failed
to retrieve PUBLIC id or SYSTEM id from the document. Decrease the number of cha
r between the beginning of the document and its root element.>
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML document.
Failed to retrieve SYSTEM id. The root element is required in a well-formed docu
ment.>
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to open XML document. Failed
to retrieve PUBLIC id or SYSTEM id from the document. Decrease the number of cha
r between the beginning of the document and its root element.>
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML document.
Failed to retrieve root tag. The root element is required in a well-formed docum
ent.>
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Could not instantiate factory class
specified in the Server console. Invalid parameters: at least one of publicId,
s
ystemId, rootTag must be non-null>
[ChangeAwareClassLoader] : Name is : META-INF/services/org.apache.xerces.xni.par
ser.XMLParserConfiguration
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to open XML document. Failed
to retrieve PUBLIC id or SYSTEM id from the document. Decrease the number of cha
r between the beginning of the document and its root element.>
<Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML document.
Failed to retrieve PUBLIC id. The root element is required in a well-formed docu
ment.>
Now from the logs I understand that the message is being parsed and since the
parser does not find any PUBLIC ID or SYSTEM id it dumps the error, since I am
using schemas there is none of the PUBLIC and SYSTEM ids in my xml, also this
is not logged by any component of my subsystems, this is a weblogic XML Service
log and when I trace through the code I find that it comes up after the first
subsystem sends the message and before the second subsystem receives it.
The question then is does JMS parse XML content in TextMessages and if so how
can I disable that parsing?
Thanks
Sandeep
JMS does not automatically parse TextMessages. Check the XML declaration in
your application's deployment descriptors. That's often the source of this
error.
FYI, you can use XMLMessage for xml payloads. As far as I can remember, the
XMLMessage is an extension of the TextMessage with xml parsing built in.
Adarsh
"Sandeep Nayak" <[email protected]> wrote in message
news:[email protected]...
>
> Hi
>
> I am working on WLS 6.1sp2 and I am using jms TextMessage type of message
to
> send XML messages from one subsystem to another. I have added an XML
registry
> for my version of XML parser. Now I do not have any entries for the entity
declarations
> nor for the parser entries in the registry.
>
> When I send in an XML message in a TextMessage envelope I find the
following
> errors in the log.
>
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML
document.
> Failed to retrieve PUBLIC id. The root element is required in a
well-formed docu
> ment.>
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to open XML document.
Failed
> to retrieve PUBLIC id or SYSTEM id from the document. Decrease the number
of cha
> r between the beginning of the document and its root element.>
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML
document.
> Failed to retrieve SYSTEM id. The root element is required in a
well-formed docu
> ment.>
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to open XML document.
Failed
> to retrieve PUBLIC id or SYSTEM id from the document. Decrease the number
of cha
> r between the beginning of the document and its root element.>
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML
document.
> Failed to retrieve root tag. The root element is required in a well-formed
docum
> ent.>
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Could not instantiate factory
class
> specified in the Server console. Invalid parameters: at least one of
publicId,
> s
> ystemId, rootTag must be non-null>
> [ChangeAwareClassLoader] : Name is :
META-INF/services/org.apache.xerces.xni.par
> ser.XMLParserConfiguration
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to open XML document.
Failed
> to retrieve PUBLIC id or SYSTEM id from the document. Decrease the number
of cha
> r between the beginning of the document and its root element.>
> <Jun 9, 2003 3:56:57 PM PDT> <Error> <XML> <Failed to parse given XML
document.
> Failed to retrieve PUBLIC id. The root element is required in a
well-formed docu
> ment.>
>
> Now from the logs I understand that the message is being parsed and since
the
> parser does not find any PUBLIC ID or SYSTEM id it dumps the error, since
I am
> using schemas there is none of the PUBLIC and SYSTEM ids in my xml, also
this
> is not logged by any component of my subsystems, this is a weblogic XML
Service
> log and when I trace through the code I find that it comes up after the
first
> subsystem sends the message and before the second subsystem receives it.
>
> The question then is does JMS parse XML content in TextMessages and if so
how
> can I disable that parsing?
>
> Thanks
>
> Sandeep
Similar Messages
-
How to parse XML content in JMS Message...
Hi everybody,
I am currently developing a Message-Driven Bean and has some problem parsing the XML data that contains in the JMS body.
The XML data is contained in TextMessage (JMS message type) and in order to parse the data, I need to use the DOM builder, which is expecting to read from a file (e.g. abc.xml).
My question is how can I use TextMessage (can be output to a String) as the input source instead of a file.
Thanks in advance.Hi Boon,
"Boon Keong" <[email protected]> wrote in message
news:3dd46800$[email protected]..
I am currently developing a Message-Driven Bean and has some problemparsing the XML data that contains in the JMS body.
>
The XML data is contained in TextMessage (JMS message type) and in orderto parse the data, I need to use the DOM builder, which is expecting to read
from a file (e.g. abc.xml).
>
My question is how can I use TextMessage (can be output to a String) asthe input source instead of a file.
What about this:
DocumentBuilder db = ...
Document doc = db.parse(new InputSource(new
StringReader(textMessage.toString()));
or
Document doc = db.parse(new
ByteArrayInputStream(textMessage.toString().getBytes()));
Regards,
Slava Imeshev -
XML parser to parse XML inside HTML file
Hi,
I wish to know is there any other parsers apart from JAXP to parse xml content present inside HTML file. For example,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="j_id_jsp_1394907664_1" name="j_id_jsp_1394907664_1" method="post" action="/msaiphoneportal1.1c/pages/xmlchech.faces;jsessionid=5666F0E1CF0E44B978940F021012AA41" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_id_jsp_1394907664_1" value="j_id_jsp_1394907664_1" />
<?xml version="1.0" encoding="UTF-8"?>
<hospital>
<Users>
<User id="1" password="x" type="staff" username="x"/>
<User id="2" password="y" type="staff" username="y"/>
<User id="3" password="z" type="staff" username="z"/>
</Users>
<Survey/>
<Patients>staaatus</Patients>
</hospital>
<input type="hidden" name="j_id_jsp_1394907664_1:j_id_jsp_1394907664_2" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-4298162632826268059:-1507671971163298623" autocomplete="off" />
</form>
</body>
</html>
I need to read the XML content inside. Is there any way please let me know
Edited by: DHURAI on Jul 22, 2010 12:59 AMDHURAI wrote:
while reading, we can fetch the starting of XML through <?xml> tag, but how we know the ending of the XML as it seems to be dynamic.1) Extract the document root element which follows the <?xml ... ?>
2) From this root element , construct the associated root element terminal by inserting a / after the <.
3) Search for the terminal.
If the root name can also be the name of an enclosed element then you will have to count the number of terminals. -
Hi all,
We are trying to interact with Documentum server through DFS exposed WCF which communicates through port 9443 and we are provided with documentum issued Public Key certificates. We have successfully imported the certificates in client machine and configured
the bindings as below in our .Net web application config file.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="ObjectServicePortBinding1">
<security
mode="Transport">
<transport
clientCredentialType="None"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
<binding
name="QueryServicePortBinding">
<security
mode="Transport">
<transport
clientCredentialType="None"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
</wsHttpBinding>
</bindings>
Also, we set the message encoding as MTOM and the wcf client object initialization code snippet is as below,
ObjectServicePortClient
serviceClient = new
ObjectServicePortClient(new
WSHttpBinding("ObjectServicePortBinding1"),
new
EndpointAddress(UriUtil.ObjectServiceUri));
if (serviceClient.Endpoint.Binding
is
WSHttpBinding)
WSHttpBinding
wsBinding = serviceClient.Endpoint.Binding as
WSHttpBinding;
wsBinding.MessageEncoding =
"MTOM".Equals(transferMode) ?
WSMessageEncoding.Mtom :
WSMessageEncoding.Text;
serviceClient.Endpoint.Behaviors.Add(new
ServiceContextBehavior(Config.RepositoryName,
Config.DocumentumUserName,
Config.DocumentumPassword));
When we execute the above code, we are getting error message as below,
Exception: The content type text/xml;charset=utf-8 of the response message does not match the content type of the binding (multipart/related; type="application/xop+xml"). If using a custom encoder, be sure that the IsContentTypeSupported
method is implemented properly. The first 407 bytes of the response were: '<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"><faultcode>S:VersionMismatch</faultcode><faultstring>Couldn't
create SOAP message. Expecting Envelope in namespace http://schemas.xmlsoap.org/soap/envelope/, but got http://www.w3.org/2003/05/soap-envelope </faultstring></S:Fault></S:Body></S:Envelope>'
Then, we changed the bindings as below
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="ObjectServicePortBinding1">
<security
mode="Transport">
<transport
clientCredentialType="Certificate"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
<binding
name="QueryServicePortBinding">
<security
mode="Transport">
<transport
clientCredentialType="
Certificate"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
</wsHttpBinding>
</bindings>
We are getting another error message,
Exception: The client certificate is not provided. Specify a client certificate in ClientCredentials.
Any pointers on resolving this issue would be highly helpful.
ThanksHi Dhanasegaran,
As per your case, the corresponding details which may guide you to resolve this issue:
1. First of all, you can try to call the wcf service directly from the browser & check where it will point out the correct location.
2. In config file ,Set IncludeExceptionDetailInFaults to true to enable exception information to flow to clients for debugging purposes .
Set this to true only during development to troubleshoot a service like below :
<serviceBehaviors>
<behavior name="metadataAndDebugEnabled">
<serviceDebug
includeExceptionDetailInFaults="true"
/>
<serviceMetadata
httpGetEnabled="true"
httpGetUrl=""
/>
</behavior>
</serviceBehaviors>
3. I suggest you to change that <security mode ="TransportWithMessageCredential"> instead of <security mode ="Transport">
for more information, refer the following link :
https://msdn.microsoft.com/en-us/library/aa354508(v=vs.110).aspx -
I have a WCF service I am trying to run on a new installation of 64-bit Windows Server 2008 IIS. Although it runs fine on Windows 2003 IIS, it is throwing the error in the thread title, which appears to be a server config issue, but I am not sure. Googling and searching the MSDN forums did not turn up a solution. I tried running WCF Logging, but that didn't help either.
Does anyone have any suggestions on how to solve this probelm?
Here is the error:
The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">I have the same issue on Windows 7 machine. The service works fine using a SoapUI client but a .Net client faisl to get a response.
Hi,
I have a WCF service which works perfectly when using SoapUI but throws error in my .Net client.
{"The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first
1024 bytes of the response were: '<HTML><HEAD><link rel=\"alternate\" type=\"text/xml\" href=\"http://xyz.mysite.com/ysa/Broker.svc?disco\"/><STYLE type=\"text/css\">#content{ FONT-SIZE: 0.7em;
PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT:
5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP:
0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>Broker
Service</TITLE></HEAD><BODY><DIV id=\"content\"><P class=\"head'."}
I have the same service hosted on my local machine and when I point to the local service I can execute the operation with no issues. The message encoding is Soap11. I tried changing to Soap12 but I get exact same error. Any ideas greatly appreciated.
I do have windows Activation Features installed and I am using .Net Framework 4.
Thanks
Sofia Khatoon -
How to read XML content from IPortalComponentRequest and parse them
Hi ,
I have a portal application.The application has 2 components(Comp1,comp2).
Comp1 is JspDynpage and Comp2 is AbstractPortalComponent.
Comp1- has a iframe element which point to the external url and has a parameter return_url.
retrun_url has a value as url to Comp2(http://ibm0343:50000/irj/servlet/prt/portal/prtroot/NewUrlProj.NewUrlComp)
When an event occurs in the external site,i suppose to receive XML content in return_url(ie Comp2),how can i check using the request if the received content is XML and how do i parse them.
I have already seen blogs from Prakash singh in which it refers a xml fixed location in webserver.Hi Detlev,
i am reposting this once again as the previous
reply didnt align good.
Thanks for your reply.The scenario is that
My portal application has to communicate with external GIS(Graphical information system)
service provider client application.
They say that i have to use iframe in my portal application.
Here is the snipet of the iframe tags.
<iframe
id="Nedbrowser"
name="Nedbrowser"
width="100%"
height="100%"
frameborder="no"
marginheight="0"
marginwidth="0"
scrolling="no"
style="position:absolute; top:0; left:0; width:800; height:400; z-index:100; visibility:visible"
src="http://nbg.nedg.nl/nbgint/NBG_INT_main.asp?action=CHART&datasource=NBGMV&product=INTERNET&size_x=300&size_y=300&result_frame=Results&
result_url=http://ibm0343:50000/irj/servlet/prt/portal/prtroot/NewUrlProj.NewUrlComp&
default_centre_x=256000&default_centre_y=471000&default_width=0.5">
</iframe>
<iframe
id="Results"
name="Results"
width="100%"
height="100%"
frameborder="no"
marginheight="0"
marginwidth="0"
scrolling="no"
style="position:absolute; top:400; left:0; width:800; height:200; z-index:100; visibility:visible"
src="about:blank">
</iframe>
When my portal application is started, comes the GIS map in the iframe with in my portal application.
When the user clicks in the area of the map,Gis application returns xml data to the return_url.
The reurn_url is my PortalAbstractComponent in which i have to parse the xml and use it for further processing in R3 system. -
Catch all error information while validating xml content with xsd schema
Hi experts,
I created a java mapping to validating the input xml content with xsd schema (schema validation). What I want is to catch all error message to the xml not just the first error. I used SAXParser in sapxmltoolkit.jar to do the schema validation. The below is a part of my java mapping.
XMLReader parser = XMLReaderFactory.createXMLReader("com.sap.engine.lib.xml.parser.SAXParser");
parser.setFeature( "http://xml.org/sax/features/validation" , true);
parser.setFeature( "http://apache.org/xml/features/validation/schema" , true);
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",this.getClass().getClassLoader().getResourceAsStream(schema)); // schema is my schema name
parser.setErrorHandler(new ParseErrorHandler()); // ParseErrorHandler is my own ErrorHandler which extends DefaultHandler
parser.parse(new InputSource(new ByteArrayInputStream(sinput.getBytes())));
// In error handler, I comment all code so as not to throw any exception
public class ParseErrorHandler extends DefaultHandler
public void error(SAXParseException e) throws SAXException
// sSystem.out.println("Error" + e.getMessage());
// throw e;
public void fatalError(SAXParseException e)
// throw e;
// System.out.println("SAP Fatal Error" + e.getMessage());
Unfortunately the program always stopped while catching the first error. Check the below log.
com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
ERRORS :
cvc-simple-type : information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is not valid, because it's value does not satisfy the constraints of facet 'minLength' with value '1'.
cvc-data : information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is is not valid with respoct to the corresponding simple type definition.
cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is associated with invalid data.
cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]' is not valid with respect to it's complex type definition..
cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]' is not valid with respect to it's complex type definition..
cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]' is not valid with respect to it's complex type definition..
cvc-element : element information item '/:ShipNotice[1]/:Header[1]' is not valid with respect to it's complex type definition..
cvc-element : element information item '/:ShipNotice[1]' is not valid with respect to it's complex type definition..
-> com.sap.engine.lib.xml.parser.ParserException:
I tried using Xerces and JAXP to do validation, the same error happened. I have no idea on this. Does xi has its own error handler logic? Is there any body can make me get out of this?
Thanks.<h6>Hi experts,
<h6>
<h6>I created a java mapping to validating the input xml content with xsd schema (schema validation). What I want is to catch all <h6>error message to the xml not just the first error. I used SAXParser in sapxmltoolkit.jar to do the schema validation. The below <h6>is a part of my java mapping.
<h6>XMLReader parser = XMLReaderFactory.createXMLReader("com.sap.engine.lib.xml.parser.SAXParser");
<h6>parser.setFeature( "http://xml.org/sax/features/validation" , true);
<h6>parser.setFeature( "http://apache.org/xml/features/validation/schema" , true);
<h6>parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); <h6>parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",this.getClass().getClassLoader().getResourceAsStream(schema)); <h6>// schema is my schema name
<h6>parser.setErrorHandler(new ParseErrorHandler()); // ParseErrorHandler is my own ErrorHandler which extends Default Handler
<h6>parser.parse(new InputSource(new ByteArrayInputStream(sinput.getBytes())));
<h6>
<h6>// In error handler, I comment all code so as not to throw any exception
<h6>public class ParseErrorHandler extends DefaultHandler
<h6>{
<h6> public void error(SAXParseException e) throws SAXException
<h6> {
<h6> // sSystem.out.println("Error" + e.getMessage());
<h6> // throw e;
<h6> }
<h6>
<h6> public void fatalError(SAXParseException e)
<h6> {
<h6> // throw e;
<h6> // System.out.println("SAP Fatal Error" + e.getMessage());
<h6>
<h6> }
<h6>
<h6>}
<h6>
<h6>Unfortunately the program always stopped while catching the first error. Check the below log.
<h6>
<h6>com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
<h6>ERRORS :
<h6>cvc-simple-type : information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is not valid, because it's value does not satisfy the constraints of facet 'minLength' with value '1'.
<h6>cvc-data : information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is is not valid with respoct to the corresponding simple type definition.
<h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is associated with invalid data.
<h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]' <h6>is not valid with respect to it's complex type definition..
<h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]' <h6>is not valid with respect to it's complex type definition..
<h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]' <h6>is not valid with respect to it's complex type definition..
<h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]' <h6>is not valid with respect to it's complex type definition..
<h6>cvc-element : element information item '/:ShipNotice[1]' is not valid with <h6>respect to it's complex type definition..
<h6> -> com.sap.engine.lib.xml.parser.ParserException:
<h6>
<h6>
<h6>I tried using Xerces and JAXP to do validation, the same error happened. I have no idea on this. Does xi has its own error <h6>handler logic? Is there any body can make me get out of this?
<h6>Thanks. -
Need help on parsing xml file...
Hi all,
I need to collect some data from an Xml file using java. I have the following code with me but I am unable to get the required result. I am unable to get the data from the tags belonging to the header and footer elements. Please find the code and the sample xml file below.
Program to parse XML:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class JobLogDetails3{
//No generics
List myJobs;
Document dom;
public JobLogDetails3(){
//create a list to hold the job objects
myJobs = new ArrayList();
public void runJobDetails() {
//parse the xml file and get the dom object
parseXmlFile();
//get each joblog element and create a job object
parseDocument();
//Iterate through the list and print the data
printData();
private void parseXmlFile(){
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
dom = db.parse("test.xml");
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
private void parseDocument(){
//get the root elememt
Element docEle = dom.getDocumentElement();
//get a nodelist of <joblog> elements
NodeList nl = dom.getElementsByTagName("*");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the joblog element
Element el = (Element)nl.item(i);
//get the joblog object
Job J = getJob(el);
//add it to list
myJobs.add(J);
* I take an joblog element and read the values in, create
* an joblog object and return it
* @param JobEl
* @return
private Job getJob(Element JobEl) {
//for each <joblog> element get text or int values of
//name ,id, age and name
String jobServer = getTextValue(JobEl,"server");
String jobName = getTextValue(JobEl,"name");
String jobClient = getTextValue(JobEl,"machine_name");
String jobStart = getTextValue(JobEl,"start_time");
String jobType = getTextValue(JobEl,"type");
String jobEnd = getTextValue(JobEl,"end_time");
String jobSize = getTextValue(JobEl,"new_processed_bytes");
//Create a new Job with the value read from the xml nodes
Job J = new Job(jobServer,jobName,jobClient,jobStart,jobType,jobEnd,jobSize);
return J;
* I take a xml element and the tag name, look for the tag and get
* the text content
* i.e for <employee><name>John</name></employee> xml snippet if
* the Element points to employee node and tagName is name I will return John
* @param ele
* @param tagName
* @return
private String getTextValue(Element ele, String tagName) {
String textVal = null;
NodeList nl = ele.getElementsByTagName(tagName);
if(nl != null && nl.getLength() > 0) {
Element el = (Element)nl.item(0);
textVal = el.getFirstChild().getNodeValue();
return textVal;
* Calls getTextValue and returns a int value
* @param ele
* @param tagName
* @return
private int getIntValue(Element ele, String tagName) {
//in production application you would catch the exception
return Integer.parseInt(getTextValue(ele,tagName));
* Iterate through the list and print the
* content to console
private void printData(){
System.out.println("No of Jobs '" + myJobs.size() + "'.");
Iterator it = myJobs.iterator();
while(it.hasNext()) {
System.out.println(it.next().toString());
public static void main(String[] args){
//create an instance
JobLogDetails JLD = new JobLogDetails();
//call run example
JLD.runJobDetails();
Job Class
public class Job {
private String jobServer;
private String jobName;
private String jobClient;
private String jobStart;
private String jobType;
private String jobEnd;
private String jobSize;
public Job(){
public Job(String jobServer,String jobName,String jobClient,String jobStart,String jobType,String jobEnd,String jobSize ) {
this.jobServer = jobServer;
this.jobName = jobName;
this.jobClient = jobClient;
this.jobStart = jobStart;
this.jobType = jobType;
this.jobEnd = jobEnd;
this.jobSize = jobSize;
public String getjobServer() {
return jobServer;
public void setjobServer(String jobServer) {
this.jobServer = jobServer;
public String getjobName() {
return jobName;
public void setjobname(String jobName) {
this.jobName = jobName;
public String getjobClient() {
return jobClient;
public void setjobClient(String jobClient) {
this.jobClient = jobClient;
public String getjobStart() {
return jobStart;
public void setjobStart(String jobStart) {
this.jobStart = jobStart;
public String getjobType() {
return jobType;
public void setjobType(String jobType) {
this.jobType = jobType;
public String getjobEnd() {
return jobEnd;
public void setjobEnd(String jobEnd) {
this.jobEnd = jobEnd;
public String getjobSize() {
return jobSize;
public void setjobSize(String jobSize) {
this.jobSize = jobSize;
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(getjobServer());
sb.append(",");
sb.append(getjobName());
sb.append(",");
sb.append(getjobClient());
sb.append(",");
sb.append(getjobType());
sb.append(",");
sb.append(getjobStart());
sb.append(",");
sb.append(getjobEnd());
sb.append(",");
sb.append(getjobSize());
sb.append(",");
return sb.toString();
Sample XML File:
<?xml version="1.0" encoding="UTF-16" ?>
- <joblog>
<job_log_version version="2.0" />
- <header>
<filler>======================================================================</filler>
<server>Job server: TGBBAK</server>
<name>Job name: TGBSAP4-SQL-SQL DB Servers S2T - High-Weekly Full Backup</name>
<start_time>Job started: 26 September 2011 at 01:00:04</start_time>
<type>Job type: Backup</type>
<log_name>Job Log: GFD_TGBBAK_71887.xml</log_name>
<filler>======================================================================</filler>
</header>
<media_mount_date>Drive and media mount requested: 26/09/2011 01:00:04</media_mount_date>
- <media_drive_and_media_info>
<media_mount_date>Drive and media information from media mount: 26/09/2011 01:00:39</media_mount_date>
<robotic_library_name>Robotic Library Name: HP 1</robotic_library_name>
<drive_name>Drive Name: LTO4_2</drive_name>
<slot>Slot: 43</slot>
<media_label>Media Label: 000059L</media_label>
<media_guid>Media GUID: {a6ca0062-7a6f-4b4b-8144-732ca25f2f9d}</media_guid>
<media_overwrite_date>Overwrite Protected Until: 25/10/2011 19:24:58</media_overwrite_date>
<media_append_date>Appendable Until: 02/10/2011 14:00:30</media_append_date>
<media_set_target>Targeted Media Set Name: Weekly Tape</media_set_target>
</media_drive_and_media_info>
- <backup>
<filler>======================================================================</filler>
<title>Job Operation - Backup</title>
<append_or_overwrite>Media operation - append.</append_or_overwrite>
<compression>Compression Type: Hardware [if available, otherwise none]</compression>
<verify_option>WARNING: The option 'Verify after backup completes' was not selected. Performing a verify operation to make sure that media can be read after the backup has completed is recommended.</verify_option>
<filler>======================================================================</filler>
- <machine>
<machine_name>TGBSAP4.Tetley.Grp</machine_name>
<info>Network control connection is established between 10.22.2.18:3271 <--> 10.22.2.4:10000</info>
<info>Network data connection is established between 10.22.2.18:3301 <--> 10.22.2.4:3094</info>
- <set>
<set_resource_name>TGBSAP4.Tetley.Grp</set_resource_name>
<tape_name>Family Name: "Media created 25/09/2011 13:59:55"</tape_name>
- <volume>
<display_volume>Backup of "TGBSAP4.Tetley.Grp "</display_volume>
</volume>
<description>Backup set #45 on storage media #1 Backup set description: "Weekly Full Backup"</description>
<backup_type>Backup Method: Full - Back up entire database or filegroup</backup_type>
<agent_started>Microsoft SQL Server Agent: Started</agent_started>
<start_time>Backup started on 26/09/2011 at 01:01:45.</start_time>
- <database>
<database>Database PRD</database>
</database>
- <database>
<database>Database master</database>
</database>
- <database>
<database>Database model</database>
</database>
- <database>
<database>Database msdb</database>
</database>
<end_time>Backup completed on 26/09/2011 at 02:42:25.</end_time>
- <summary>
<backed_up_database>Backed up 4 databases</backed_up_database>
<new_processed_bytes>Processed 573363576542 bytes in 1 hour, 40 minutes, and 40 seconds.</new_processed_bytes>
<vlm_hist_rateformat2>Throughput rate: 5432 MB/min</vlm_hist_rateformat2>
</summary>
<filler>----------------------------------------------------------------------</filler>
</set>
</machine>
</backup>
- <footer>
<filler>======================================================================</filler>
<end_time>Job ended: 26 September 2011 at 02:43:12</end_time>
<engine_completion_status>Job completion status: Successful</engine_completion_status>
<filler>======================================================================</filler>
<completeStatus>19</completeStatus>
</footer>
</joblog>1. your code does not compile (in your main method you try to create an instance of a class which does not exist).
2. your XML document is not well formed.
+[Fatal Error] test.xml:34:74: The content of elements must consist of well-formed character data or markup.+
org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
Maybe there are other problems but you can start by fixing these. -
Dynamic queue name with JMS Queue XML?
Hi,
Is it possible to use dynamic queue name with JMS Queue XML?
I tried using a variable in the JNDI URL, and supply the value in a package. I specified the following in the JNDI URL in the Topology:
e.g.
<JMS_RESOURCE>?d=<DTD_FILE>&s=<SCHEMA>&JMS_DESTINATION=#PROJECT_NAME.dest_var
I declared and set the variable in a package, then tried to load data from the above data server to database. But executing this package gave me the following error:
7000 : null : java.sql.SQLException: javax.jms.JMSException: Cannot find the target in JNDI (#PROJECT_NAME.dest_var)
java.sql.SQLException: javax.jms.JMSException: Cannot find the target in JNDI (#PROJECT_NAME.dest_var)
at com.sunopsis.jdbc.driver.bg.executeQuery(bg.java)
at com.sunopsis.jdbc.driver.bh.executeQuery(bh.java)
at com.sunopsis.jdbc.driver.l.f(l.java)
at com.sunopsis.jdbc.driver.l.executeUpdate(l.java)
at com.sunopsis.sql.SnpsQuery.executeUpdate(SnpsQuery.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execSrcOrders(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenario.java)
at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
at com.sunopsis.dwg.cmd.e.i(e.java)
at com.sunopsis.dwg.cmd.g.y(g.java)
at com.sunopsis.dwg.cmd.e.run(e.java)
at java.lang.Thread.run(Unknown Source)
Am I doing it wrongly?
Thanks!hi,
as it's not in Adapter-Specific Message Properties
http://help.sap.com/saphelp_nw04/helpdata/en/10/b1b4c8575a6e47954ad63438d303e4/content.htm
looks like you cannot do it with jms adapter in standard
use proxy or your own adapter instead
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
How to Parse XML with SAX and Retrieving the Information?
Hiya!
I have written this code in one of my classes:
/**Parse XML File**/
SAXParserFactory factory = SAXParserFactory.newInstance();
GameContentHandler gameCH = new GameContentHandler();
try
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(recentFiles[0], gameCH);
catch(javax.xml.parsers.ParserConfigurationException e)
e.printStackTrace();
catch(java.io.IOException e)
e.printStackTrace();
catch(org.xml.sax.SAXException e)
e.printStackTrace();
/**Parse XML File**/
games = gameCH.getGames();And here is the content handler:
import java.util.ArrayList;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
class GameContentHandler extends DefaultHandler
private ArrayList<Game> games = new ArrayList<Game>();
public void startDocument()
System.out.println("Start document.");
public void endDocument()
System.out.println("End document.");
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes atts) throws SAXException
public void endElement(String namespaceURI, String localName, String qualifiedName) throws SAXException
public void characters(char[] ch, int start, int length) throws SAXException
/**for (int i = start; i < start+length; i++)
System.out.print(ch);
public ArrayList<Game> getGames()
return games;
}And here is the xml i am trying to parse:<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<Database>
<Name></Name>
<Description></Description>
<CurrentGameID></CurrentGameID>
<Game>
<gameID></gameID>
<name></name>
<publisher></publisher>
<platform></platform>
<type></type>
<subtype></subtype>
<genre></genre>
<serial></serial>
<prodReg></prodReg>
<expantionFor></expantionFor>
<relYear></relYear>
<expantion></expantion>
<picPath></picPath>
<notes></notes>
<discType></discType>
<owner></owner>
<location></location>
<borrower></borrower>
<numDiscs></numDiscs>
<discSize></discSize>
<locFrom></locFrom>
<locTo></locTo>
<onLoan></onLoan>
<borrowed></borrowed>
<manual></manual>
<update></update>
<mods></mods>
<guide></guide>
<walkthrough></walkthrough>
<cheats></cheats>
<savegame></savegame>
<completed></completed>
</Game>
</Database>I have been trying for ages and just can't get the content handler class to extract a gameID and instantiate a Game to add to my ArrayList! How do I extract the information from my file?
I have tried so many things in the startElement() method that I can't actually remember what I've tried and what I haven't! If you need to know, the Game class instantiates with asnew Game(int gameID)and the rest of the variables are public.
Please help someone...OK, how's this?
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes atts) throws SAXException
current = "";
public void endElement(String namespaceURI, String localName, String qualifiedName) throws SAXException
try
if(qualifiedName.equals("Game") || qualifiedName.equals("Database"))
{return;}
else if(qualifiedName.equals("gameID"))
{games.add(new Game(Integer.parseInt(current)));}
else if(qualifiedName.equals("name"))
{games.get(games.size()-1).name = current;}
else if(qualifiedName.equals("publisher"))
{games.get(games.size()-1).publisher = current;}
etc...
else
{System.out.println("ERROR - Qualified Name found in xml that does not exist as databse field: " + qualifiedName);}
catch (Exception e) {} //Ignore
public void characters(char[] ch, int start, int length) throws SAXException
current += new String(ch, start, length);
} -
Parsing xml in clob field remove non utf-8 characters
hi all,
i have an issue where a stored procedure runs during a nightly process and parses xml contained in a clob field. There are some records that contain non-utf8(they paste characters from word)characters and therefore the parse fails when using performing an xquery select against the clob field as xmltype. I was wondering if anyone knew of a handy way to handle such a situation? I have looked around a bit and not found anything that seemed tailored to my situation, and I would like something a bit more generic than doing a replace on individual characters that i have found causing issues...thx in advance! -- jpHi,
Like BluShadow I'm curious to see a test case...
Depending on the way it's been created, the encoding declared in the XML prolog doesn't necessarily reflects the actual encoding of the content.
What's your database character set, and version?
Please also post the error message you get (LPX-00200 probably?). -
OSB transformation error- BEA-382513- Error parsing XML
Hi Gurus -
I am struggling to fix one OSB Xquery transformation error
<con:errorCode>BEA-382513</con:errorCode>
<con:reason>OSB Replace action failed updating variable "body": Error parsing XML: {err}FORG0005: expected exactly one item, got 0 items
I am passing SIL formatted data to this transformation an expecting a transformation but its keep on failing, I have tested the transformation and thats looking good.
This is my replace operation where I am doing transformation.
Replace [ node contents ] of [ ./* ]
in [ body ] with
XQuery Resource: TestProject/Common/Transformation/XQJMS2DBTransformation
Variable Names And Bindings:
commonInterfaceLayout1 - $body/*:CommonInterfaceLayout
transformation file
(:: pragma bea:global-element-parameter parameter="$commonInterfaceLayout1" element="ns0:CommonInterfaceLayout" location="../../Common/Schema/CommonInterfaceLayout.xsd" ::)
(:: pragma bea:global-element-return element="ns1:EaiAuditCollection" location="../../Common/Schema/XSD_InsertEAIAuditDBTable.xsd" ::)
declare namespace ns1 = "http://xmlns.oracle.com/pcbpel/adapter/db/top/InsertEAIAuditDBTable";
declare namespace ns0 = "http://eai.fpl.com/schema/CommonInterfaceLayout";
declare namespace xf = "http://tempuri.org/ErrorHandlingR1V1/XQJMS2DB/";
declare function xf:XQJMS2DB($commonInterfaceLayout1 as element(ns0:CommonInterfaceLayout))
as element(ns1:EaiAuditCollection) {
<ns1:EaiAuditCollection>
<ns1:EaiAudit>
<ns1:eaiAuditId></ns1:eaiAuditId>
<ns1:messageId>{ data($commonInterfaceLayout1/ns0:Header/ns0:MessageId) }</ns1:messageId>
<ns1:messageDate>{ data($commonInterfaceLayout1/ns0:Header/ns0:MessageReceivedDate) }</ns1:messageDate>
<ns1:messageType>{ data($commonInterfaceLayout1/ns0:Header/ns0:MessageType) }</ns1:messageType>
<ns1:messageSource>{ data($commonInterfaceLayout1/ns0:Header/ns0:MessageSource) }</ns1:messageSource>
<ns1:messageTarget>{ data($commonInterfaceLayout1/ns0:Header/ns0:MessageTarget) }</ns1:messageTarget>
<ns1:appUniqId>{ data($commonInterfaceLayout1/ns0:Header/ns0:ApplicationUniqueId) }</ns1:appUniqId>
<ns1:payload>{ data($commonInterfaceLayout1/ns0:Body) }</ns1:payload>
<ns1:componentName>{ data($commonInterfaceLayout1/ns0:Header/ns0:ComponentName) }</ns1:componentName>
<ns1:clientId>{ data($commonInterfaceLayout1/ns0:Header/ns0:ClientId) }</ns1:clientId>
<ns1:createDate>{ fn:current-date() }</ns1:createDate>
<ns1:processFlag></ns1:processFlag>
</ns1:EaiAudit>
</ns1:EaiAuditCollection>
declare variable $commonInterfaceLayout1 as element(ns0:CommonInterfaceLayout) external;
xf:XQJMS2DB($commonInterfaceLayout1)
pls advice whats wrong I am doing here.
Edited by: KumarB on Feb 7, 2013 9:56 PMupdate - I dont see this error any more but transformation is not happening. as a result of transformation, i get same message as output .. no change in it.
-
can any one help me to access the xml contents using a servlet or a java code.
eg: there are some tags in xml and i want to access those contents from those tags and display it..
if u can please mail me to:
[email protected]Hi Suresh
I need the same one for my requirement if u have please post to this site or send me an email .
[email protected]
I can able to parsed one structured XML file using SAX
Sample code :
// ===========================================================
// SAX DocumentHandler methods
// ===========================================================
public void startDocument() throws SAXException {
logger.info("Start of document");
public void endDocument() throws SAXException {
logger.info("End of document");
public void startElement(String namespaceURI, String localName, // local
// name
String qualName, // qualified name
Attributes attrs) throws SAXException {
elemName = new String(localName); // element name
if (elemName.equals(""))
elemName = new String(qualName); // namespaceAware = false
tagPosition = TAG_START;
// Set the string for accumulating the text in a tag to empty
elemChars = "";
// If the element name is "row", create a new row instance
// If the element is "indexxid", "ModelPrice", or "ModelSpread",
// the value will be read in the method "characters" and stored.
if (elemName.equals("row")) {
row = new IndexRow();
numRows++;
// logger.info("Number of numRow:"+numRows);
} // end method startElement
public void endElement(String namespaceURI, String simpleName, // simple
// name
String qualName // qualified name
) throws SAXException {
elemName = new String(simpleName);
if (elemName.equals(""))
elemName = new String(qualName); // namespaceAware = false
tagPosition = TAG_END;
String indexId = new String();
Double dblVal = new Double(0);
// If element name is "row", put the current row in the map for row
// instances
if (elemName.equals("row")) {
if (numRows <= 5) { logger.info("Row is: " + row.toString()); }
//ABX
//indexRows.put(row.getIndexxId(), row);
if (family.equals("ABX.HE")){
indexRows.put(row.getIndexREDId(), row);
else {
//CDX ITRXX
indexRows.put(row.getIndexxId(), row);
} else if (elemName.equals("IndexID")) {
row.setIndexxId(elemChars);
else if (elemName.equals("ModelPrice")) {
// Leave double value at default of zero if there are no chars
if (elemChars.trim().length() != 0) {
dblVal = new Double(elemChars);
row.setModelPrice(dblVal);
indexId = row.getIndexxId();
} else if (elemName.equals("ModelSpread")) {
// Leave double value at default of zero if there are no chars
if (elemChars.trim().length() != 0) {
dblVal = new Double(elemChars);
row.setModelSpread(dblVal);
indexId = row.getIndexxId();
} else if (elemName.equals("CompositePrice")) {
// Leave double value at default of zero if there are no chars
if (elemChars.trim().length() != 0) {
dblVal = new Double(elemChars);
row.setCompositePrice(dblVal);
indexId = row.getIndexxId();
} else if (elemName.equals("CompositeSpread")) {
// Leave double value at default of zero if there are no chars
if (elemChars.trim().length() != 0) {
dblVal = new Double(elemChars);
row.setCompositeSpread(dblVal);
indexId = row.getIndexxId();
} else if (elemName.equals("REDCode")) {
row.setRedCode(elemChars);
else if (elemName.equals("Name")) {
row.setRowName(elemChars);
} else if (elemName.equals("Series")) {
row.setSeries(elemChars);
} else if (elemName.equals("Version")) {
row.setVersion(elemChars);
} else if (elemName.equals("Term")) {
row.setTerm(elemChars);
} else if (elemName.equals("Maturity")) {
row.setMaturity(elemChars);
} else if (elemName.equals("OnTheRun")) {
row.setOnTheRun(elemChars);
} else if (elemName.equals("Date")) {
row.setRowDate(elemChars);
} else if (elemName.equals("Depth")) {
row.setDepth(elemChars);
else if (elemName.equals("Heat")) {
// logger.info("Chars for element " + elemName + " are '" +
// elemChars + "'");
// Leave double value at default of zero if there are no chars
if (elemChars.trim().length() != 0) {
dblVal = new Double(elemChars);
row.setHeat(dblVal);
indexId = row.getIndexxId();
// ABX.HE
else if (elemName.equals("IndexREDId")){
row.setIndexREDId(elemChars);
else if (elemName.equals("Coupon")){
row.setCoupon(elemChars);
if (elemName.equals("Ontherun")) {
row.setOnTheRun(elemChars);
} // end method endElement
public void characters(char buf[], int offset, int len) throws SAXException {
// If at end of element, there will be no characters
if (tagPosition == TAG_END) {
return;
// The characteres method may be called more than once
// for an element if the internal buffer fills up.
// Append the characters until the end of the element.
String strVal = new String(buf, offset, len);
elemChars = elemChars + strVal;
} // end method characters
} // end class MarkItIndexLoader
but the problem is i want to parse any XML file means any Elemets would be change any time using SAX .In the above example
else if (elemName.equals("Heat")) {
else if (elemName.equals("IndexREDId")){
} else if (elemName.equals("Maturity")) {
like above I am doing hard code so i don't want hard coding the elements names I want to read any element name and value dynamically.
Dynamically i want to read the root and child elements
EX: I can give any XML file like
Student.XML: <root>..</StName>..</StAge>...</root>
Employee.XML: <root>..</EmpName>..</EmpAge>...</root>
CdCatalog.XML: <root>..</Cdtitle>...</CdNumber>...</root>
I need one java program can ready any type of XML file elements and send to the Database table.
Please any one done like this task please suggest some reference links or books or sample snippet which can help me to develop program in my requirement. -
Script for parsing xml data and inserting in DB
Thank you for reading.
I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
Method 1
Create or replace procedure parse_xml is
l_bfile BFILE;
l_clob CLOB;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
l_file dbms_xmldom.DOMNodeList;
l_filen dbms_xmldom.DOMNode;
lv_value VARCHAR2(1000);
l_ch dbms_xmldom.DOMNode;
l_partname varchar2(100);
l_filename varchar2(1000);
l_temp VARCHAR2(1000);
TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
l_bfile := BFileName('DIR1', 'SoftwareParts.xml');
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.close(l_bfile);
dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY''');
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part');
FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_emp);
t_tab.extend;
dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname);
t_tab(t_tab.last).partname := l_partname;
l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName');
FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP
l_ch := dbms_xmldom.item(l_file, cur_ch);
lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch));
if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if;
t_tab(t_tab.last).filename := lv_value;
t_tab.extend;
END LOOP;
END LOOP;
t_tab.delete(t_tab.last);
FOR cur_emp IN t_tab.first .. t_tab.last LOOP
if t_tab(cur_emp).partname is not null and t_tab(cur_emp).filename is not null then
INSERT INTO tab_software_parts
VALUES
(t_tab(cur_emp).partname, t_tab(cur_emp).filename);
end if;
END LOOP;
COMMIT;
dbms_xmldom.freeDocument(l_doc);
EXCEPTION
WHEN OTHERS THEN
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;
<TWObject className="TWObject">
<array size="240">
<item>
<variable type="QuestionDetail">
<questionId type="String"><![CDATA[30]]></questionId>
<questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
<country type="String"><![CDATA[GB]]></country>
<questionText type="String"><![CDATA[Please indicate]]></questionText>
<optionType type="String"><![CDATA[RadioButton]]></optionType>
<answerOptions type="String[]">
<item><![CDATA[Yes]]></item>
<item><![CDATA[No]]></item>
</answerOptions>
<ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
<parentQuestionId type="String"></parentQuestionId>
<parentQuestionResp type="String"></parentQuestionResp>
</variable>
</item>
<item>
<variable type="QuestionDetail">
<questionId type="String"><![CDATA[40]]></questionId>
<questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
<country type="String"><![CDATA[DE]]></country>
<questionText type="String"><![CDATA[Please indicate]]></questionText>
<optionType type="String"><![CDATA[RadioButton]]></optionType>
<answerOptions type="String[]">
<item><![CDATA[Yes]]></item>
<item><![CDATA[No]]></item>
</answerOptions>
<ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
<parentQuestionId type="String"></parentQuestionId>
<parentQuestionResp type="String"></parentQuestionResp>
</variable>
</item>
</array>
</TWObject>Reposted as
Script to parse XML data into Oracle DB -
Error parsing XML file from a HttpServletRequest using JAXP
Hi,
I am trying to generate an XML file from an HttpServletRequest. I am actually using file uploading method in JSP to send the XML file. I think the parser isnt able to correctly identify the XML file from the message body and hence it is giving some strange error messages. Has anyone of u managed to solve this problem ?
Code snippet:
//now build an XML document from the requested input stream
InputStream in = myRequest.getInputStream();
try {
myDocRequest = myParser.parse(in);
} catch (Throwable t) {
throw new Exception("Could not build document",t);
Error message is:
[Fatal Error] :1:1: Content is not allowed in prolog.
java.lang.Exception: Could not build document
at XMLUtil.<init>(XMLUtil.java:91)
at WCS.doPost(WCS.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at XMLUtil.<init>(XMLUtil.java:89)
... 20 more
Actually if i just print out the message, it gives something like this:
-----------------------------7d63dc71b06b2
Content-Disposition: form-data; name="W"; filename="C:\work_projects\Capas.xml"
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<GetCapabilities version="1.0.0" service="wcs">
<section>/WCS_Capabilities/Capability</section>
</GetCapabilities>
-----------------------------7d63dc71b06b2--
Cheers.The ServletInput stream contains this:
-----------------------------7d63dc71b06b2
Content-Disposition: form-data; name="W"; filename="C:\work_projects\Capas.xml"
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
i.e., its the HTTP File Upload MIME stuff, followed by the XML. You need to wrap around the input stream something that can decode the HTTP MIME stuff and let you get at the XML itself, i.e., something like: com.orielly.servlet.multipart.MultipartParser (Apache has a similar 'file upload servlet).
Jeremy
Maybe you are looking for
-
How to create the web template
Hi BW Experts, how to create the web template.....! I just want to know what is the use of Web template. i want to display the report in WEB-UI screen ( sap-crm 7.0 portal ) can any one help me please how to proceed ...! Thanks shahina..!
-
Material Document for Scrap consumption not Found
Dear Friends During order confirmation, molten material / raw material is consumed by 261 MT and dross SH100002 is generated by MT 531 along with the finished product with MT 102. I reversed finished product through 102 MT and Raw material through MT
-
Hello, I have a problem with RFC adapters (From ECC and from BW) When I try to found the problem in RWB communication channel monitoring (I choose RFC in adapter type section) I'm not seeing these channels. Any idea how I can found this channels? E
-
Recaluculation of taxes at item level based on the value given in ZZ field
Dear all, We have added a custom field for ALT BP TAX Grp at item level of service order. Whenever user changes the BP Tax Grp using this field at item level, we want the system to re-determine the taxes based on this new value of BP tax group bypass
-
What's your RECALL status?
Hi, guys. Let's post here only 3 things: 1. Where you live. 2. The successful procedures you followed to get your battery replaced. 3. The updated status of your recall / Expected date of Arrival. This way, we can follow the delivery of batteries and