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

Re: Referencing unique values by their order number.

Subject: Re: Referencing unique values by their order number.
From: Andreas Kemkes <a5sk4s@xxxxxxxxx>
Date: Fri, 8 Dec 2006 17:05:46 -0800 (PST)
Re:  Referencing unique values by their order number.
David:

Thank you.  Works like a charm.

I was trying to solve the problem
without keys first and then see if I can apply keys in case I need to speed it
up.

Part of the reason was that I had not used keys before, but the other
issue was a concern that I could not use keys in my context, which might have
been lost in the simplification of the example.

The real input example has
various sections of the original example - aside from being also more
convoluted in other aspects. All sections need to use their own unique value
set and reference it appropriately.  My concern was that the top-level (i.e.,
somewhat global) key feature wouldn't be appropriate.

Is there a way to do
the same without keys?

I will also study keys and the example expression a
bit more to understand how to make it work.

Thanks again,

Andreas

-----
Original Message ----
From: David Carlisle <davidc@xxxxxxxxx>
To:
a5sk4s@xxxxxxxxx
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Friday, December 8,
2006 4:20:24 PM
Subject: Re:  Referencing unique values by their order
number.


> I do not have a separate file - and I'd rather avoid it.

ah ok,
time to bring out keys then (google for muenchian grouping)


<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output
indent="yes"/>
<xsl:key name="i" match="item" use="."/>

<xsl:template
match="x">
  <a>
    <items>
      <xsl:copy-of
select="item[generate-id()=generate-id(key('i',.))]"/>
    </items>
<elements>
      <xsl:for-each select="text">
      <element>
        <item>
<xsl:value-of
select="count(key('i',preceding-sibling::item[1])[1]/preceding-sibling::item[
generate-id()=generate-id(key('i',.))])"/>
    </item>
      <xsl:copy-of
select="."/>
      </element>
      </xsl:for-each>
    </elements>
  </a>
</xsl:template>

</xsl:stylesheet>


<a>
   <items>
      <item>V1</item>
<item>V2</item>
      <item>V3</item>
   </items>
   <elements>
<element>
         <item>0</item>
         <text>(content)</text>
</element>
      <element>
         <item>0</item>
<text>(content)</text>
      </element>
      <element>
<item>1</item>
         <text>(content)</text>
      </element>
<element>
         <item>0</item>
         <text>(content)</text>
</element>
      <element>
         <item>2</item>
<text>(content)</text>
      </element>
      <element>
<item>2</item>
         <text>(content)</text>
      </element>
   </elements>
</a>
_____________________________________________________________________________
_______
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

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.