[xsl] for-each with included variable

Subject: [xsl] for-each with included variable
From: "Machelett, Renato (FA.G+M-EP/ETK)" <fa-gm-renato.machelett@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Apr 2001 19:12:09 +0200
Hi Everybody,

I'm not including any XML here, because it would take me a while to locate
and isolate the right part in a few MB of XML and it might still be too
large to post it. If required though, I'll provide it.
I'm dealing with a working piece of legacy XSL that is used for code
generation and looks like this in one part:

<xsl:for-each select="(.//*[@OPTypeRef='Type1'])[1] |
(.//*[@OPTypeRef='Type2'])[1] | (.//*[@OPTypeRef='Type3'])[1]">
  <!-- do some stuff -->

That is contained in a number of XSL-Files, and of course the number of
comparisons is much larger.
The DTD has changed and so e.g. 'Type1' has now become 'XType1".
Instead of just substituting the occurences everywhere in that stylesheet
I'd rather generalize it, preventing typos and making future changes easier,
by including an XSL-File with the different Types in one variable.

<xsl:variable name="myOPTypeList">XType1,XType2,XType3</xsl:variable>

and applying it like this

<xsl:for-each select="(.//*[@OPTypeRef[contains($myOPTypeList,
  <!-- do some stuff -->

Now after the first match no other nodes on the same level are selected -
instead of selecting the first occurence of every type that is present in
that substructure. I'm not familiar enough with XPath to see the solution
myself, and my approach might be wrong in general or not efficient at all.
So any kind of help would be appreciated. My apologies if this should be a


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread