Subject: Re: [xsl] combining multiple documents From: Steven Ericsson-Zenith <steven@xxxxxxxxxxxxx> Date: Fri, 25 Jan 2008 08:23:45 -0800 |
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="test.xsl"?> <document file="include.xml"> <extra type="introduction"><p>barfoo</p></extra> </document>
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="test.xsl"?>
<document> <p> foobar </p> </document>
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:key match="extra" name="extra" use="@type"/>
<xsl:template match="extra"/> <xsl:template match="p"> <p> <xsl:apply-templates/> </p> </xsl:template>
Sincerely, Steven
On 24/01/2008, Steven Ericsson-Zenith <steven@xxxxxxxxxxxxx> wrote:The first call to the root node stores a value in a key and the second
call is meant to use the key value.
For the second call to use the key on the first document you need to do a bit of extra work in XSLT 1.0 eg
<xsl:variable name="val" select="val to use in key look up"/> <xsl:for-each select="$first-doc"> <xsl:apply-templates select="key('keyname', $val)"/> </
...because the key will only ever be applied to the current document, so you have to switch back to the first document before making the call.
XSLT 2.0 remedies this by providing a third argument to key to tell it which document should be used:
key('keyname', value, $first-doc)
If that's a bit hard to follow, produce the test case and it will be easier to show you with that.
cheers -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] matching complex attribut, Scott Trenda | Thread | Re: [xsl] combining multiple docume, David Carlisle |
Re: [xsl] manage errors and termina, Florent Georges | Date | Re: [xsl] combining multiple docume, David Carlisle |
Month |