‎2009 May 14 2:32 PM
Hello,
I have a trasnformation and something in this transformation is not logical. why do I have to write after the expression for-each, <item>????
<ROOT>
<LIST>
<xsl:for-each select="/pre:XmlInterchange/pre:Payload/pre:Organisations/pre:Organisation/pre:OrganisationDetails/pre:Addresses/pre:Address">
<item>
<NAME>
<xsl:value-of select="string(../../pre:Name)"/>
</NAME>
if I delete the expression <item> I get a short dump, the funny thing is that I can write whatever I want for the expression <item> and it works
So following I don't understand, why do I have to write it?
‎2009 May 14 5:00 PM
Hi,
I have done a little XLST, but never used 'for-each'. So I am just speculating...
Maybe the <item> element is mandatory for the parser in order to bound each item of the for-each?
I think someone more experienced with the topic would tell us!
‎2009 May 14 5:03 PM
what I not understand is that <item> is not a command, I can wrote in this < > somethinf else and it works
‎2009 May 14 8:24 PM
Only elements which have the namespace xls for example <xls:for-each> are part of the XSLT. In your example <item> is an element (not part of the XSLT) that will be copied to the result as is. That's why there is no problem with your XSLT. If I understood your question correctly.
The best website for XSLT is [http://w3schools.com]
‎2009 May 14 8:32 PM
Actually. Can you post your entire XSLT? Might help to answer your question.
‎2009 May 14 10:02 PM
this is my xslt which works very well, but I understand not why I have to write the element <item> on the top and on the buttom.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pre="http://www.edi.com.au/EnterpriseService/" version="1.0">
<xsl:template match="*">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<LIST>
<xsl:for-each select="/pre:XmlInterchange/pre:Payload/pre:Organisations/pre:Organisation/pre:OrganisationDetails/pre:Addresses/pre:Address">
<item>
<NAME>
<xsl:value-of select="string(../../pre:Name)"/>
</NAME>
<COUNTRY>
<xsl:value-of select="string(../../pre:Location/@Country)"/>
</COUNTRY>
<CITY>
<xsl:value-of select="string(../../pre:Location/@City)"/>
</CITY>
<LOCATION>
<xsl:value-of select="string(../../pre:Location)"/>
</LOCATION>
<ADDRESSLINE1>
<xsl:value-of select="string(pre:AddressLine1)"/>
</ADDRESSLINE1>
<ADDRESSLINE2>
<xsl:value-of select="string(pre:AddressLine2)"/>
</ADDRESSLINE2>
<ADDRESSCODE>
<xsl:value-of select="string(pre:AddressCode)"/>
</ADDRESSCODE>
<CITYORSUBURB>
<xsl:value-of select="string(pre:CityOrSuburb)"/>
</CITYORSUBURB>
<STATEORPROVINCE>
<xsl:value-of select="string(pre:StateOrProvince)"/>
</STATEORPROVINCE>
<POSTCODE>
<xsl:value-of select="string(pre:PostCode)"/>
</POSTCODE>
<LANGUAGE>
<xsl:value-of select="string(pre:Language)"/>
</LANGUAGE>
</item>
</xsl:for-each>
</LIST>
</ROOT>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
‎2009 May 15 8:29 AM
Hi,
Logically(for me) the <item></item> element is very much required. Let me explain..
From your XSLT code the source/result XML should look like below rite...
<ROOT>
<LIST>
<ITEM> " First Item
<NAME>
Jose
</NAME>
<COUNTRY>
India
</COUNTRY>
.
.
<LANGUAGE>
English
</LANGUAGE>
</ITEM>
<ITEM> " Second Item
<NAME>
ABAP OO Beginner
</NAME>
.
.
<LANGUAGE>
English
</LANGUAGE>
</ITEM>
</LIST>
</ROOT>Here if you have only one item, element <item> is not required. But for the other cases(multiple items), the XML document is not proper without <item>....
~Jose
‎2009 May 15 9:59 AM
but instead of <item> I can write whatever I want, this is what I not really understand, as item is not a expression
‎2009 May 15 10:15 AM
Hi,
With the very limited knowledge on ABAP <-> XML conversions using XSLT, I assume
this conversion is for converting SAP data to XML format... If it is so, the name of element does not
matter at all becoz <item> is just going to be the element name in the result XML document
1) If it is <item> , the result XML document will be like in the above message.
2) Or if it is <somethingelse> the result XML document will be
<ROOT>
<LIST>
<somethingelse> " First Item
<NAME>
Jose
</NAME>
<COUNTRY>
India
</COUNTRY>
.
.
<LANGUAGE>
English
</LANGUAGE>
</somethingelse>
<somethingelse> " Second Item
<NAME>
ABAP OO Beginner
</NAME>
.
.
<LANGUAGE>
English
</LANGUAGE>
</somethingelse>
</LIST>
</ROOT>~Jose.
Edited by: Jose on May 15, 2009 2:46 PM
‎2009 May 15 4:59 AM
Hello
Again many important pieces of information are missing in order to answer your question. However, I assume your scenario looks like this:
- You have an XML file with data
- You want to make an XSLT transformation XML -> ABAP (using CALL TRANSFORMATION)
DATA:
ld_xml TYPE string,
lt_data TYPE <table type>.
"... Upload XML file into string
CALL TRANSFORMATION ID 'Z_MY_XSLT'
SOURCE ld_xml
RESULT itab = lt_data.
I think to remember that this transformation expects each record of the ABAP itab to be defined as <ITEM> structure (complex sequence) in the XML.
You may also replace the <xsl:transform> statement with <xsl:stylesheet> and check if you still need <item> or if you can use any other name.
Regards
Uwe
‎2009 May 15 10:19 AM
Hi,
The element <item> (or whatever the name) seems just to declare the item that are to be repeted with the for-each. Like some kind of a container...
‎2009 May 15 2:05 PM
Please provide the following, if you'd like further discussion on this.
1) A sample XML that you are transforming
2) Your CALL TRANSFORMATION with the declaration of variables used in it
If no further discussion needed, then, in my opinion, Uwe Schieferstein answered your question.