Reputation: 31
I have this working correctly. I am looping through starting at position 3 and separating each addition value with a ;
so I can store the remainder of it in one CSV slot. This works, but I was wondering if there is any way I can store the entire lumped value as one variable along with the ;s
? So than I can later call it below to format my CSV?
My Code:
<xsl:for-each select="//act/templateId[@root='2.16.840.1.113883.10.20.22.4.3']/following-sibling::entryRelationship[@typeCode='SUBJ']/observation">
<xsl:if test="position() > 2">
<xsl:value-of select="value/@displayName"/>
<xsl:if test="position() != last()">;</xsl:if>
</xsl:if>
</xsl:for-each>
Thanks
Upvotes: 1
Views: 31
Reputation: 56182
Simply wrap you code into <xsl:variable name="x">
, then render this variable: <xsl:value-of select="$x"/>
as many times as you want.
Example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="x">
<xsl:for-each select="//item">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">;</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$x"/>
<xsl:value-of select="$x"/>
</xsl:template>
</xsl:stylesheet>
Input XML:
<root>
<item>1</item>
<item>2</item>
<item>3</item>
</root>
Upvotes: 1