L4zl0w
L4zl0w

Reputation: 1097

XSLT with nodeset as external parameter

I'm passing XML nodes to my JAVA transformer:

transformer.setParameter("orset", qRes);

The contents of qRes is similar to this:

<DOCTYPES>
    <SUBTYPE>Passport</SUBTYPE>
    <DOCTYPE>Proof of identity</DOCTYPE>
</DOCTYPES>
<DOCTYPES>
    <SUBTYPE>Driving License</SUBTYPE>
    <DOCTYPE>Proof of address</DOCTYPE>
</DOCTYPES>

I have a global parameter declared in my XSL file:

<xsl:param name="orset"/>

Can I access specific values from the parameter something like this:

<xsl:for-each SELECT="$orset/DOCTYPES">
<xsl:value-of select="$orset/DOCTYPES/DOCTYPE"/>
...

Or what would be the proper way of doing this?

Many thanks!

Upvotes: 3

Views: 2463

Answers (1)

Paul
Paul

Reputation: 4259

You are best to use the eXslt node-set function...

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl="http://exslt.org/common"
  extension-element-prefixes="exsl"
  version="1.0">
 ...
 <xsl:value-of select="exsl:node-set($orset)/DOCTYPES"/>
  ...
</xsl:stylesheet>

There are alternative node-set functions available based on your processor etc, they are all listed in the below reference.

http://www.xml.com/pub/a/2003/07/16/nodeset.html

Upvotes: 2

Related Questions