Subject: RE: [xsl] match nodes based on given path From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Fri, 11 Apr 2003 11:06:24 +0100 |
(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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] match nodes based on give, Andrew Welch | Thread | Re: [xsl] match nodes based on give, David Carlisle |
RE: [xsl] Self index?, David . Pawson | Date | RE: [xsl] Re: parsing a long string, Tim Wilkins |
Month |