Hi List,
I have a setup where I want to store my HTML pages as XML and use XSLT
to apply common layout features, e.g. headers and footers. I also need
to pass dynamic data into some of the pages, and rather than process
everything twice I (perhaps foolishly) thought I could use parameters to
send the data in. So I have a $parameters variable which contains a
string something like '<parameters><namespace variable1="value"
variable2="value" /></parameters>'
In my HTML fragments where I want to place a variable, I use a call-out like
<variable name="namespace:variable1" />
Then in my XSLT I have this:
<xsl:template match="variable">
<xsl:variable name="a" select="substring-before(@name, ':')" />
<xsl:variable name="b" select="substring-after(@name, ':')" />
<xsl:value-of select="exslt:node-set($parameters)//*[name() =
$a]/@*[name() = $b]" />
</xsl:template>
[As an aside, I couldn't get the substring-before and -after to work
directly in the XPath expression. Am I missing something, or do they
need to be assigned to variables like that to be used?]
This all seems to work well enough when the $parameters string is set
inside the stylesheet, however when I try to pass it in as a global
parameter I get empty results. I know the string is making it in because
<xsl:value-of select="$parameters" /> prints out the escaped string.
What I can't figure out is why it is not being treated the same way as a
local variable would be.
Can anyone shed any light on this? I've spent 2 days banging my head
against Google so far. I am trying to do this with PHP 5.1.4 compiled
against libXML and lbXSLT, versions 2.6.23 and 1.1.15 respectively. I'd
like to finger PHP as the culprit, but I get the same results when
running xsltproc over the documents.
Regards,
Duncan
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--