On Thu, 7 Nov 2002, Joerg Heinicke wrote: > normally this won't work. You create a Result Tree Fragment in $colours > and have to convert it to a node set using node-set() extension > function. This is not possible when using XSLTC.
The nodeset extension is supported under XSLTC in Xalan as of v2.4.1, although this is at an early stage of development. http://xml.apache.org/xalan-j/extensions_xsltc.html#nodeset_ext *** An alternative implementation of a lookup table in XSL can provide values as first-class nodes: Declare lookup namespace -- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:colormap="Lookup table for colors."> The table itself must be the first thing in the stylesheet, prior to any other top level elements, that's why we establish a namespace for it -- <colormap:color id="white">#fff</colormap:color> <colormap:color id="black">#000</colormap:color> <colormap:color id="gray">#888</colormap:color> Because document() called upon an empty string returns nodes within the stylesheet tree, we can reference these within the stylesheet like so -- <xsl:template match="foo"> <xsl:variable name="colour" select="@colour"/> <bar> <xsl:attribute name="colour"> <xsl:value-of select="document('')/*/colormap:color[@id = $colour]"/> </xsl:attribute> </bar> </xsl:template> I have not tested this, but I expect the performance drag represented by the document() function is minimized when it returns the already parsed stylesheet tree. cheers, Mike > > You may find, if you re-encode your lookup table as XSLT variables, that > > you can 'include' your data as XSLT into your stylesheet. > > > > eg. > > > > constants.xslt: > > > > <xsl:variable name="colours"> > > <colour id="white">#fff</colour> > > <colour id="black">#000</colour> > > <colour id="grey">#888</colour> > > </xsl:variable> > > > > main.xslt: > > > > <xsl:include src="constants.xslt"/> > > > > ...... > > > > <xsl:template match="foo"> > > <xsl:variable name="colour" select="@colour"/> > > <bar> > > <xsl:attribute name="colour"> > > <xsl:value-of select="$colours[@id=$colour]"/> > > <!-- or is it: <xsl:value-of > > select="$colours/colours[@id=$colour]"/> --> > > </xsl:attribute> > > </bar> > > </xsl:template> > > > > Hope this helps > > > > regards Jeremy > > > --------------------------------------------------------------------- > Please check that your question has not already been answered in the > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> > > To unsubscribe, e-mail: <[EMAIL PROTECTED]> > For additional commands, e-mail: <[EMAIL PROTECTED]> > > ---------------------------------------------------------------- Mike Haarman [EMAIL PROTECTED] --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>