RE: How to manipulate XML based on attribute?

Subject: RE: How to manipulate XML based on attribute?
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 20 Jul 2000 09:36:13 +0100
> The vip attribute could occur on any element ...
> Wherever the vip attribute appears, I want to embed the 
> result of whatever I
> do with that element in <em></em> tags in the resultant HTML. 

An interesting little challenge to do this elegantly. The problem is that
there's no direct way of applying more than one template rule to an element.
But I think you can do something along the following lines:

a.xsl
<xsl:import href="b.xsl"/>
<xsl:template match="*[@vip]" priority="2">
  <em><xsl:apply-imports/></em>
</xsl:template>
<xsl:template match="*" priority="1">
  <xsl:apply-imports/>
</xsl:template>

b.xsl:
All the other template rules for your elements.

It's a little odd that you need two stylesheet modules: this is because
xsl:apply-imports will only look for rules with lower import precedence, not
for rules with lower priority.

I think this is the first problem I have ever seen on this list to which
xsl:apply-imports is the answer.

Mike Kay


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


Current Thread