[DDI-users] XSLT: How to iterate over contained var's or varGrp's

I-Lin Kuo ikuo at icpsr.umich.edu
Wed Aug 11 16:30:04 EDT 2004


As far as I know, there is currently no other way in XSLT 1.0 to deal with this
kind of situation except for using extensions. XSLT 2.0, however, has methods
to do this, including a tokenize() function. However, only a few parsers have
implemented XSLT 2.0, the most notable being Saxon.

Quoting Andrew L Arnott <relate_webmaster at byu.edu>:

> Quick question on XSLT:
>
> If I have a varGrp with 5 var's referenced in it,
> <varGrp ID="VG1" var="V1 V2 V3 V4 V5"/>
>
> And of course the necessary variables also in the XML, then how do I iterate
> over those variables in XSLT?  I have used EXSLT to tokenize the string and
> then do a search like this:
> <xsl:variable name="IDlist"
> select="ExsltStrings:tokenize(/codeBook/dataDscr/varGrp[@ID='VG1']"/>
> <xsl:variable name="varList" select="/codeBook/dataDscr/var[@ID=$IDlist]"/>
> <xsl:for-each select="varList">
> 	...
> </xsl:for-each>
>
> But I want to get away from using extension methods.  It seems like
> something this common would be provided for in XSLT, maybe using xsl:key or
> something like that.  But I just don't know it. Can someone please advise?


More information about the DDI-users mailing list