Reputation: 5537
Is it possible to store all content nodes as an array and pass to another template? I Have tried but cannot get it tho work. My select expression is selecting the correct nodes.
<xsl:variable name="array" select="/data/contents/content[ ..... ] />
<xsl:value-of select="$array/.../... " />
<xsl:variable name="bannerList" select="data/contents[$dayOfWeekIndex]/content[position() <= 5]" />
<xsl:apply-templates select="$bannerList" mode="article">
<xsl:with-param name="numberOfBanners" select="count($bannerList)" />
</xsl:apply-templates>
I would like to use call-template instead and send the bannerList as a parameter.
Upvotes: 0
Views: 1091
Reputation: 3138
Yes, it is easily approachable, have a look:
XML:
<body>
<RIAssetType><text>Product</text></RIAssetType>
<RIAssetType><text>Service</text></RIAssetType>
<RIAssetType><text>Company/Business Unit</text></RIAssetType>
<RIAssetType><text>Technology</text></RIAssetType>
<RIAssetType><text>Intellectual Property/Data Only</text></RIAssetType>
</body>
XSLT:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="body">
<copyBody>
<xsl:call-template name="childCopy">
<xsl:with-param name="bodyChild" select="self::body/child::*"/>
</xsl:call-template>
</copyBody>
</xsl:template>
<xsl:template name="childCopy">
<xsl:param name="bodyChild"/>
<xsl:for-each select="$bodyChild/self::*">
<xsl:copy>
<xsl:copy-of select="."/>
</xsl:copy>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
<copyBody>
<RIAssetType>
<RIAssetType>
<text>Product</text>
</RIAssetType>
</RIAssetType>
<RIAssetType>
<RIAssetType>
<text>Service</text>
</RIAssetType>
</RIAssetType>
<RIAssetType>
<RIAssetType>
<text>Company/Business Unit</text>
</RIAssetType>
</RIAssetType>
<RIAssetType>
<RIAssetType>
<text>Technology</text>
</RIAssetType>
</RIAssetType>
<RIAssetType>
<RIAssetType>
<text>Intellectual Property/Data Only</text>
</RIAssetType>
</RIAssetType>
</copyBody>
It seems you got struct in XPATH somewhere, please check again.
Upvotes: 1