Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Possible to keep a variable value after for-each >Thread Next - Re: Possible to keep a variable value after for-each Re: Possible to keep a variable value after for-eachTo: NULL Date: 5/1/2009 12:57:00 PM Gina_Marano wrote:
> ok, I will try to make an example:
>
>
> <parts>
> <component>
> <description>Item123_cover</description>
> <color>white</color>
> <weight>80</weight>
> <component>
> <component>
> <description>Item123_block</description>
> <weight>100</weight>
> <pagecount>156</pagecount>
> <component>
> </parts>
>
> -note, the above can be in any order
>
> generating:
>
> <order>
> <cover>
> <color>white</color>
> <case>(if Item123_block.weight = 100 then 'A' if
> Item123_block.weight = 80 then 'B')</case>
> </cover>
> <block>
> <pagecount>156</pagecount>
> <weight>100</weight>
> <size>8x11</size>
> </block>
> <block>
>
> NOTE: the <cover><case> is dependant on the Item123_block's weight.
I am not sure whether the contents of the case element is meant to be
literal content you want to generate or some attempt to use a pseudo
code language to show what you want.
In case that is meant literal then here is a stylesheet:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="parts">
<order>
<xsl:variable name="b" select="component[contains(description,
'block')]"/>
<xsl:variable name="c" select="component[contains(description,
'cover')]"/>
<xsl:variable name="A" select=""'A'""/>
<xsl:variable name="B" select=""'B'""/>
<cover>
<xsl:copy-of select="$c/color"/>
<case>
<xsl:value-of select="concat('(if ', $b/description,
'.weight = ', $b/weight, ' then ', $A, ' if ', $b/description,
'.weight = ', $c/weight, ' then ', $B, ')')"/>
</case>
</cover>
<block>
<xsl:copy-of select="$b/pagecount"/>
<xsl:copy-of select="$b/weight"/>
<size>8x11</size>
</block>
</order>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
