|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Style questions (2 questions)
> But you cant do that with keys ... can you?
related to the parallel thread re xslt1/xslt2, just a note that you can
do this fairly easily with keys in xslt2 as you can get more
expressivity into the use attribute of xsl:key.
<x>
<post tag="reference xml" href="..." />
<post tag="reference xml xslt" href="..." />
<post tag="reference xml css" href="..." />
<post tag="reference html" href="..." />
<post tag="reference html 1" href="..." />
<post tag="reference html 2" href="..." />
<post tag="reference html 3rip" href="..." />
<post tag="reference html 3.2" href="..." />
<post tag="reference html 4" href="..." />
<post tag="linux" href="..." />
</x>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:key name="t" match="post" use="for $i in (1 to count(tokenize(@tag,' +'))) return
string-join(tokenize(@tag,' +')[position()<=$i],' ')"/>
<xsl:template match="/">
1 reference xml
<xsl:copy-of select="key('t','reference xml')"/>
2: linux
<xsl:copy-of select="key('t','linux')"/>
3: reference
<xsl:copy-of select="key('t','reference')"/>
4: reference html
<xsl:copy-of select="key('t','reference html')"/>
4: reference html 4
<xsl:copy-of select="key('t','reference html 4')"/>
</xsl:template>
</xsl:stylesheet>
$ saxon8 keys.xml keys.xsl
<?xml version="1.0" encoding="UTF-8"?>
1 reference xml
<post tag="reference xml" href="..."/>
<post tag="reference xml xslt" href="..."/>
<post tag="reference xml css" href="..."/>
2: linux
<post tag="linux" href="..."/>
3: reference
<post tag="reference xml" href="..."/>
<post tag="reference xml xslt" href="..."/>
<post tag="reference xml css" href="..."/>
<post tag="reference html" href="..."/>
<post tag="reference html 1" href="..."/>
<post tag="reference html 2" href="..."/>
<post tag="reference html 3rip" href="..."/>
<post tag="reference html 3.2" href="..."/>
<post tag="reference html 4" href="..."/>
4: reference html
<post tag="reference html" href="..."/>
<post tag="reference html 1" href="..."/>
<post tag="reference html 2" href="..."/>
<post tag="reference html 3rip" href="..."/>
<post tag="reference html 3.2" href="..."/>
<post tag="reference html 4" href="..."/>
4: reference html 4
<post tag="reference html 4" href="..."/>
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








