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

Re: linkdiff template

Subject: Re: linkdiff template
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Tue, 18 Jun 2002 10:19:45 +0200
Re:  linkdiff template
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

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-2007 All Rights Reserved.