Convert XML using XSLT mapping
Hi,
I have an XML in the following format and would want to cnvert it in the target format shown below. Kindly let me know the XSLT mapping to conert from hierarchy to flat structure.
<u><b>Source XML:</b></u>
<group Level1="Mac Tools Item Classifications">
<group Level2="6-Other Merchandise">
<group Level3="61-Racing">
<group Level4="011-Collectibles">
<group Level5="001-NASCAR"/>
<group Level5="002-NHRA"/>
<group Level5="003-Other"/>
</group>
<group Level4="012-Apparel">
<group Level5="001-Jackets"/>
<group Level5="002-Shirts"/>
<group Level5="003-Other">
<group PartNumber="SHOE823-060"/>
<group PartNumber="SHOE823-070"/>
<group PartNumber="SHOE823-080"/>
<group PartNumber="SHOE823-085"/>
<group PartNumber="SHOE823-090"/>
</group>
</group>
</group>
</group>
</group>
<u><b>Target XML:</b></u>
<Group>
<part>
<Level1/>
<Level2/>
<Level3/>
<Level4/>
<PartNumber/>
</part>
<part>
<Level1/>
<Level2/>
<Level3/>
<Level4/>
<PartNumber/>
</part>
</Group>
I am not clear how to capture level1, level 2, etc. till the end node.
Regards,
Swaroopa
HI,
This is a sample
<b>
<xsl:variable name="var0_floatToString" select="user0:floatToString(/body/getQuote/inputGetQuote/@customerIDFloatAttr)"/>
<xsl:if test="@customerIDFloatAttr">
<xsl:attribute name="customerIDFloatAttr">
<xsl:value-of select="@customerIDFloatAttr"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="customerIDAttr">
<xsl:value-of select="$var0_floatToString"/>
</xsl:attribute></b>
using <xsl:attribute name here name ="leval1" like that u can use in XSLT Mapping .
Hope it helps
Regards.,
V.Rangrajan
Similar Messages
-
EDI flat file to X12 xml using XSLT mapping
Hi all,
I have a scenario EDI File -> XI -> file. Here on the source side, it is a txt IDOC document. I have created an XSLT mapping to convert txt document to X12 xml.
Can any body please suggest that what should be the message type that i need to choose at source inbound message?
Thanks
-KulwantHi
It is not very clear from what you have explained above..
1) whats the format when the msg enters XI?
2) which stage of the flow this XSLT mapping is located...??
3) when you say that your XSLT converts txt to xml, then whats the ROOT tag you use??
4) whats your incoming msg structure??
make the above clear for better answers
Regards
Vishnu -
Invalid tag generated in result XML file, xslt mapping done using MAPFORCE
HI
My requirement is File to File using xslt mapping
I have done a very simple XSLT mapping, but through MAPFORCE tool
Here are the steps, I followed:
1. Supplied source xsd and xml file to MAPFORCE
2. Supplied target xsd file
3. mapped it as required
4. tested by supplying a sample xml file by clicking OUTPUT button, which displays perfect XML structure
5. Clicked XSLT button and copied and created a new file with extension .xsl file
6. Zipped the above xsl file
7. imported into IR imported archives folder
8. Selected the above xslt mapping in my Interface mapping.
9. Now tested my Interface Mapping by supplying sample some data for the source structure.
Now I got the error or warning "XML not well-formed" and got the successfull completion message window for my mapping when I proceed.
Now when I clicked xml source button for the target structure, It displays the invalid tag and starting with "#default"
So If I removed this particular tag at the first and last lines, it becomes a valid xml structure and able to see properly in my internet explorer
Here is the result I am getting:
<?xml version="1.0" encoding="UTF-8"?>
<#default:MT_Student_Result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:xsltMappingScenarios C:/DOCUME~1/Satya/Desktop/MT_Student_Result.xsd">
<Data>
<Name>Khan Raj</Name>
<Marks>
<Total_Marks>166</Total_Marks>
</Marks>
</Data>
</#default:MT_Student_Result>
When I tested through MAPFORCE it generates absolutely valid XML structure when I clicked OUTPUT button on MAPFORCE, but not when I used the xslt mapping through my interface mapping.
What is the error I am making or any step missing?
Please help me!
Edited by: Shilpa Shetty on Oct 9, 2008 4:17 AM
Edited by: Shilpa Shetty on Oct 9, 2008 5:58 AM
Edited by: Chris Rock on Oct 9, 2008 6:06 AMFor some reason when I use MapForce tool to generate my xslt mapping source, it is generating the following statement in the xsl file.
<xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default"/>
So at the root element of XML file, it is replacing the character n with '#default' for some reason, I don;t know the purpose of this.
As you suggested, I changed the name space, still I experienced same problem.
It is now resolved after removing the above xsl statement from the xsl file before creating/uploading the relevant zip file into archives folder.
It works fine now. Thanks for the clue. -
Using XSLT mapping to avoid File content conversion
Hi all,
Can we avoid FCC by using XSLT mapping? I have a scenario in which I have to avoid FCC in the adapter and save the file in a excel/csv format. I have been through the different blogs and forums in SDN.
I have been through Michal Krawczyk's Blog https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2803. [original link is broken] [original link is broken] [original link is broken] [original link is broken]
Got a bit confused whether that blog serves my purpose. Expecting your valid inputs.
Thanks and regards,
Harikumar. SHi,
There are multiple ways in which you can avoid Content Conversion in the Sender / Receiver File adapters.
I think there was a heated discussion already regarding this in one of your earlier threads,
Read/Write csv files without file converter
Basically, if you want to avoid content conversion on the sender file adapter,
1. Write an Adapter Module. or,
2. Use a Java Mapping.
If you want to avoid content conversion on the receiver File adapter,
1,. Use a Adapter Modules or,
2. Use Java Or XSLTmapping ( XSLT can be used if the input to the mapping is XML and output needs to be say a Excel File etc).
Regards
Bhavesh -
How to skip first TWO Lines of .txt file using XSLT Mapping
Hi Friends ,
I have an .txt file in has the format as
<TEST>
4564564545
56456444566
56465
How can i skip the first two Lines when i am writing the XSLT Mapping ?
That <TEST> and empty line shouldn't go the rfc .
How can i skip and sent to rfc using XSLT Mapping ?
Best Regards .,
V.Rangarajanyou can avoid the empty lines in your File Content Conversion by defining offset.
<i>Under Document Offset, specify the number of lines that are to be ignored at the beginning of the document.
This enables you to skip comment lines or column names during processing. If you do not make an entry, the default value is zero lines.</i>
ref: http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm
then the generated XML after FCC will not have the empty lines. -
Sorting on specific field using XSLT Mapping
Hi All,
I am trying to sort the records on specific field using XSLT mapping.But I'm unable get the proper output for the following code.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://xxxxxxxx">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<a:T1>
<Row>
<xsl:for-each select="a:S1/Record">
<xsl:sort select="EmpID" />
<EMPID>
<xsl:value-of select="EmpID"/>
</EMPID>
<ENAME>
<xsl:value-of select="EmpName"/>
</ENAME>
</xsl:for-each>
</Row>
</a:T1>
</xsl:template>
</xsl:stylesheet>>
Currently getting following output :
http://www.flickr.com/photos/21390012@N04/2074799747/
Expected output should be like below :
http://www.flickr.com/photos/21390012@N04/2074807393/
Kindly send me suggestion to achieve this.
Regards
PullaraoHi ,
I donno much about srting in XSLT but i can give you one example on that.
Example :
This is how to sort numbers in xslt.
Try this :
<xsl:for-each select="learn[@kind='done']">
<xsl:sort select="number(@rank)" data-type="number"/>
<table border="00" cellpadding="3" width="100%">
<tr>
<td width="100" valign="top" align="right"><input type="checkbox" checked="checked" readonly="readonly"/></td>
<td width="10" valign="top" align="right"><xsl:value-of select="position()"/>. </td>
<td valign="top">
[<xsl:value-of select="@rank"/>] <xsl:value-of select="@title"/>
</td>
</tr>
</table>
<table border="00" cellpadding="3" width="100%">
<tr>
<td width="100"> </td>
<td valign="top">
<xsl:apply-templates/>
</td>
</tr>
</table>
</xsl:for-each>
Regards
Aashish Sinha
PS : reward points if helpful -
File TO File-Using XSLT mapping (for Beginners) --- Error in XSLT
Hi,
I am following this wiki (TO File-Using XSLT mapping (for Beginners))
https://wiki.sdn.sap.com/wiki/display/XI/FileTOFile-UsingXSLTmapping%28forBeginners%29
When creating Xslt from the MapForce, when I click on the XSLT Tab I am getting the following error
http://www.flickr.com/photo_zoom.gne?id=1216715484&size=o
How to correct this error ?.....
Thanks
srini
Message was edited by:
srinivasHello,
The XSD you are using is from Data Type and you are using it for mapping.
Instead export XSD for Message Type and also pass the XML schema for source that will solve the issue and your XSLT will be generated.
Regards, -
Remove SOAP Envelop using XSLT mapping.
Hi,
I need a code to remove SOAP Envelop using XSLT mapping.
Source:
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
<soapenv:Body>
<getServerTimestampResponse>
<result>
<timestamp>2008-06-19T14:22:25.004Z</timestamp>
</result>
</getServerTimestampResponse>
</soapenv:Body>
</soapenv:Envelope>
target:
<?xml version="1.0" encoding="UTF-8" ?>
<a>
<b>
<c>2008-06-19T14:22:25.004Z<c>
</b>
</a>
Please help me in this
Thanks&Regards,
Yugahi,
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<ns0:c>
<xsl:copy-of select="SOAP-ENV:Envelope/SOAP-ENV:Body"/ />
</ns0:c>
</xsl:template>
</xsl:stylesheet>
This will get your whole body...
Your root node should belong to some namesapce...i.e. getServerTimestampResponse .
Thanks,
Vijaya. -
How to Count schedule lines in IDoc ORDERS05 using XSLT Mapping
Hi Experts,
In a Scenario where we are sending Purchase order (ORDERS05) to SAP SNC using XSLT Mapping,
where in we need to count the no. of schedule lines against the Purchase Order line.
As in Schedule line segment there is no such provision, so it needs to be handle in XSLT mapping to count the schedule lines.
Can you all please guide me how to go about the same.
Regards,
Nitin PHi Satish,
Thank you very much for the reply,
as there is only Quantity and other information is maintained against schedule lines how we can count the schedule line repeatation against PO line ? Is that very simple as you suggested or some other consideration also needs to be taken.
Please clarify the same and let me also know if there are some standard documents also for the same.
Regards,
Nitin P -
ERROR WHILE USING XSLT MAPPING IN INTERFACE MAPPING
Hi,
We are using an xslt mapping in our scenario but while i load the XSLT mapping in the interface mapping i get a message :
Transformer configuration exception occurred when loading XSLT
sorce interface :outbound and asyncronous.
mapping : XSLT mapping (imported as a zip file)
target interface: abstract,asyncronous.
The xslt runs well in standalone and its well formed and there is no name space issue.
please help if any one has faced such a situation while using XSLT mapping.
regards,
Anirban.Hi Anirban
When you say it runs well <i>standalone</i> what exactly do you mean? Which XSLT processor are you using to run it? There are subtle difference between XSTL processors that can sometimes result in incompatibilities. For instance, I have seen XSLTs run correctly in XMLSpy but incorrectly (or at least slightly differently) in XI.
Regards,
Thorsten -
Advantages of using XSLT mapping
Can any one explain me the advantages of using XSLT mapping compare to graphical.java and abap mappings
Hi
Please go through the below links for details on XSLT Mappings..
XSLT Mapping
/people/udo.martens/blog/2006/04/26/xslt-recursive-templates
Thread:
Sample XSLT mapping required
XSLT Mapping Links::->
/people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping
/people/sreekanth.babu2/blog/2005/01/05/design-time-value-mappings-in-xslt
/people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping
XSLT Mapping with java enhancement
/people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners
XSLT - ABAP.
/people/r.eijpe/blog/2005/11/04/using-abap-xslt-extensions-for-xi-mapping
exception handling errors in respect with XSLT mapping
http://help.sap.com/saphelp_nw2004s/helpdata/en/8a/7672f7d7e444439fd7024f806221a4/content.htm
Hope this will help
Regards
Piyush
**reward points if found useful. -
Change Filename using XSLT mapping without variable subtitution
Hi,
My scenario is IDOC to file...i am using XSLT mapping, i want to change the filename format to OUT_<Purchase Number>_<DDMMYYYYhhmmss>_KKKK.txt, i cannot use UDF function as i do XSLT mapping i also i cannot use variable substitution as the target structure doesn't have PO and timestamp as tag elements. Can i acheive using writing a adapter module? I appreciate if anyone could help me with this..
Many thanks>
Ravibabu Adari wrote:
> Hi,
> If i go with Option1: what changes i need to do in the file adapter to tell the adapter to pick the filename from XSLT ?
> If i go with Option2: To which element to the target structure should i map the filename using UDF ? do i have to add additional element to the target structure? what changes i need to do in the file adapter to tell the adapter to pick the filename from Message mapping ?
>
> Many thanks
Hi,
in both cases you need to enable file adapter specific properties and enable the file name...
for this you need to use the dynamic configuration properties for the same...
usage of this option using udf in message mapping is rather easy than to use in XSLT...for this you dont need to change the structure in the message mapping...message mapping is just needed for execution of the udf.. thats it..
HTH
Rajesh -
IDOC Generation Using XSLT Mapping[Query]
Hi,
I am working on File to IDOC scenario. I have used XSLT mapping. It is necessary to generate EDI_DC40 segment for IDOC in XSLT?
-KavitaHi Kavita,
please take a look at note: 728792
(Fields of the IDoc control record )
it describes your scenario
Regards,
michal -
Get the file name using XSLT mapping
Hi
How to get the file Name at receiver side using XSLT mapping.
Could any one please help me
Regards
sowmyaSowmya
If you will use Grpahical Mesage Mapping then this can be achieved using Adapter-Specific Attribute u201CFileNameu201D
http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
Code Snippet -->
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
u201Chttp://sap.com/xi/XI/System/Fileu201D,
u201CFileNameu201D);
But in case you have to ONLY use XSLT mapping then I would suggest to use the same jave code & call it from your XSLT mapping. I never tried such thing you might use couple of jar files too.
- lalit - -
Can we use XSLT mapping after graphical Mapping
Hi,
Can we use XSLT mapping after graphical mapping?
My requirement is to generate two namespace attributes in the target output.
So first I want to generate a structure using graphical mapping and then want to use XSLT mapping only to generate the second namespace XSI (leaving the rest of the structure as it is). Is it possible?
<ns1:Test xmlns:ns1="wmdata.dwbi.interface" xsi:schemaLocation="wmdata.dwbi.interface w_interface_1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Please post some solution. (I will reward points)
Br,
Madan AgrawalHi Madan,
Can we use XSLT mapping after graphical mapping?
To me it seems feasible...
But to using the two mappings one after another you will have to use BPM .
Use transformation step for this to use the mapping and change in structure.
Regards,
Maybe you are looking for
-
ID CS4 Anti-Alias problems with Linked files
All the linked files i have put into Indesign CS 4 whether they are PSD, Tiff,layered or flat have shown up slightly pixelated. When i print the same file from its native program (in this case Photoshop CS4) the files print clean and crisp and the te
-
Custom field in VA01 at item level in Additional Data B Tab
Hi , I have a requirement to add a custom field at item level in Additional Data B tab of VA01/VA02. We have to store the data in that field in the VBAP table also have to validate the data entered in the field when user hit save. Can any body tell m
-
Transfering itunes music from old 20" G5 to new 24" iMac via DVD
OK got the new 24" iMac, love it. Have the old 20" G5 with all my purchest songs and copied CDs albums on it .... OK so I burned 2 DVDs of all the songs about 1200 of them and am trying to transfer them onto my new iMac well it only lets about 130 so
-
I decided to erase the disk on Macbook Pro late 2011 model and do a clean reinstall of Mavericks. When I tried to restore the software I get an error message that says something like "installation information for this machine is not available - call
-
how to copy psd actions and brushes etc from CS2 to PS6 libraries?