XSLT 1.0 - Create node set and pass as a parameter -
using xslt 1.0, i'm trying create small node set , pass parameter template, following:
<xsl:call-template name="widget"> <xsl:with-param name="flags"> <items> <item>widget.recent-posts.trim-length=100</item> <item>widget.recent-posts.how-many=3</item> <item>widget.recent-posts.show-excerpt</item> </items> </xsl:with-param> </xsl:call-template>
the idea within widget
template write like:
<xsl:value-of select="$flags/item[1]" />
obviously compile errors.. how can achieve sort of thing?
there way (non-standard) in xslt 1.0 create temporary trees dynamically , evaluate xpath expressions on them, however requires using xxx:node-set()
function.
whenever nodes dynamically created inside body of xsl:variable
or xsl:param
, type of xsl:variable
/ xsl:param
rtf (result tree fragment) , w3 xslt 1.0 spec. limits severyly kind of xpath expressions can evaluated against rtf.
as workaround, every xslt 1.0 vendor has own xxx:node-set()
extension function takes rtf , produces normal node-set it.
the namespace xxx
prefix (or other prefix choose) bound different different vendors. msxml , 2 .net xslt processor is: "urn:schemas-microsoft-com:xslt"
. exslt library uses namespace: "http://exslt.org/common"
. namespace exslt implemented on many xslt 1.0 processors , recommended use xxx:node-set()
extension, if possible.
here quick example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext msxsl" > <xsl:template match="/"> <xsl:variable name="vtemprtf"> <a> <b/> </a> </xsl:variable> <xsl:copy-of select="ext:node-set($vtemprtf)/a/*"/> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment