Subject:Problem with Xalan with variables Author:Giuseppe Cardon Date:29 Apr 2005 01:43 PM Originally Posted: 29 Apr 2005 01:27 PM
Hi,
I have written an xslt that work well with the Stylus built-in processor, but if i choose the others processors like Xalan-J or Saxon the templates are not getting applied. It must work with xalan-J because I have to use it with the java compiler that use Xalan. The problem is with the using of variables with the "ATTRIBUTE-SET" element.
I have a code like this
<xsl:stylesheet>
<xsl:template name="NameOfTemplate">
<xsl:for-each select="NODE">
<xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable> <xsl:element name="NEWELEMENT" use-attribute-sets="ELEMENT ATTRIBUTES"/>
</xsl:for-each>
</xsl:template>
<xsl:attribute-set name="ELEMENT ATTRIBUTES">
<xsl:attribute name="NAME"><xsl:value-of select="concat('xxx',$id)"/></xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>
In the attribute-set ELEMENT ATTRIBUTES I use the value of the variable and with the built-in processor it work good but with Xalan it can find the name of the variable ( I think is out of scope). How I can do ???
Subject:Problem with Xalan with variables Author:Ivan Pedruzzi Date:30 Apr 2005 12:24 AM Originally Posted: 30 Apr 2005 12:25 AM
Ciao Giuseppe
There are two problems with your code: the attribute-set name is not valid name because contains spaces, the attribute-set uses a variable that is out of scope.
Subject:Problem with Xalan with variables Author:Giuseppe Cardon Date:30 Apr 2005 02:54 AM
In the example I haven't used the same name of the variable and element of my real code. In the real code I not have spaces. I can't use the method u said because I don't have to use the variable only in the name of the element but in many attributes of it. For example: