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

RE: match nodes based on given path

Subject: RE: match nodes based on given path
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Fri, 11 Apr 2003 11:06:24 +0100
elementpath
(hmmmm stuck again very quickly :) 

Now I am generating a stylesheet which looks like:

<xsl:key name="indyLink" match="/root/node/foo" use="generate-id()"/>

<xsl:template match="*[generate-id() = generate-id(key('indyLink',generate-id()))]">
  <xsl:call-template name="IndyLink"/>
  <xsl:apply-imports/>
</xsl:template>

Which will call the named template when /root/node/foo is matched.  The key match is generated from the link file, which takes the form:

    <extended>
      <locator href="test1.xml" elementPath="/root/node/foo"/>
      <locator href="test2.xml" elementPath="/root/node/bar"/>
      <locator href="test3.xml" elementPath="/root/node/baz"/>
    </extended>

Now, in order to generate the link, I need to pass the siblings of the node matched by the key (/root/node/foo) to the named template.

How can I get to the correct <locator> from the matching template?  As Im generating the stylesheet I can do pretty much anything, but I cant see how to do it using the key approach.

I initially thought to generate-id() on an eval()'d @elementPath, but that sounds silly... 

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

<xsl:import href="file:///C:/main.xsl"/>

<xsl:param name="thisXmlFileName" select="'test1.xml'"/>
<xsl:param name="indyLinksRTF">
    <extended>
      <locator href="test1.xml" elementPath="/root/node/foo"/>
      <locator href="test2.xml" elementPath="/root/node/bar"/>
      <locator href="test3.xml" elementPath="/root/node/baz"/>
    </extended>
</xsl:param>
<xsl:variable name="indyLinks" select="saxon:node-set($indyLinksRTF)"/>

<xsl:key name="indyLink" match="/root/node/foo" use="generate-id()"/>

<xsl:template match="*[generate-id() = generate-id(key('indyLink',generate-id()))]">
  <xsl:call-template name="IndyLink">
  //***need to pass extended nodeset here where @elementPath
  //***points to current node
  </xsl:call-template/>
  <xsl:apply-imports/>
</xsl:template>

<xsl:template name="IndyLink">
  <xsl:param name="extendedNodeSet"/>  
  ....
</xsl:template>

</xsl:stylesheet>

thanks for any help

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.