Convertion of String to XML node using Xquery transformation in OSB
How to convert string to XML node elementusing a built in function using Xquery transformation in OSB?
check this out - http://www.javamonamour.org/2011/06/fn-beainlinedxml.html
if in SOA (BPEL & Mediator) you can use oraext:parseXML.
you should thoroughly analyse where to implement your requirement as some good practices advise to implement more complex logic in SOA and leave OSB to only connect to the services' endpoints.
Hope this helps,
A.
Similar Messages
-
Convertion of XML node to string using Xquery transformation in OSB
How to convert XML node to string using a built in function using Xquery transformation in OSB? In BPEL we have the Xpath extension function ora:getContentAsString() to do the same.
fn:bea-serialize() function converts xml node to string. but it assigns namespace prefix in every xml node during the conversion. So is there any function to remove the namespace prefix from XML node using Xquery built in function?
-
Can't convert string element to XML node using XSL
We have a source XML with a node that contains another XML as string. Like this:
"<imp1:payload><?xml version = '1.0' encoding = 'ISO-8859-15' standalone = 'no'?>
<!-- Oracle eXtensible Markup Language Gateway Server --><!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd"><PROCESS_PO_007><CNTROLAREA>" etc
And we have a target XML that has the schema inside the string in the source file, like this:
"<PROCESS_PO_007>
<CNTROLAREA>"....etc.
How can we "parse" the string to a node using an XSL transformation file?Hi,
Can you tell me which code are you using currently for transferrring the data? It might help me to figure out what your problem is. -
Assign default namespace to XML fragment using XQuery
Hi everybody!
I need to add a default namespace declaration to a XML fragment using XQuery. I wrote following statement to assign fragment to $body:
<soap-env:Body>{
fn-bea:inlinedXML($content/text())}
</soap-env:Body>
The problem is "$content/text()" has no namespace declaration so I need to assign a default namespace (xmlns="") to it in order to apply some XQuery transformations to its content.
I know this can be easily done with a XSLT but I would like use XQuery instead.
Could anyone tell me how I could perform this task?
Thank you in advance,
Daniel.Re: xquery function - send namespace as binding variable and define it in a tag
-
How to add all namespaces in root node of xquery transformation result?
Hi,
I'm using xquery Transformation in oracle service bus to transfrom output. The schema used for output transfromation has elements being imported from several schemas. so that output xml has these long tags with namespaces of repective schemas e.g.
<rr:Get360ViewOfProductResponse xmlns:rr="http://canaldigital.com/schema/product/CPMProductInformation/v2.0/">
<ResponseHeader>
<com:ResponseCode xmlns:com="http://broadcast.telenor.com/tsi/common/commonparameters_v1" >0</com:ResponseCode>
<com:ResponseText xmlns:com="http://broadcast.telenor.com/tsi/common/commonparameters_v1" >0</com:ResponseText>
</ResponseHeader>
</rr:Get360ViewOfProductResponse>
what I want to achieve is that all namespaces come once in the rootNode and all childnodes just use the repective prefixes, so that the xml size doesnt grow too large.Like below.
<rr:Get360ViewOfProductResponse xmlns:com="http://broadcast.telenor.com/tsi/common/commonparameters_v1" xmlns:rr="http://canaldigital.com/schema/product/CPMProductInformation/v2.0/" xmlns:pr="http://broadcast.telenor.com/tsi/common/program_v1">
<ResponseHeader>
<com:ResponseCode>0</com:ResponseCode>
<com:ResponseText>0</com:ResponseText>
</ResponseHeader>
</rr:Get360ViewOfProductResponse>
the difference is that ResponseCode and responseText should only use their prefix, and not complete namespace. How can i acheive this.
Thanks in advance.
Edited by: 856401 on Feb 9, 2012 1:53 AMI get error 'Invalid expression- Unexpected token copy-namespaces'. Is it supported by xquery version 1.0 ? Following is the updated xquery transformation which gives static error:
xquery version "1.0" encoding "Cp1252";
(:: pragma bea:global-element-parameter parameter="$get360ViewOfProductResponse1" element="ns5:Get360ViewOfProductResponse" location="../XSD/CPMSchema_v20.xsd" ::)
(:: pragma bea:global-element-return element="ns6:Get360ViewOfProductResponse" location="../XSD/CPMSchema_v3.xsd" ::)
declare namespace ns2 = "http://broadcast.telenor.com/tsi/common/displayinformation_v1";
declare namespace ns1 = "http://broadcast.telenor.com/tsi/common/commonparameters_v1";
declare namespace ns4 = "http://broadcast.telenor.com/tsi/common/Property_v2";
declare namespace ns3 = "http://broadcast.telenor.com/tsi/common/ProductMain_v2";
declare namespace ns0 = "http://broadcast.telenor.com/tsi/common/condition_v1";
declare namespace ns9 = "http://broadcast.telenor.com/tsi/common/extension_v1";
declare namespace ns5 = "http://broadcast.telenor.com/tsi/psd/cpm/CPMSchema_v20";
declare namespace ns6 = "http://canaldigital.com/schema/product/CPMProductInformation/v3.0/";
declare namespace xf = "http://tempuri.org/CPM_OSB_v3/XQuery/Get360ViewOfProductResponse/";
declare namespace ns7 = "http://broadcast.telenor.com/tsi/common/productofferingpricewithrules_v2";
declare namespace ns8 = "http://broadcast.telenor.com/tsi/common/pricecomponent_v2";
declare copy-namespaces preserve, inherit;
declare function xf:Get360ViewOfProductResponse($get360ViewOfProductResponse1 as element(ns5:Get360ViewOfProductResponse))
as element(ns6:Get360ViewOfProductResponse) {
<ns6:Get360ViewOfProductResponse>
<ResponseHeader>
<ns1:ResponseCode>0</ns1:ResponseCode>
<ns1:ResponseText>{ data($get360ViewOfProductResponse1/responseDescription) }</ns1:ResponseText>
</ResponseHeader>
</ns6:Get360ViewOfProductResponse>
declare variable $get360ViewOfProductResponse1 as element(ns5:Get360ViewOfProductResponse) external;
xf:Get360ViewOfProductResponse($get360ViewOfProductResponse1) -
Creating XML file Using Call Transformation
Hello Friends,
I have searched before posting thread, couldnt find anything.
I am creating an XML file using Call Transformation. My internal table has 3 date fields and some other fields. For some records I dont have values for the date fields. In that case my XML file is giving the date value as 0000-00-00 since I declared it as Date type. This value 0000-00-00 is not accepted by the middle ware as the valid date. I can not change it as String type as per the suggestion.
In that case I am advised to skip printing the date field tag if it doesnt have value.
Is there any way to skip the date field if it is empty. Any Suggestions please ?.
Thanks
Lakshmi.Hi,
I had exactly the same problem before. When you call a transformation there is an option called initial_components. According to SAP if you use initial_components = 'SUPRESS' the empty fields should not being generated on the XML.
Now, this didn't work for me and I have seen some people with the same problem. Here is how I solved this (maybe not the best way but it worked):
First: My fields are all CHAR in my table
Second: In the transformation, you can use conditional transformation to not display a tag if field is empty, here a piece of my transformation (I am using simple transformations):
<tt:root name="ROOT"/>
<tt:cond s-check="not-initial(ref('ROOT.L1_NM')) or not-initial(ref('ROOT.L2_NM'))">
<TRNMTR_NM>
<tt:cond s-check="not-initial(ref('ROOT.L1_NM'))">
<l1_nm>
<tt:value ref="ROOT.L1_NM"/>
</l1_nm>
</tt:cond>
<tt:cond s-check="not-initial(ref('ROOT.L2_NM'))">
<l2_nm>
<tt:value ref="ROOT.L2_NM"/>
</l2_nm>
</tt:cond>
</TRNMTR_NM>
</tt:cond>
As you can see, I first check if the fields have values.
Hope it helps
Edited by: carlosrv on Oct 4, 2011 8:22 PM -
Problem with Xquery transformation in OSB
hi,
My scenario is that I have to break the data in a single tag of xml A, to populate multiple tags of xml B.I am using Xquery transformation and substring function to achieve this. The problem comes when i import the xquery resource in OSB and try to do the transformation in a proxy service it gives the following error
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-382510</con:errorCode>
<con:reason>
*OSB Assign action failed updating variable "message": com.bea.wli.common.xquery.XQueryException: Error parsing XML: {err}XP0006: "element {http://schemas.xmlsoap.org/soap/envelope/}Body { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type element {http://www.example.org/data}data { {http://www.w3.org/2001/XMLSchema}anyType }*
</con:reason>
<con:location>
<con:node>PipelinePairNode1</con:node>
<con:pipeline>PipelinePairNode1_request</con:pipeline>
<con:stage>stage1</con:stage>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>
the configuration i have done in the proxy service is this::_
Assign: [XQuery resource..] to [message]
Delete: [.] in [body]
Insert [$message] [as first child of][.] in [body]
The Xquery resource is the .xq file that i have generated for Xquery transformation.
and i m routing this proxy service to a business service that wud take the XML and dump it to my D drive using file protocol.
Edited by: rahulc on Oct 12, 2010 12:40 AM
Edited by: rahulc on Oct 12, 2010 12:41 AMMy Xquery is this::
(:: pragma bea:global-element-parameter parameter="$data1" element="ns0:data" location="data.xsd" ::)
(:: pragma bea:global-element-return element="note" location="note.xsd" ::)
declare namespace ns0 = "http://www.example.org/data";
declare namespace xf = "http://tempuri.org/OSB_Try/tag_break/";
declare function xf:tag_break($data1 as element(ns0:data))
as element(note) {
<note>
<to>
fn:substring(data($data1),
1 ,
6)
</to>
<from>
fn:substring(data($data1),
7 ,
6)
</from>
<heading>
fn:substring(data($data1),
13 ,
6)
</heading>
<body>
fn:substring(data($data1),
19 ,
11)
</body>
</note>
declare variable $data1 as element(ns0:data) external;
xf:tag_break($data1)
and my data is this::
<?xml version="1.0"?>
<ns0:data xmlns:ns0="http://www.example.org/data">DON'T FORGET ME THIS WEEKEND!</ns0:data>
and i have tested this zquery for the above data and this is the transformation its doing::
<note>
<to>DON'T </to>
<from>FORGET</from>
<heading> ME TH</heading>
<body>IS WEEKEND!</body>
</note>
Edited by: rahulc on Oct 12, 2010 1:57 AM -
Hi
can any body tell how to make xquery transformation for the requirement like source as xml and target as schema,please provide related links if any
Thanks
Manihttp://docs.oracle.com/cd/E13160_01/wli/docs10gr3/dtguide/
http://docs.oracle.com/cd/E13159_01/osb/docs10gr3/userguide/xquery.html
Already a thread is available.
sample examples for doing XQuery transformation within OSB
Hope this helps.
Thanks,
Vijay -
How to call business service from xquery transformation in OSB ??
Hi All,
How to call business service from xquery transformation in OSB ??
I need to assign the response variable of Business Service to a target element in XQuery Transformation Mapper file.
It's urgent.
Regards,
Jyoti NayakTransformation is to mapping the source and target of 2 different schemas.
In your case you should have a XQuery transformation between, your Business Service output schema and the target schema.
Thanks,
Vijay -
String to XML conversion using XSLT
Hi all,
I have a scenario when my source input XML is in the form of a string which needs to be transformed into an XML target fields.
I am using XSLT mapping to do that and its working but unfortunately, input XML contain xml declaration <?xml version='1.0'?>. Because of which it fails.
I need to remove this. Can any body please suggest how to do this?
Any help will be appriciated.
Regards
-KulwantHi,
Refer these links
XI/PI: Convert Flat File to Deeply Nested XML Structures Using Only Graphical Mapping
Regards,
Surya -
Converting Delimited string to XML message
Hi,
We are trying to convert pipe delimited string into a xml schema using a XSD and BPEL funtion. Consider a scenario in which message has 5 fields with last as 2 optional fields. So the incoming string message can be like "1|2|3" or "1|2|3|4|5". In this case how the XSD should look like, since for each field we have to give "terminatedby" option in the XSD. So the issue is coming for element 3 where the delimiter can be "|" or "eol" (end of line). How to specify that ? Is there any option to use like "optionally terminated by?"
Any help will be appreciated.
Thanks,
Ramesh
Edited by: rameshchandra85 on 2 Aug, 2010 10:00 AMHi Ramesh,
You can use below XSD for input file of kind
1|2|3
1|2|3|4|5
1|2|3|4
1|2|3|4|5|6
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
targetNamespace="http://TargetNamespace.com/InboundService"
xmlns:tns="http://TargetNamespace.com/InboundService"
elementFormDefault="qualified"
attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
<xsd:element name="Root-Element">
<xsd:complexType>
<xsd:choice minOccurs="1" maxOccurs="unbounded" nxsd:choiceCondition="terminated" nxsd:terminatedBy="|">
<xsd:element name="RECORD1" nxsd:conditionValue="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C3" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD2" nxsd:conditionValue="2">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C3" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C4" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C5" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD3" nxsd:conditionValue="3">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C3" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C4" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RECORD4" nxsd:conditionValue="4">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C2" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C3" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C4" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C5" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy=""">
</xsd:element>
<xsd:element name="C6" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<!--NXSDWIZ:D:\DBIN\ReadFile.txt:-->
<!--USE-HEADER:false:-->But in your case if you are getting 5 elements instead of 3 elements in some other file....Use the same and maipulate the last element afterwards.
I think we can not have an element definition for two scenarios.
Update you if i get any..
Regards
PavanKumar.M -
Retrieve xml attribute value of nth xml node using xpath query
I have an xml with following stucture...
<xml>
<header>
<DocumentReference OrderId="order001">
<DocumentReference OrderId="order002">
<DocumentReference OrderId="order003">
I have to loop through this xml and retrieve the orderId values inside Biztalk orchestration.
In the expression shape, I get the count of 'DocumentReference' nodes using an xpath query and then
Added a loopshape to make sure it loops thru all nodes
Loop condition: n<=nodeCount (where n is an integer variable, n=0 to begin with, incremented by 1 thru each loop, nodeCount is # of DocumentReference nodes)
I try retrieve to the orderId in the following expression shape using the below xpath query
xpathQuery = System.String.Format("//*[local-name()='OrderReference'][{0}]/@orderID)",n);
sOrderId = xpath(MsgSingleInvoice,xpathQuery);
And I get the following exception:
Inner exception: '//*[local-name()='OrderReference'][1]/@orderID)' has an invalid token.
Exception type: XPathException
Appreciate any help! thanks!Thanks for the quick response. I got rid of it.
And I see a different error:
Inner exception: Specified cast is not valid. Exception type: InvalidCastException
Source: Microsoft.XLANGs.Engine
Target Site: System.Object XPathLoad(Microsoft.XLANGs.Core.Part, System.String, System.Type)
Since variable 'n' is of integer type, I suspected it and changed it to n.ToString() and tested again and still see the same error. -
How to convert a string into xml file
Hi,
i have a string . the string contain fully formated xml data. i mean my string like below
<?xml version="1.0"?>
<PARTS>
<TITLE>Computer Parts</TITLE>
<PART>
<ITEM>Motherboard</ITEM>
<MANUFACTURER>ASUS</MANUFACTURER>
<MODEL>P3B-F</MODEL>
<COST> 123.00</COST>
</PART>
<PART>
......................i want to convert it into an xml file
can u help me?
thank uThank you Paul Clapham,
and sorry ..
i have some other doubt.. regarding xml
i want to post an XML file from one server(Server_1) to other server.(Server_2)
To generate an xml file i used DOM in Server_1.
using xml.transform , StringWriter i converted it into String.
I post the string to another server and there i will parse it.
for that i write the code like below in servlet in server_1
<form name=fn action=http://localhost:8080/server_2/parseXMl.do method=post>
<input type=hidden name=xmlFile value="+Xmlstring+">
<input type=submit >is this process is correct?
Some of the turorial told that use web-services/XML-RPC
but i new to both..
I want to complete it using my knowledge only/
Is it possible to do it?
Or any other alternative?
can help me? -
Edit XML node using actionscript?
How would I go about editing an XML node from within
actionscript?
I load the XML from a file, and before I pass it to an
HTTPService I would like to set the field DateTime. The XML file
that I am using can be seen here:
XML Document
When I try doing something like
myXML.fiAPI.fiHeader.Service.DateTime="time here", it creates a new
fiAPI node with all new children. However, I wish to edit the
current DateTime field without creating a new one.
All help is appreciated.Thanks to both of you.
ctzn99: I tried that as well, after realizing my mistake.
However, it still does not work. I'm certain I have the path right,
but nothing is set (or in other cases, returned). Even when I use
myXML.fiHeader..., It creates a new fiHeader node and the
corresponding nodes underneath it.
ntsiii: That's a very complex example, like you said...
almost overkill for my problem?
Thanks though! -
How to Get and Update properties values from XML tag Using Xquery or PL Sql
Hi
I have this tag
<Solicitud Pais = "1">
How i can get Pais value?
How i can update Pais Value?
Y can use Xquery funtions or PL SQL for this?
Thak's
AngelHow i can get Pais value? ExtractValue
How i can update Pais Value?UpdateXML
Y can use Xquery funtions or PL SQL for this?Yes
Without knowing more about your requirements, where information resides, or even a version of Oracle, that is the best I'll do.
Maybe you are looking for
-
C++ speak the text libraries, not sure which option in the project to include
Hi, i have downloaded all the necessary libraries to speak the text, here the link to the project libraries: http://www.codeproject.com/Articles/17897/audio-ostream-A-Text-to-Speech-ostream and they require to include them in the project settings. Pr
-
I am trying to download songs onto my PC it gets to about 85% downloaded and then freezes I have to turn off and restart but then I have been charged for the item but it is not available in my downloads can anyone help?
-
WRT54G behind another Linksys router
the WRT 54 is donated and we are trying to expand to cover more computers from our original 8 pport Linksys rouoter and add wireless. Plugged the WRT internet into a port from the original router and it shows the IP address as 192.168.1.1xx for each
-
Acrobat DC scanner only ICA interface no TWAIN?
Hello, After upgrading to Acrobat DC I can no longer access TWAIN drivers for two of my scanners: Canon MX920 series, CanoScan LiDe 500F. I am on Mac OS X 10.9 machine. They were working fine with Acrobat XI. The only scanner driver available is Cano
-
Disable column scrolling in grid
Hi there. Is there some possibility to block the first column of grid from scrolling? For example when grid is wider than screen - a horizontal scrollbar appears. So how to do such thing that whole grid is scrolling except first column? Greetings. P.