[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hello Guy,
I can't see an error in your code, maybe somebody else? Did you exactly use the code below? Line 12 is the key() - no error with parantheses, commas or apostrophes?
What it does:
<xsl:key/> creates one index for each input XML. With key() you can easily access these indexed elements, here your <a/>s.
With <xsl:for-each select="document($previous)"> you do not work through the whole tree, you only switch the context to the other file, because you want to have the indexed <a/>s from there and not from your current file. With "document($previous)" you only access the root node '/', so there is only one iteration. For multiple iterations you can write "document($previous)//a", but as you said it, it's completely useless when using keys.
Regards,
Joerg
Guy McArthur wrote:
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] linkdiff template
Subject: Re: [xsl] linkdiff template From: Joerg Heinicke <joerg.heinicke@xxxxxx> Date: Tue, 18 Jun 2002 10:19:45 +0200 |
Hello Guy,
I can't see an error in your code, maybe somebody else? Did you exactly use the code below? Line 12 is the key() - no error with parantheses, commas or apostrophes?
What it does:
<xsl:key/> creates one index for each input XML. With key() you can easily access these indexed elements, here your <a/>s.
With <xsl:for-each select="document($previous)"> you do not work through the whole tree, you only switch the context to the other file, because you want to have the indexed <a/>s from there and not from your current file. With "document($previous)" you only access the root node '/', so there is only one iteration. For multiple iterations you can write "document($previous)//a", but as you said it, it's completely useless when using keys.
Regards,
Joerg
Guy McArthur wrote:
I thought I understood, but I get an "unknown error in XPath" on line 12.
Here is the xsl I'm using: (also tried putting wrapping the key() method with a boolean() method.
--
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="previous"/>
<xsl:key name="links" match="a" use="@href"/>
<xsl:output method="text"/>
<xsl:template match="a"> <xsl:variable name="href" select="@href"/> <xsl:for-each select="document($previous)"> <xsl:if test="not(key('links', $href))"> <xsl:value-of select="$href"/> </xsl:if> </xsl:for-each> </xsl:template>
</xsl:stylesheet> --
Also, it would seem by looking at it, that it would walk through all the elements of document($previous) for every matching "a" element. Shouldn't building a key eleminate the need to walk through the tree each time?
Guy
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] linkdiff template, Guy McArthur | Thread | [xsl] SSI in XML, Joel Konkle-Parker |
RE: [xsl] Formatting body, Michael Kay | Date | [xsl] Best way to create a "diction, Antonio Fiol |
Month |
Keywords