[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

match nodes based on given path

Subject: match nodes based on given path
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Thu, 10 Apr 2003 12:20:54 +0100
xml element path
(tricky)

Hi,

Given an element path of the form:

/root/node/value

How can I override the usual <value> matching template with a special template, only when <value>'s path matches the given path?

To expand it a little, take the xml snippet:

<root>
  <node>
    <value>foo</value>
  </node>
</root>

And the stylesheet:

<xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="externalLinks">
  <link path="/root/node/value"/>
  <link path="/root/value"/>
</xsl:param>

<xsl:template match="value">
  <xsl:value-of select="'usual'"/>
</xsl:template>

<xsl:template name="special">
  do something extra
</xsl:template>

</xsl:stylesheet>

Here, as the <value> elements path matches that given in the parameter I would like to apply the special template, and then the usual one.  The paths could point to any element, so I need to somehow apply templates based on the paths, generating the output in the result tree in the position that it would appear normally (I can't just bolt it onto the end with an 'eval').

This is more tricky than it initally looks.  I'm currently using an importing stylesheet that tests every element's path against those in the parameter, which is far from efficient and requires the paths to be in some kind of normal form.

Has anyone got any ideas to improve this?  Im thinking about creating a stylesheet that generates templates with match attributes based on the paths, and then including them at the foot of the original stylesheet... however I may be missing something more obvious.

cheers
andrew



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.470 / Virus Database: 268 - Release Date: 08/04/2003
 

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.