on 02-10-2010 2:50 AM
Hi all,
I'm sorry if my question is a bit off the topic / subject. I want to ask something about XI excel xslt transformation.
For ex. I have 2 worksheets, Header and Lineitems. Header details appear on one row only. The problem lies within the Lineitems. I can have multiple lineitems. I tried testing it in XI. I duplicated the ITEMS source node. But In the output,only one row is being created. I tried using the 'for-each' function but it did not work. I also tried apply-templates, did not work also. The code is somewhat like this:
<Row>
<xsl:for-each select="xxx/yyy/ITEM"/>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="xxx/yyy/ITEM/VAR"/>
</Data>
</Cell>
</Row>
For every instance of ITEM node, I need to output a new Row. How can I do this in XSLT?
Any help would be greatly appreciated.
Thanks!
IX
Hi IX,
Couple small things. First, your for-each is an empty node. You need to remove the trailing slash and close the for-each node when your looping is finished. Second, the path to VAR should be relative since you are inside a loop.
<xsl:for-each select="/xxx/yyy/ITEM">
<Row>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="./VAR"/>
</Data>
</Cell>
</Row>
</xsl:for-each>
Thanks,
-Russ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks.
your code worked russel. i have a problem though if the xpath is not the same as the VAR.
ex.
<xsl:for-each select="/xxx/yyy/ITEM">
<Row>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="xxx/yyy/HEADER/VAR"/>
</Data>
</Cell>
</xsl:for-each>
output is not being shown when i use <xsl:value-of select="xxx/yyy/HEADER/VAR"/> or <xsl:value-of select="./VAR"/>. How can I use a variable from the HEADER node.
You need the root slash in your path to the HEADER nodes. Otherwise, it's looking here /xxx/yyy/ITEM/xxx/yyy/HEADER/VAR
<xsl:for-each select="/xxx/yyy/ITEM">
<Row>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="/xxx/yyy/HEADER/VAR"/>
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="./VAR"/>
</Data>
</Cell>
</Row>
</xsl:for-each>
i have one last question russell, what if i'm using a condition?
EX.
<xsl:for-each select="/ns0:SAPSRMRFQAward_CSV_MT/Recordset/ITEM">
<Row>
<Cell>
<Data ss:Type="String">
<xsl:choose>
<xsl:when test="xxx/yyy/ITEM/PLANT='000'">
<xsl:if test="/xxx/yyy/HEADER/PURCH_ORG='1000'">
<Data ss:Type="String">"'1000'"</Data>
</xsl:if test>
</xsl:when>
<xsl:otherwise>
<Data ss:Type="String">
<xsl:value-of select="./PLANT"/>
</Data>
</xsl:otherwise>
</xsl:choose>
</Cell>
</Row>
</xsl:for-each>
im getting the correct output for the otherwise block. i'm getting a blank for the if block. is there something wrong again with my xpath?
no need.. thanks!!!!
Edited by: Ignatius - Xavier Bazar on Feb 10, 2010 4:57 PM
The for-each does not seem to have been used properly....take help from this online example:
http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=tryxsl_for-each
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
try to use,
<xsl:for-each select="xxx/yyy/ITEM"/>
<Row>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="xxx/yyy/ITEM/VAR"/>
</Data>
</Cell>
</Row>
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.