Find processing instructions in XSLT

To get the value of a processing instruction from the input XML document in an XSLT stylesheet, use the /processing-instruction(name) function. I use a username PI in my XML-formatted ASP responses to pass the logged-in user parameters to XSLT, for example ...
<?user Web admin (admin@something.net) {00000000-0000-0000-0000-000000000000}?>
To get this string into an XSLT parameter, I use the following XSLT instruction:
<xsl:param name="username" select="/processing-instruction('user')" />

A processing instruction can appear anywhere in the XML document. To find processing instructions that are not children of the root element, use the appropriate XPath syntax.

No comments:

Post a Comment