Converting XML to String in OSB
Hi All,
Is there any function (apart from fn-bea:serialize function) for converting XML payload to a String in OSB. Please let me know.
Thanks,
Bpeltechie
That's how it's worded by W3C
http://www.w3.org/TR/REC-xml/#syntax
The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment,
a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the
strings " & " and " & lt; " respectively. The right angle bracket (>) may be represented using the string " & gt; ", and must, for compatibility, be
escaped using either " & gt; " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end
of a CDATA section.Note that it says left angle bracket must not appear in their literal form, but the right angle bracket may be represented using the string " &gt; "
Cheers,
Vlad
Similar Messages
-
How to convert XML to Binary in OSB Message flow
Dear All,
Can you please help me in converting XML to Binary in OSB Message flow.
Please help.
Thanks,ah ok, then you have to apply a transformation from XML to some fixed length format, EDI style
probably you have 2 options: the traditional MFL
http://docs.oracle.com/cd/E13159_01/osb/docs10gr3/consolehelp/mfls.html
or the (probably) more supported nXSD with a JCA adapter
http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/nfb.htm
I will let you digest this info and then we can continue.
There are a number of threads in this forum on whether one technology is better than the other (as usual, google can assist you) -
Receive xml as string from OSB and pass it to Bpel
I was given xml and DTD by our external partners. I need to receive this xml, parse this and insert some of the
values of the elements into DB.
Question1:
Since I don't have WSDL, can I receive xml in string and pass it on to OSB BS which calls Bpel process?
If yes, how and can I get any example?
How do I set up osb bs service to talk to bpel?
I have installed oracle soa suite 10g with patch set 4. This runs with Oracle AS. I have my Bea weblogic 10.3 with OSB installed.
Both the servers are running seperately.If I use
string to xml --- fn-bea:inlinedXML()
How do I extract a value of an element? When I log the xml that got extracted from a string, I only see the values of elements with no element names:
eg: if incoming string format of xml is:
<Customer>
<name>aaa</name>
<address>bb</address>
</Customer>
After fn-bea:inlinedXML($body)
I see:
aaa
bbb
in the log, but with no element names -
Converting XML data string in to file object to parse
Hi
I have XML in the form of String .. i just want to convert this string in to a file to parse.. how can i do that ..<p>
Here is my xml string<p>
String str = "<?xml version="1.0"?>
<!DOCTYPE some SYSTEM "some.dtd">
<firsttag>
<childtag>
<name>some name</name>
<age>age</age>
</childtag>
</firsttag>";<p>
if u have code that would be great
Thanks in advanceHi
I have XML in the form of String .. i just want to
convert this string in to a file to parse.. how can i
do that ..<p>
Why not to use RandomAccessFile to write string to file(you need to do this? is i'm right?) -
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 To Convert XML into String?
Hi,
I have a requirement in which I need to convert the data from XML file to string.
E.g.
<Drawing>
<DrawingSpecification>
<Header>
<SoldTo>SDN</SoldTo>
<SoldToName>SAP</SoldToName>
<Date/>
<Manager>CEO</Manager>
< Plant>INDIA</Name>
<Items>
<Item>
< MaterialNumber>MatNum12</ MaterialNumber>
<ProductNumber>ProName12</ ProductNumber>
</Item>
</Items>
< ClientId>ClientID123</ ClientId>
<FileName>FileName123</FileName>
<Type/>
< TemplateName/>
</DrawingSpecification>
<Image contentType=""/>
< /Drawing>
Output should be like:
< File>
< Content> SDN SAP CEO INDIA MatNum12 ProName12 ClientID123 FileName123</Content>
< /File>
Please provide solution for the same.
Thanks,
Abhishek.what about something like this
package test;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Test {
public static void main(String args[]) throws Exception {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File("test.xml"));
StringBuffer buffer = new StringBuffer();
appendChildren(buffer, doc.getChildNodes());
System.out.println(buffer.toString());
private static void appendChildren(StringBuffer buffer, NodeList list) {
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeValue() != null) {
if (node.getNodeValue().trim().length() > 0) {
buffer.append(node.getNodeValue()).append("|");
appendChildren(buffer, node.getChildNodes());
...btw: IMHO the use of this forum is to get an answer to an particular question - not to ask for complete solutions - create the solution yourself an ask if you are stuck somewhere (with a bit of research (google) it is not hard to find a solution for your problem)
regards franz
...close thread if question is answered -
Error converting XML to String
I'm trying to use getXMLString() to put my XML document in a String variable. I get the following when I try to output the String:
<?xml version = '1.0'?>
<ERROR>oracle.xml.sql.OracleXMLSQLException: This object has been closed. If the close() was implicit, and you would like the object not to be closed between calls, see the keepCursorAlive() method</ERROR>
If I just output the XML doc without putting it into a String variable it works fine.
System.out.println(q.getXMLString()); //OK
// get the XML document in string format
String xmlString = q.getXMLString(); //NOT OK
System.out.println(xmlString);
What am I doing wrong? Any help would be great!
Thanks,
MelaniHi,
SMUM_XML_PARSE is a simplified, unreleased and undocumented version of the powerful, released and documented iXML
If you look at the GET_ELEMENT subroutine in that function module, you'll see that the nodes of type CO_NODE_CDATA_SECTION are simply ignored.
The simpliest thing for you, maybe, is to duplicate the code of SMUM_XML_PARSE (as it is rather easy to handle), and add a section to GET_ELEMENT. You'll have also to use IF_IXML_CDATA_SECTION interface and ixml_iid_cdata_section constant.
Documentation is here: [SAP Library: Interface if_ixml_cdata_section|http://help.sap.com/saphelp_nw70/helpdata/en/bb/576658dca511d4990b00508b6b8b11/frameset.htm ]
Best regards,
Sandra -
I have an xml file titled config.xml that looks like this.
<textChanges>
<change id = “22833” whatToAdd = “\n\n” whereToAdd = “Front”></change>
<change id = “22843” whatToAdd = “\n” whereToAdd = “End”></change>
</textChanges>
I’m processing this code inorder to automatically add \n to the front or end of a line found in an xml file titled textXML.
Here is the processing code:
var textToInsert:String = textXML.text.(@id == i);
var textAddition:String = config.textChanges.change.(@id == i).@whatToAdd;
if (textAddition != “”)
var textLoc:String = config.textChanges.change.(@id == i).@whereToAdd;
if (textLoc == “Front”)
textToInsert = textAddition + textToInsert;
else if (textLoc == “End”)
textToInsert = textToInsert + textAddition;
trace(”“);
trace(finalText;);
trace(”“);
This traces the correct line of code from textXML, but the \n\n shows up in the text and doesn’t add the carriage returns. The crazy thing is, it works if I replace textAddition with “\n\n”. I figure this is happening because of some weird formatting issue. So I’ve tried many ways of formatting the textAddition var to a string. Each time has had no effect.
Does anyone have any ideas? Any help is really appreciated.It is your second post where it feels like it is an overkill. Why not to use plain html in your xml for text formatting, line breaks, etc.?
-
Error While converting xml to sap abap string.
Hi Experts,
As i am doing an cross Application from SAP to .Net and vice versa.I am receiving an xml from .Net and it should be converted to ABAP string Using the following function module SMUM_XML_PARSE
And the following string i am receiving from .net
<Root><qApprovalInfo><RequesterId>xxxx</RequesterId><RequesterName>xxx</RequesterName><ApproverId>xxxx</ApproverId><ApproverLevel>1</ApproverLevel><PendingApprovalId>0200169911</PendingApprovalId><CreatedDate>20/07/2011</CreatedDate><CreatedBy>xx</CreatedBy><ModifiedDate>2011-07-20 16:45</ModifiedDate><ModifiedBy>xxxx</ModifiedBy><ApplicationCode>EPAY</ApplicationCode><WorkFlowCode>EPX</WorkFlowCode><ApprovalStatus>APPROVED</ApprovalStatus><ActionComments><![CDATA[APPROVED(through Desktop)]]></ActionComments><Mode>CREATE</Mode><ActionSource>DESKTOP</ActionSource></qApprovalInfo><qApprovalHidden><Approverl>40002664</Approver><EmployeeId>40016515</EmployeeId></qApprovalHidden></Root>
In this xml i am getting all the values except the <ActionComments><![CDATA[APPROVED(through Desktop)]]></ActionComments>
is their any way to convert that CDATA value?..
have anybody come across the following issue ?...
can anybody provide the solution for this?.
Edited by: basavaraj.p on Aug 29, 2011 10:54 AMHi,
SMUM_XML_PARSE is a simplified, unreleased and undocumented version of the powerful, released and documented iXML
If you look at the GET_ELEMENT subroutine in that function module, you'll see that the nodes of type CO_NODE_CDATA_SECTION are simply ignored.
The simpliest thing for you, maybe, is to duplicate the code of SMUM_XML_PARSE (as it is rather easy to handle), and add a section to GET_ELEMENT. You'll have also to use IF_IXML_CDATA_SECTION interface and ixml_iid_cdata_section constant.
Documentation is here: [SAP Library: Interface if_ixml_cdata_section|http://help.sap.com/saphelp_nw70/helpdata/en/bb/576658dca511d4990b00508b6b8b11/frameset.htm ]
Best regards,
Sandra -
Strange problem in converting between XML to string and vice versa
i have an application that needs to send an XML document
over the wire. For this reason, I need to convert the
doc into a String at the sending side and back to Doc
at the receiving side. This document is stored in a "CLOB"
column in a table in the database. I use XDK to retrieve
this entire row (including the CLOB - hence this is an XML
document which has a column that itself is an xml document in
string format - this is just the clob read in by XDK).
Thus the row looks like
<ROWSET>
<ROW>
<col1> A <col1>
<CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
</ROW>
</ROWSET>
When I convert this document into String and back, one of the "<"
tags in the clob column document gets changed to "<" and hence
the parsing fails! I have used the latest label of the XDK build
to get the latest parser jar but still i have the same problem.
I am using the following routines for the conversion.
/* for converting document to string */
public static String convertToString(XMLDocument xml) throws
IOException
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
xml.print(pw);
String result = sw.toString();
return result;
/* for converting string to document */
public static XMLDocument convertToXml(String xmlStr)
throws
IOException,SAXException
ByteArrayInputStream inStream = new
ByteArrayInputStream(xmlStr.getBytes());
DOMParser parser = new DOMParser();
parser.setPreserveWhitespace(false);
parser.parse(inStream);
return parser.getDocument();How do you get the XML document? Do you use XSU? You can use:
String str = qry.getXMLString();
to get the result XML document in String.
XSU will escape all of the < and >. Or the the XML document in
one of the column will make the result XML doc not well-formed.
Not quite understand your problem. You can send me your test
case.
i have an application that needs to send an XML document
over the wire. For this reason, I need to convert the
doc into a String at the sending side and back to Doc
at the receiving side. This document is stored in a "CLOB"
column in a table in the database. I use XDK to retrieve
this entire row (including the CLOB - hence this is an XML
document which has a column that itself is an xml document in
string format - this is just the clob read in by XDK).
Thus the row looks like
<ROWSET>
<ROW>
<col1> A <col1>
<CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
</ROW>
</ROWSET>
When I convert this document into String and back, one of the "<"
tags in the clob column document gets changed to "<" and hence
the parsing fails! I have used the latest label of the XDK build
to get the latest parser jar but still i have the same problem.
I am using the following routines for the conversion.
/* for converting document to string */
public static String convertToString(XMLDocument xml) throws
IOException
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
xml.print(pw);
String result = sw.toString();
return result;
/* for converting string to document */
public static XMLDocument convertToXml(String xmlStr)
throws
IOException,SAXException
ByteArrayInputStream inStream = new
ByteArrayInputStream(xmlStr.getBytes());
DOMParser parser = new DOMParser();
parser.setPreserveWhitespace(false);
parser.parse(inStream);
return parser.getDocument(); -
Converting XML Document to String
Dear All,
I am quite new to Java Web Services. I have made a Java Class which calls all the web services . I am displaying the results on a Command prompt. Below is my sample code:
import javax.xml.rpc.Service;
import javax.xml.rpc.Stub;
import horusWS.Horus_x0020_Web_x0020_Services_Impl;
import horusWS.Horus_x0020_Web_x0020_ServicesSoap;
public class JavaClient {
public static void main(String[] args)
Horus_x0020_Web_x0020_Services_Impl service = new Horus_x0020_Web_x0020_Services_Impl();
Horus_x0020_Web_x0020_ServicesSoap port = service.getHorus_x0020_Web_x0020_ServicesSoap();
String str;
str = port.getTextFeedbackLearner(1,"P001",1);
//where getTextFeedbackLearner is the my Web Service.
System.out.println(str);
System.out.println returns the web service in string format. Now I want to compare this string to my actual getTextFeedbackLearner.xml file. But I think I need to convert getTextFeedbackLearner.xml to string first. Please let me know
how can I convert an XML Document to String.
Thanking you in Anticipation.
cheers,
Sunil SabirYou can read the XML document as you read any other file.
Read it into a String variable.
Check java.io.FileReader, java.io.BufferReader, etc. -
Special charecters handling while Converting XML string to DOM
Hi,
I am using the following approach for converting XML string to DOM, but due to Special characters like "&", I am getting Exceptions:
String xmlString;
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(xmlString)));
Can anyone please help me out on how to handle the Special characters in the above code.If the XML doesn't parse, then the XML must be invalid. Show a sample of such a special character in the XML data. Please use \ tags to post the actual XML content and any other code.
-
Converting XML as table to XML as string
All,
I am successfully able to convert XML table from Internal Table. Now, I would like to convert this XML Table into XML string.
Any help on this will be appreciated.
Regards,
Salil
Moderator message: please search for available information/documentation before asking.
Edited by: Thomas Zloch on Dec 7, 2010 11:57 AMHowdy,
CONCATENATE LINES OF lt_table into l_string SEPARATED BY cl_abap_char_utilities=>cr_lf.
This will create a string of the lines of the internal table with a carriage return after each line.
Cheers
Alex -
Hi All,
Can you please let me know for any sample code in xslt/java mapping for converting XML string into XML. We use SAP Pi 7.0
My XML string starts like this
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MT_ReceiverFileStructure <namespace>"><Output><?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<xsl>"?><Tarih_Date Tarih="11.09.2014" Date="09/11/2014>
Thanks,
PavithraThanks Praveen. It worked.
However, the xml i have is an extract from a exchange rate URL and it has the reference to a xsl in it as below
<?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<ABC.xsl>"?>.
So there is an error in sxmb_moni. Is it possible to remove this. -
Hi all,
I have a question here regarding converting XML string into a DOM document.
How can I do this in Java?
The Document.Parse() methods do not have one that takes in String as its parameter.
I'm not sure what is the best way to do this in Java.
Any help is greatly appreciated.
Thank you in advance.
regards,
SeanConvert XML String to Document with StringReader.
String xmlString;
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(xmlString)));
Maybe you are looking for
-
Error message when Elements starts installation process and halts
Mac OS 10.7.2 on a 13" macBook Air 1.8 ghz intel Core i7 4 GB Ram 20GB unused SSD space, After clicking "trial" and entering my Admin pasword, the install starts but then halts with the following messages: Exit Code: 24 ------------------------------
-
Photoshop wont open get error could not open a scratch file because the disk is not available
Had to clone my hard drive to another drive on my computer. I have been receiving a message "Could not open a scratch file because the disk is not available" I have tried UN-installing and re-installing...still the same message. Does anyone have any
-
How do I install plug ins to Premiere Pro CC?
I just downloaded Pro CC and my New Blue Plug Ins are missing. What do I do?
-
Sqlplus and db starup/shutdown job
hello dear all , I need some help to starup and shutdown the database oracel 9.i though job how ca I put a job to startup and shutdown the database with sqlplus
-
Is it possible to widen my browser to fit on the personas since they always seem to get cut?
Basically, all the personas that I try on my browser get half cut of so only the top half shows but I'd like to know if I can widen it to fit? I know it probably sounds stupid but let me know if this is possible