Parsing string to xml
Dear All,
I have an OSB service which returns an xml form of output in string.
I am calling this OSB service in BPEL but it fails due to this string format recieved by BPEL.
How can I avoid it. I am also trying to convert string to xml but failing to do so.
Any pointers to this would be helpful
Thanks and Regards,
Mits
try setting the Outbound Response HTTP transport header
http:Content-Type=text/xml
or application/xml (even better)
(and of course you should make sure you have fn-bea:inlinedXml() function to turn the String into a XmlObject)
Similar Messages
-
Hello,
What is the proper way to parse XML String instead of a XML file?.Use new InputSource(new StringReader(s)).
Good luck. -
Parsing String to XML Attribute bug
Hello!
I'm trying to convert String to org.w3c.dom.Document with javax.xml.parsers.DocumentBuilder, but when I check my XML Document after creating, I find that all the Attributes are like "" or "
 ". Does anyone have some idea why that problem is and how it can be solved?
Thanks a lot!
SvigiThere are lots of bug reports about Java 5's built-in XML parser screwing up on attribute values. Try forcing Java to use the current version of Xerces (download it) instead of whatever it has built in, if that seems to apply to you. On the other hand it's possible that the bug is in your code too.
-
XML string to XML parsing in JCD
I have stored an XML file as a CLOB in the Oracle DB. While fetching this data into JCD using Oracle OTD, I am getting this CLOB field as a string containing the XML. Now I want to parse this XML string to XML, as I need to map the individual fields to an XSD OTD, which will be my output.
Kindly suggest a way to achieve this.An XSD OTD has an unmarshalFromString() method:
inputFormat.unmarshalFromString( strData );
When putting the XML into the CLOB it could be a good idea to wrap an outputstream into a Writer object in order to make certain that the encoding is correct, depending how the data is represented. When retrieving CLOB data using getCharacterStream() you will get a Reader object where the encoding is already given. -
How to parse a string containing xml data
Hi,
Is it possible to parse a string containing xml data into a array list?
my string contains xml data as <blood_group>
<choice id ='1' value='A +ve'/>
<choice id ='2' value='B +ve'/>
<choice id ='3' value='O +ve'/>
</blood_group>how can i get "value" into array list?There are lot of Java XML parsing API's available, e.g. JAXP, DOM4J, JXPath, etc.
Of course you can also write it yourself. Look which methods the String API offers you, e.g. substring and *indexOf. -
I have stored an XML file as a CLOB in the Oracle DB. While fetching this data into JCD in JavaCAPS using Oracle OTD, I am getting this CLOB field as a string containing the XML. Now I want to parse this XML string to XML, as I need to map the individual fields to an XSD OTD, which will be my output.
Kindly suggest a way to achieve this.The forum itself is a good starting point : [http://forum.java.sun.com/thread.jspa?forumID=34&threadID=347151] is a result searching for "parse string"...
-
How to parse the result xml string in BPEL
Hi,
This is Ishmayel.v new to BPEL and hava experience in xml parsing, java and webservices.
Now I am getting the XML file as a result string in BEPL.
now I want to parse the XML string and insert into the database... If any one has the idea let me know.
my email id is [email protected]
Thanks in Advance,
Regards,
Ishmayel.Your question is not clear.
You have a client applicaton which invokes a BPEL process and receives XML response from BPEL. Then you want to parse this response XML in your client application?
Or you are running a BPEL process which invokes a service and receives an XML response. Then you want to parse this XML response in BPEL before your process can proceed?
I have to assume that you are working with a string and then you want to convert the string into XML, and then parse the XML. If this is the case, then take a look at the ora:parseEscapedXML(contentString) function. You can use this in the expression editor in JDev. -
Error while parsing or executing XML-SQL document
friends,
my scenario is based on file to jdbc.i am facing an error in receiver CC in RWB.
The error states that '
Error while parsing or executing XML-SQL document: Error processing request in sax parser: Error when executing statement for table/stored proc. 'MATMAS' (structure 'STATEMENT'): java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]String or binary data would be truncated.'
My SOAP xml message is
- <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
- <SOAP:Header>
- <sap:Main xmlns:sap="http://sap.com/xi/XI/Message/30" versionMajor="3" versionMinor="0" SOAP:mustUnderstand="1" xmlns:wsu="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="wsuid-main-92ABE13F5C59AB7FE10000000A1551F7">
<sap:MessageClass>ApplicationMessage</sap:MessageClass>
<sap:ProcessingMode>asynchronous</sap:ProcessingMode>
<sap:MessageId>18f17dd0-d503-11dc-cb4d-001635b02bfd</sap:MessageId>
<sap:TimeSent>2008-02-06T22:30:21Z</sap:TimeSent>
- <sap:Sender>
<sap:Party agency="http://sap.com/xi/XI" scheme="XIParty" />
<sap:Service>ECC</sap:Service>
</sap:Sender>
- <sap:Receiver>
<sap:Party agency="http://sap.com/xi/XI" scheme="XIParty" />
<sap:Service>BS_JDBC</sap:Service>
</sap:Receiver>
<sap:Interface namespace="http://file_to_jdbc">MI_JDBC_RECEIVER</sap:Interface>
</sap:Main>
- <sap:ReliableMessaging xmlns:sap="http://sap.com/xi/XI/Message/30" SOAP:mustUnderstand="1">
<sap:QualityOfService>ExactlyOnce</sap:QualityOfService>
</sap:ReliableMessaging>
- <sap:DynamicConfiguration xmlns:sap="http://sap.com/xi/XI/Message/30" SOAP:mustUnderstand="1">
<sap:Record namespace="http://sap.com/xi/XI/System/File" name="Directory">
sapecc50\sapmnt\trans</sap:Record>
<sap:Record namespace="http://sap.com/xi/XI/System/File" name="FileEncoding">UTF-8</sap:Record>
<sap:Record namespace="http://sap.com/xi/XI/System/File" name="FileType">txt</sap:Record>
<sap:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">matmas1.txt</sap:Record>
</sap:DynamicConfiguration>
- <sap:HopList xmlns:sap="http://sap.com/xi/XI/Message/30" SOAP:mustUnderstand="1">
- <sap:Hop timeStamp="2008-02-06T22:30:21Z" wasRead="false">
<sap:Engine type="AE">af.e6e.sapecc6eval</sap:Engine>
<sap:Adapter namespace="http://sap.com/xi/XI/System">XIRA</sap:Adapter>
<sap:MessageId>18f17dd0-d503-11dc-cb4d-001635b02bfd</sap:MessageId>
<sap:Info />
</sap:Hop>
- <sap:Hop timeStamp="2008-02-06T22:30:21Z" wasRead="false">
<sap:Engine type="IS">is.01.sapecc6eval</sap:Engine>
<sap:Adapter namespace="http://sap.com/xi/XI/System">XI</sap:Adapter>
<sap:MessageId>18f17dd0-d503-11dc-cb4d-001635b02bfd</sap:MessageId>
<sap:Info>3.0</sap:Info>
</sap:Hop>
- <sap:Hop timeStamp="2008-02-06T22:30:22Z" wasRead="false">
<sap:Engine type="AE">af.e6e.sapecc6eval</sap:Engine>
<sap:Adapter namespace="http://sap.com/xi/XI/System">XIRA</sap:Adapter>
<sap:MessageId>18f17dd0-d503-11dc-cb4d-001635b02bfd</sap:MessageId>
</sap:Hop>
</sap:HopList>
- <sap:Diagnostic xmlns:sap="http://sap.com/xi/XI/Message/30" SOAP:mustUnderstand="1">
<sap:TraceLevel>Information</sap:TraceLevel>
<sap:Logging>Off</sap:Logging>
</sap:Diagnostic>
</SOAP:Header>
- <SOAP:Body>
- <sap:Manifest xmlns:sap="http://sap.com/xi/XI/Message/30" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wsu="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="wsuid-manifest-5CABE13F5C59AB7FE10000000A1551F7">
- <sap:Payload xlink:type="simple" xlink:href="cid:[email protected]">
<sap:Name>MainDocument</sap:Name>
<sap:Description />
<sap:Type>Application</sap:Type>
</sap:Payload>
</sap:Manifest>
</SOAP:Body>
</SOAP:Envelope>
and payload message is
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MT_JDBC_RECEIVER xmlns:ns0="http://file_to_jdbc">
- <STATEMENT>
- <ROW action="INSERT">
<TABLE>MATMAS</TABLE>
- <access>
<MATNR>38</MATNR>
<MTART>HALB</MTART>
<MATKL>00107</MATKL>
<MEINS>pc</MEINS>
<ERSDA>2008.04.05</ERSDA>
<BRGEW>10</BRGEW>
<NTGEW>12</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>88</MATNR>
<MTART>FERT</MTART>
<MATKL>02004</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2008.04.05</ERSDA>
<BRGEW>12</BRGEW>
<NTGEW>13</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>89</MATNR>
<MTART>FERT</MTART>
<MATKL>02004</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2008.03.02</ERSDA>
<BRGEW>12</BRGEW>
<NTGEW>14</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>98</MATNR>
<MTART>HALB</MTART>
<MATKL>2</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2006.09.01</ERSDA>
<BRGEW>12</BRGEW>
<NTGEW>12</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>170</MATNR>
<MTART>NLAG</MTART>
<MATKL>4</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2005.03.02</ERSDA>
<BRGEW>2</BRGEW>
<NTGEW>3</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>178</MATNR>
<MTART>NLAG</MTART>
<MATKL>4</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2007.03.06</ERSDA>
<BRGEW>3</BRGEW>
<NTGEW>4</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>188</MATNR>
<MTART>NLAG</MTART>
<MATKL>5</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2007.05.02</ERSDA>
<BRGEW>2</BRGEW>
<NTGEW>3</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>288</MATNR>
<MTART>HALB</MTART>
<MATKL>101</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2006.02.11</ERSDA>
<BRGEW>5</BRGEW>
<NTGEW>4</NTGEW>
<GEWEI>KG</GEWEI>
</access>
- <access>
<MATNR>358</MATNR>
<MTART>HAWA</MTART>
<MATKL>2</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2007.09.09</ERSDA>
<BRGEW>500</BRGEW>
<NTGEW>500</NTGEW>
<GEWEI>G</GEWEI>
</access>
- <access>
<MATNR>359</MATNR>
<MTART>HAWA</MTART>
<MATKL>2</MATKL>
<MEINS>PC</MEINS>
<ERSDA>2007.08.01</ERSDA>
<BRGEW>20</BRGEW>
<NTGEW>10</NTGEW>
<GEWEI>G</GEWEI>
</access>
</ROW>
</STATEMENT>
</ns0:MT_JDBC_RECEIVER>
Could anybody help me in sorting out this issue.My advance thankshi,
ypur structure is bad defined.
if you want to do an insert, the DT should be
<ns0:MT_JDBC_RECEIVER xmlns:ns0="http://file_to_jdbc">
___<StatementName>
______<dbTableName action=INSERT>
_____<table>MATMAS</table>
_______ <access>
___________<MATNR>38</MATNR>
___________<MTART>HALB</MTART>
___________<MATKL>00107</MATKL>
___________<MEINS>pc</MEINS>
___________<ERSDA>2008.04.05</ERSDA>
___________<BRGEW>10</BRGEW>
___________<NTGEW>12</NTGEW>
___________<GEWEI>KG</GEWEI>
______</access>
_____</dbTableName>
__ </StatementName>
</ns0:MT_JDBC_RECEIVER>
the ROW field is used when you wait receive data from DB for example you execute and SQL Query from Sender communication channel "SELECT name FROM TABLE Names"
so, the result of this query would be, for example:
<row>
____<name>joge</name>
</row>
<row>
____<name>pepe</name>
</row>
<row>
____<name>nicola</name>
</row>
See this link
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm
Thanks
Rodrigo
Edited by: Rodrigo Pertierra on Feb 8, 2008 8:40 AM
Edited by: Rodrigo Pertierra on Feb 8, 2008 8:42 AM -
Hi everyone,
i'm just writing a method, that gets a string and a XPath and want writes the string to the specific XPath in my xml document. The problem ist, that the string itself can contain nodes like (e.g. <image> or something else from my dtd, so i got some problems converting the string to xml. Actually i'm trying this:
public static void setEditFragment(String content, String xPath) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse("data.xml");
XPath xpath = XPathFactory.newInstance().newXPath();
Node node = (Node)xpath.evaluate(xPath, document, XPathConstants.NODE);
System.out.println(content);
node.setTextContent(content);
// Use a XSLT transformer for writing the new XML file
Transformer transformer = TransformerFactory.newInstance().newTransformer();
// Set output to IsoLatin1
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
DOMSource source = new DOMSource( document );
FileOutputStream os = new FileOutputStream("tmp.xml");
StreamResult result = new StreamResult( os );
transformer.transform( source, result );
}but of course this will not work and sets up some cryptic signs in mein xml document....
can anyone give me advice ?
Thanks !Well, if you already have the data XML encoded, then just write them to a file:
http://java.sun.com/docs/books/tutorial/essential/io/index.html
Make sure you encode the data with UTF8:
http://java.sun.com/javase/6/docs/api/java/lang/String.html#getBytes(java.lang.String)
Write "<?xml version="1.0" encoding="utf-8"?>" before the data!
Note however, I generally don't recommend to write XML data by hand. Rather use a framework like JAXB.
-Puce
Edited by: Puce on May 8, 2008 1:36 PM -
Conversion of xml string to xml file
To convert xml string to xml file in java i used
Document XMLDoc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader("<root><main>Title</main></root&g t;")));
But it is showing an error as InputSource cannot be resolved
How to rectify thisI assume you mean there is a compiler error? (It helps if you explain your problem instead of just giving a vague description of it.) It sounds like you have to import InputSource. You do know about the import statements that go at the beginning of a Java class, don't you?
-
Parsing a single XML node by JAXB
Hi,
we are developing an application to communicate with an XML webservice. Basically there are a lot of diffferent xsd files, one group are object types while another are in and out formats for action requests.
My question here is if it would be possible to parse an incoming XML string, look through it and let JAXB unmarshal only a couple of nodes from the XML. I would do this to parse my XML to a business object (containing other BO's) and because I would have to check on status information that came with the XML before trying to parse anything by JAXB.
Any advice is greatly appreciated.
Regards,
StevenAbove suggestion does not work for me.
Am currently using this solution
feed = event.result as XML;
switch(feed.channel.item.length()) {
case 0 :
trace('No results found');
break;
case 1 :
items = new ArrayCollection(ArrayUtil.toArray(feed.channel.item));
break;
default :
items = convertXmlToArrayCollection(feed);
Help me with a util function or something. -
Converting XML(as String) to XML(XMLObject) in WLI8.1
Hi,
I am new to WLI 8.1. In my business process I receive an XML from client as Java
String. Now I want to convert it into com.bea.xml.XMLObject to perform XSL Transformation.
How do I do it in WLI workshop.
Is it possible in WLI8.1 to use XML in the form of Java String as Input/Output
for XSL Transformation.
Thanks in advance
AshishI can think of 2 options.
a) Take the generated XMLObject for the XML as input to JPD - this is the default
behaviour when you use WLW when you configure you client request control method
to take the XSD as the input.
b) If you to take java.lang.String as input to the JPD method then by default
the transformation tool does NOT parse it as XML. You will have to write custome
code (using xquery/xpath or supply an xslt) to parse the XML to build the XMLObject.
The client would still send an XML request in both scenarios... and so both the
above options would not impact clients.
Hope this helps...
Vishwa
"Ashish Agrawal" <[email protected]> wrote:
>
Hi,
I am new to WLI 8.1. In my business process I receive an XML from client
as Java
String. Now I want to convert it into com.bea.xml.XMLObject to perform
XSL Transformation.
How do I do it in WLI workshop.
Is it possible in WLI8.1 to use XML in the form of Java String as Input/Output
for XSL Transformation.
Thanks in advance
Ashish -
How do you pass a string into xml
How do we pass a string to be parsed as xml
something like
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
oc = docBuilder.parse (String s);
Thanks
ArnoldString xmlString = "<?xml version=\"1.0\"?>\n<myelement myattribute=\"myvalue\"/>\n";
InputSource inputSource = new InputSource(new StringReader(xmlString));
Document document = builder.parse(inputSource); -
Can anyone say how to transform a XML String to XML document
(eg: String xmlstring="<root><main>Title</main></root>";
How can I transform this to XML Document??
GuhanRight, my mistake, this is what happens when you type code in a browser... hard to compile.
Document XMLDoc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader("<root><main>Title</main></root&g t;")))PS. Consider following the online JAXP tutorial: http://java.sun.com/xml/tutorial_intro.html -
i have problem to parse string to document
i have string like this str = "<root><data>1</data><data>2</data><root>";
how to parse this string in docoment xmlimport java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
public class PrettyPrinter {
public static void main(String[] args) {
// Assume filename argument
String filename = args[0];
try {
// Build the document with SAX and Xerces, no validation
SAXBuilder builder = new SAXBuilder();
// Create the document
Document doc = builder.build(new File(filename));
// Output the document, use standard formatter
XMLOutputter fmt = new XMLOutputter();
fmt.output(doc, System.out);
} catch (Exception e) {
e.printStackTrace();
}The above code is taken directly from
http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom-p2.html
u don't have to use Factories, this is what is said in that excerpt, it is very easy to use, and it is said that 80 % of the xml work can be done with 20 % or less work using JDOM.
n joy ....
</ksenji>
Maybe you are looking for
-
Problem with Adobe Reader 10.1.2
Updated to this version this week. Now when I trying to open PDF documents on-line nothing happens. It is as if it tries to open and then freezes. Many of these are year end tax documents I am trying to access
-
Since a few days my iMac (newest version running Mountain Lion) freezes during TC backups. Since TC is set to backup every hour my computer freezes every hour - the MAC wheel pops up and keeps spinning. Once I abort the TC backup it takes about half
-
Can ID doc be exported/saved as to place inside email?
I wish to design a newsletter in ID and then change it so that it can be placed/copied into an email and read by a recipient. Is this possible. I have tried exporting it as PDF, opening in Acrobat and exporting as html, but it looses all formating. I
-
FB is loading on Safari 6.0.5 very slow
Dears could you please help me on issue concerning FB site data and picture loading? they are loading very very slow in many case there won't load at all, I have traid to turn off secure concoction, deleting cookies, resenting safari but these tree a
-
Programmatically Add/Delete slider
Hello, I'm using System Horizontal Pointer slide. And I want to add slider programmatically. I know how to add this manuel but I want to add/delete sliders programmatically. Could you please help me ? Yasemin Barutçu Electrical And Electronics Engine