This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

linkdiff template


Hi, I'm looking to write a template to output the a/@href's from one 
(newer) file that are *not* present in another (older) file.

I.e. given the following two files
-old.xml-
<html>
 <a href="http://www.google.com/>Google!</a>
 <a href="http://w3.org/";>W3C</a>
</html>
-new.xml-
<html>
 <a href="http://w3.org/";>W3C</a>
 <a href="http://guymcarthur.com";>My HomePage</a>
 <a href="http://xml.apache.org/xalan/";>Xalan</a>
</html>
--
The output would be:
http://guymcarthur.com
http://xml.apache.org/xalan/

Here's my first stab at the stylesheet:
-linkdiff.xsl-
<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="document($previous)///a/@href"/>
 
 <xsl:output method="text"/>

 <xsl:template match="a">
   <xsl:if test="not(boolean(key('links', @href)))">
     <xsl:value-of select="@href"/>
   </xsl:if>
 </xsl:template>

</xsl:stylesheet> 
--

However, it is just outputting all the href's (test is always true).
Please enlighten me!

I'm using 'java org.apache.xalan.xslt.Process -IN new.xml -XSL \
linkdiff.xsl -PARAM previous old.xml'.

GKM


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]