Q: Hi i have a strange issue with matching specific attribute of xml node. Example code that doesnt work:
or
<xsl:for-each select="../../unit/service/price/season[@name=$period_name]">
<xsl:attribute name="std_bed_price">
<xsl:value-of select="../@amount"/>
</xsl:attribute>
</xsl:for-each>
Example code that DOES work but i don't like this way too much:
<xsl:for-each select="../../unit/service/price/season">
<xsl:if test="@name = $period_name">
<xsl:attribute name="std_bed_price">
<xsl:value-of select="../@amount"/>
</xsl:attribute>
</xsl:if>
</xsl:for-each>
If in first example i replace the variable name with some of the values like 'A' it works, i also tested what variable name is selected and it has the correct data inside (so, 'A','B','C' ...)
Anyone had this problem before?
A: You might try changing it to an apply-templates instead of a foreach. Something like the following should work.
<xsl:template match="price">
<xsl:attribute name="std_bed_price">
<xsl:value-of select="@amount" />
</xsl:attribute>
</xsl:template>
And then call it like:
<xsl:apply-template select="../../unit/service/price/[season/@name=$period_name]" />
select="../../unit/service/price/season[./@name=$period_name]
No comments:
Post a Comment
Post Your Comment...