XSLT Code
HI,
Can anybody explain me where should i write the xslt code for error handling and how to use this error handling in Xi ?
Regards,
Tuhin
Hi All,
I followed this thread for a while. Because I'm also interested in good error handling during mapping.
I just experimented with throwing a Runtime Exception. This stops mapping but the error message is buried within a large stack trace in the ErrorHeader of the XI-Message.
I'm still searching for a method where the ErrorHeader clearly shows my error message like ...
<i> <SAP:ErrorHeader xmlns:SAP="http://sap.com/exchange/MessageFormat">
<SAP:Context></SAP:Context>
<SAP:Code p1="Error during mapping"
p2="Field value XYZ out of Range"
p3=""
p4="">MAPPING.GENERIC</SAP:Code>
<SAP:Text language="EN">Error during mapping</SAP:Text>
</SAP:ErrorHeader></i>
Regards,
Marc
Similar Messages
-
Xslt code to replace a node name to include ns0 prefix
Hi,
Is there some easy xslt code to change the following: (I want the ns0 tag and namespace introduced in the root node so that my mapping works. I have created the mapping using externally provided wsdl, but the input message expects the prefix ns0 whereas the message coming to me from third party does not have the prefix. So in order to force it through the mapping I am thinking of using xslt to translate <createOrUpdateJobsResponse> to <ns0:createOrUpdateJobsResponse xmlns:ns0="http://service.webservice.xxxxxxxx.com"> and the closing tag </createOrUpdateJobsResponse> to </ns0:createOrUpdateJobsResponse>.
Source:
<?xml version="1.0" encoding="UTF-8"?>
<createOrUpdateJobsResponse>
<createOrUpdateJobsReturn>
<errorCode/>
<errorMessage/>
<goodResult/>
<jobReferenceNumber/>
</createOrUpdateJobsReturn>
</createOrUpdateJobsResponse>
Target:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:createOrUpdateJobsResponse xmlns:ns0="http://service.webservice.xxxxxxxx.com">
<createOrUpdateJobsReturn>
<errorCode/>
<errorMessage/>
<goodResult/>
<jobReferenceNumber/>
</createOrUpdateJobsReturn>
</ns0:createOrUpdateJobsResponse>Hi James,
You could give a try with this :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://service.webservice.xxxxxxxx.com" version="1.0">
<xsl:output indent="yes" omit-xml-declaration="no"/>
<xsl:template match="/">
<ns0:createOrUpdateJobsResponse>
<xsl:apply-templates/>
</ns0:createOrUpdateJobsResponse>
</xsl:template>
<xsl:template match="createOrUpdateJobsReturn">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
It should recreate the same msg structure with a ns0 namespace for the output document
Rgds
Chris -
Dear SAP experts,
Would you be able to help me in configuring the right xslt code to accomodate the looping logic?
Source Document:
School (occur only once)
- Name (can occur multiple times)
- Nickname (occur only once)
- Desired name (occur only once)
Target Document:
School
- Name
- Nickname (the value for this should be obtained from 'Desired name field')
- Desired name
I have this code, but seems not working in looping logic. (to accomodate the multiple Names):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Order/OrderDetail/ListOfItemDetail/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/BuyerPartNumber">
<BuyerPartNumber>
<PartNum>
<PartID>
<xsl:value-of select ="/Order/OrderDetail/ListOfItemDetail/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/ManufacturerPartNumber/PartID"/>
</PartID>
</PartNum>
</BuyerPartNumber>
</xsl:template>
</xsl:stylesheet>
What happened is that the value was taken ONLY on the 1st line item. (1st Name occurence)
The succeeding Name field just copied the value of Nicknames from the 1st Name field.
Kindly advise how to handle the context (loop logic) in the xslt code.
Thanks!Apologies, but, it seems i did not indicate the complete message structure for the document I am testing.
Order (root)
OrderHeader (1st parent segment)
OrderNumber (child fields - 1st)
Order.. (child fields - 2nd)
Order...(child fields - 2nd)
OrderDetail (1st parent segment)
<fields under this segment were already mentioned from previous threads>
OrderSummary (1st parent segment)
NumOfLines (child fields - 1st)
TotalAmount (child fields - 1st)
Under Order, there are also OrderHeader and OrderSummary parent segment, other than OrderDetail, in which we focus our code.
I've tried your code, but, the segments OrderHeader and OrderSummary and child fields under it were not appearing on my output.
But it seems, I've already generated the correct code.
Here it is,
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" media-type="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:template match="/Order/OrderDetail/ListOfItemDetail/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/BuyerPartNumber">
<xsl:for-each select=".">
<BuyerPartNumber>
<PartNum>
<PartID>
<xsl:value-of select="../ManufacturerPartNumber/PartID"/>
</PartID>
</PartNum>
</BuyerPartNumber>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I believe, the code you've suggested last time will accomodate only OrderDetail parent segment. Is this correct?
Thanks! -
Hello,
Can someone help me to give an XSLT code for the following condition?
Source Message:
/Order/Ident/ReceiverID = 203
Condition:
If the value of Source ReceiverID is 203, then, make it to the value to 456.
I've tried this code, but seems to be many error validations.
<xsl:template match="/Order/Ident/ReceiverID">
<xsl:choose>
<xsl:when test="203">
<xsl:attribute name="203">
<xsl:value-of select="456"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="203">unknown</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Should you have helpful links, please let me know. I will greatly appreciate it.
Thanks in advance!
GerbertoGerberto,
Try this -
<xsl:choose>
<xsl:when test="*[local-name()='ReceiverID']='203' ">
<ns:YourField>
<xsl:value-of select="456"/>
</ns:YourField>
</xsl:when>
<xsl:otherwise>
<ns:YourField>
<xsl:value-of select="203"/>
</ns:YourField>
</xsl:otherwise>
</xsl:choose>
Let me know if this works for you.
Regards,
Neetesh -
Hi All,
I am doing on XSLT Mapping. It is having a lookup. Lookup is working fine and I am getting data back in one variable say 'Var1'.
Now in my mapping all the field are mapped one to one from source to target except one field say "lookup' and I am mapping responce of RFC 'Var1' variable to this node.
My XSLT code is as follows:
<TargetNode>
<Field1><xsl:value of select="/Isourcenode/Field1"/></Field1>
<Field2><xsl:value of select="/Isourcenode/Field2"/></Field2>
<Lookup><xsl:value of select="$Var1"/></Lookup>
<Field3><xsl:value of select="/Isourcenode/Field3"/></Field3>
<Field4><xsl:value of select="/Isourcenode/Field4"/>/<Field4>
</TargetNode>
Now here I get value of Variable Var1 in Lookup field whereas all the fields after that node like Field3,Field4 are not getting mapped value.
Do I need to do anything special to access the nodes values in xpath once i access variables using $ ?
Thanks and Regards,
AtulHi,
You can use CALL TRANSFORMATION <NAME> to meet your requirement
For an example, refer:
Re: help in Xml to abap
Thanks,
Aabhas -
Hi Mates,
I have requirement like
need to check value endwith Y then add comment line and populate output field using XSLT mapping.
Ex:
Input :Source=KolkataY
check Source is ends with Y
then Add comment line and populate Source =Kolkata
Please provide XSLT code for this requiremet.
Thanks
JAYANWhy do you need XSLT code ? it can be acheived by simple graphical mapping standard functions
if input endswith y then input concatenate with comment and pass to target
regards
Ninad -
Need an Custom XSLT code... where i need to compare 2 attribute fields( Name and Start Date) fromInputMessagePart_0 with the 2 fields ( Name and Start Date) from InputMessagePart_1 and need to map the repetitive attribute field ( phoneno) from InputMessagePart_1
to attribute field( PhoneNo of Destination schema.
this will look like this
Source Schema
Destination Schema
InputMessagePart_0 Item
Record
- Name
-Name
- StartDate
- StartDate
- Addres
- PhoneNo
InputMessagePart_1
-Name
-StartDate
-PhoneNo
Final output should look like by
Details
Name
StartDate
PhoneNo
Details
Name
StartDate
PhoneNo
Details
Name
StartDate
PhoneNo
Details
Name
StartDate
PhoneNo
Need urgent assistance
Thank you in advance
BizTalkLearnercould you also post your sample input instance and expected output instance
Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply. -
Anyone can check my xslt code ?
i've tried to use JAXP to transform xml by using xslt. the java program has been written and compiled, but when i tried to run it, it come out the errors:
error: 'unknown protocol: c'
fatal error: 'could not compile stylesheet'
i was suspecting my xslt code might be wrong, could anyone check for me ? i'm quite new to xslt, probably will make lots of silly mistakes.
xml file: http://www.bbc.co.uk/travelnews/tpeg/en/local/rtm/rtm_tpeg.xml
xslt file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="tpeg_document/tpeg_message">
<xsl:value-of select="summary"><xsl:text>;<\xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
any suggestions will be appreciated,
cheers,i'm not sure whether it'll be the case, but you migt be right. i posted my java source code here:
public class FileDownload {
public static void download(String address, String localFileName){
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
StringBuffer xmlContentBuffer = new StringBuffer();
String temp = new String();
String xmlContent;
try {
URL url = new URL(address);
out = new BufferedOutputStream(
new FileOutputStream(localFileName));
conn = url.openConnection();
in = conn.getInputStream();
byte[] buffer = new byte[1024];
int numRead;
long numWritten = 0;
System.out.println (in.toString ());
while ((numRead = in.read(buffer)) != -1) {
out.write(buffer, 0, numRead);
numWritten += numRead;
temp = new String(buffer);
xmlContentBuffer.append(temp);
System.out.println(localFileName + "\t" + numWritten);
xmlContent = xmlContentBuffer.toString();
String xsltString;
FileInputStream xslt= new FileInputStream ("Tpeg.xslt");
int x= xslt.available();
byte b[]= new byte[x];
xslt.read(b);
xsltString = new String(b);
String htmlString = XmlUtil.applyXslt(xmlContent, xsltString);
System.out.println(htmlString);
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
if (out != null) {
out.close();
} catch (IOException ioe) {
public static void download(String address) {
int lastSlashIndex = address.lastIndexOf('/');
if (lastSlashIndex >= 0 &&
lastSlashIndex < address.length() - 1) {
download(address, address.substring(lastSlashIndex + 1));
} else {
System.err.println("Could not figure out local file name for " + address);
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
download(args); -
XSLT code giving emplty output
Hi ,
i am a beginer in XSLT. when i execute the code i am getting emplty structure.
Can anyone point out what is missing in my code, are the xpath expressions correct??
input Xml will look as below
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
<Person>
<FirstName>James</FirstName>
<LastName>Bond</LastName>
<Gender>Male</Gender>
<Address>
<Street>6B</Street>
<Houseno>bbbb</Houseno>
<City>AAAA</City>
</Address>
</Person>
</ns0:MT_XSLT_Source>
my output should be...
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_XSLT_Target xmlns:ns0="http://XYZ.com/Gen">
<Title>Male</Title>
<Name> James Bond</Name>
<Street> 6B bbbb</Street>
<City>AAA</City>
</ns0:MT_XSLT_Target>
my XSLT code is as below .. ( i think the xpath's are not executing)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/Gen">
<xsl:template match="/">
<ns0:MT_XSLT_Target>
<Title>
<xsl:value-of select="/ns0:MT_XSLT_Source/Person/FirstName"/>
( i doubt issue is in xpath??)
</Title>
<Name>
<xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '),
Person/LastName)"/>
</Name>
<Street>
<xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/Address/Houseno,' '),ns0:MT_XSLT_Source/Person/Address/Street)"/>
</Street>
<City>
<xsl:value-of select="ns0:MT_XSLT_Source/Person/Address/City"/>
</City>
</ns0:MT_XSLT_Target>
</xsl:template>
</xsl:stylesheet>
Edited by: sam kumar on Aug 31, 2010 2:37 PMHi, take this code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/gen">
<xsl:template match="/">
<ns0:MT_XSLT_Target>
<Title>
<xsl:value-of select="ns0:MT_XSLT_Source/Person/FirstName"/>
</Title>
<Name>
<xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '),
Person/LastName)"/>
</Name>
<Street>
<xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/Address/Houseno,' '),ns0:MT_XSLT_Source/Person/Address/Street)"/>
</Street>
<City>
<xsl:value-of select="ns0:MT_XSLT_Source/Person/Address/City"/>
</City>
</ns0:MT_XSLT_Target>
</xsl:template>
</xsl:stylesheet>
I Just change the xmlns:ns0="http://XYZ.com/Gen" to xmlns:ns0="http://XYZ.com/gen"
Regards,
Edson Thomaz -
Xslt code - adding suffix value
Hello SAP experts,
May we seek advise from you on a working xslt code for adding suffix?
Source: 012345
Target: 012345HELLO
The suffix 'HELLO' will be placed at the end of the value.
Please advise.
Thanks!
Gerberto!take reference as follows:
<Name><xsl:value-of select="concat($fname, $lname)"/></Name>
In your case
<Name><xsl:value-of select="concat($srcnode, 'HELLO)"/></Name>
Regards
Liang -
Hi All,
I am working for a scenario with XSLT Mapping(For converting xml to html).
I get data into a field D_TXT with S_TXT as parent node. The data in D_TXT is space delimited. I need to split the data in D_TXT for every space in data and print the data items separatly in a row of table.
The code I wrote is:
"" <xsl:template name="temp">
<xsl:param name="x"/>
</xsl:template>
<xsl:template match="/">
<xsl:for-each select="Root/S_TXT">
<tr>
<xsl:call-template name="temp">
<xsl:with-param name="x" select="D_TEXT"/>
</xsl:call-template>
<xsl:for-each select=" $x [string-length('$x') > '0'] ">
<td><tt> <xsl:value-of select="substring-before($x,' ')"/></tt></td>
<xsl:call-template name="temp">
<xsl:with-param name="x" select="substring-after($x,' ')"/>
</xsl:call-template>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template> ""
The output I got is improper values in table.
Can u please correct the error in this code.
Thanks in advance.
Regards,
Lakshmi.The XSLT service is configurable.
http://help.adobe.com/en_US/LiveCycle/9.5/WorkbenchHelp/WS92d06802c76abadb-1cc35bda128261a 20dd-6750.html
1) Stop LiveCycle.
2) Add the .jars of your XSLT processor of choice to the LiveCycle server lib folder.
3) Restart LiveCycle.
4) Go to Workbench and stop the XSLT service. Right-click on XSLTService:1.0 and Edit Service Configuration.
5) Enter the factory name for the given XSLT processor. I think for Xalan 2.7.1 it is org.apache.xalan.processor.TransformerFactoryImpl (but I could be wrong).
6) Restart the service.
Steve -
Sample XSLT code to Display the Current date and time
Hi all,
Please Let me know code to display the system date in my target in xslt mapping.
I am trying fn:current-datetime() function for the same.but could not get how to use it .Is it function right function.If so please send me the examples on the same.
Thanks and Regards,
Srinihey
use this date:date-time()
also have a look at this
http://www.w3.org/TR/xpath-functions/#func-current-dateTime
thanx
ahmad -
HI,
I'm very new to BI Publishere. I've to modify the oracle case stmt into XLS.
CASE
WHEN TRUNC (a.X_EXPIRATION_DATE) < TRUNC (SYSDATE) THEN 'Expired'
ELSE 'Active'
END
Can any one help me out on it
Edited by: user10675696 on Jan 18, 2012 3:28 AMWhat is the format of your date column? You have to bring the expiration date and sysdate into the same formats and then compare. You could use substring function to compare the dates. See the folllowing link:
Date Comparison in BI Publisher Report
OR look here:
http://blogs.oracle.com/xmlpublisher/entry/date_functions
http://www.orafaq.com/forum/t/164844/0/
Thanks,
Bipuser -
Hi all,
In my XSL file I am using the following snippet
<xsl:attribute name="noNamespaceSchemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance" >
<xsl:text disable-output-escaping="no">../xsd/nikuxog_project.xsd</xsl:text>
</xsl:attribute>
The resultant output is...
<NikuDataBus xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance" ns2:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
What I want is, how to specify the prefix in xsl to be used. Because sometimes 'ns2' getting generated and sometimes it is 'ns1'!!!
I want to use 'xsi' instead of these prefixes.I think you need to add xmlns:xsi="http://www.example.org" on top of your xsl file.
Hope this helps
Thanks
Ram -
XSLT mapping code to replace ns1: tag as plm: in XML file in PI mapping
Hi
I am sending XML file to HTTP server as below format
<?xml version="1.0" encoding="UTF-8" ?>
- <ns1:Responses xmlns:ns1="http://">
- <ns1:Response Application="SAP">
<ns1:field1>12345</ns1:field1>
<ns1:field2>abc</ns1:field2>
- <ns1:Items>
<ns1:doc></ns1:doc>
</ns1:Items>
</ns1:Response>
</ns1:Responses>
i hve to replace <ns1: as <plm:, i could able to delete <ns1: tag uisng XSLT mapping(in sdn), but i dont know how to add tag with <plm:
Hi XSLT experts/if any has come across this requirment, please send XSLT code to add tag in XML.
Regards,
RajeshNo need for XSLT, just use the XMLAnonymizerBean module in your receiver communication channel.
http://help.sap.com/saphelp_nw70/helpdata/EN/45/d169186a29570ae10000000a114a6b/frameset.htm
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
If your receiver CC cannot process modules (ABAP receiver, for example), in your XSLT just define the target namespace with the desired prefix.
Regards,
Henrique.
Maybe you are looking for
-
Question on scanned images and coloring in Photoshop
I have some sketches from my drawing class that I would like to scan and color in Photoshop. I scan the sketch but I can't add color. I've tried 'lassoing' a portion of the drawing but the paint bucket still won't add color. What am I doing wrong? Pl
-
Iphoto library folder question.
Don't quite know how to word this one but here goes. If i go to Finder and click on the Pictures icon, i see an iPhoto Library icon. If i highlight that then click on the small wheel cog thing drop down menu above it and go to "Open With" i see sever
-
None of the apps I downloaded are opening. The screen just flashes a little, and goes back to the home screen,
-
OBYC Valuation and account assignment
Hi, when I create a purchase order for a material, system doesn't propose automatically the g.l. account (Purchasing account, EIN) that has been set in OBYC. I had a look in material master and the material has a valuation class assigned. I checked i
-
Don't want IPhoto to open when I plug in camera
Where can I set Iphoto to NOT auto launch when I plug in USB camera? I would rather just preview first and then import the few I want to save. Yes, I can just quit Iphoto but that's dumb.