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

Re: Style questions (2 questions)

Subject: Re: Style questions (2 questions)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 25 Aug 2005 15:08:37 +0100
href post
> 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()&lt;=$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
________________________________________________________________________

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