Hi everyone,
Apologies if this is off-topic..
I am writing an XSLT where I want to pass an XPath statement in as a parameter. Like so:
<xsl:param name="contentXPath" select="'//content[@id=535]'" />
Note the single quotes around the XPath - the param is a string literal, not a node set.
I then want to go:
<xsl:apply-templates select="msxsl:node-set($contentXPath)">
</xsl:apply-templates>
But ASP.Net doesn't like this at all, in fact my web server crashes as soon as it attempts the transform. XMLSpy doesn't like it either. It works fine when I declare the param like this:
<xsl:param name="contentXPath" select="//content[@id=535]" />
Can anyone tell me if there's a way to get it to do what I want, or a workaround?
As background, I'm doing this because I need to calculate the XPath on the fly based on the current URL. It's basically a kind of URL rewriter - I'll convert /mypages/mypage.htm to /pagegroup[@title='mypages']/page[@title='mypage']
-
-
Hi Andrew,
You can't use the node-set function in that way surely? The node-set needs to operate on well a node-set, not a string literal. Maybe transfer this query over to http://www.xmlpitstop.com if you want to discuss further.
Cheers
Dave Mc -
Dave I suspect you're right. I've thought of a reasonably elegant workaround which I'll implement for now, and I'll post the question in that forum too. Thanks for the link!
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.