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

Re: Using XSLT to build an index

Subject: Re: Using XSLT to build an index
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Mon, 31 Oct 2011 05:10:49 -0700
Re:  Using XSLT to build an index
Ken,
I just ran your code and it produced the expected results.
Thanks,
Mark

-----Original Message----- From: G. Ken Holman
Sent: Monday, October 31, 2011 4:17 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Using XSLT to build an index


Michael's answer gives you source document context of each item,
which can be very useful.

But to answer your specific question in the event that context is not needed:

At 2011-10-30 22:29 -0700, Mark wrote:
I have now normalized and isolated every phrase I wish to index into a few thousand structures similar to:

<Text lang="en" data="Zlutice Hymnal 1558" title="Czech Republic Stamp 664" ref="2010-664.htm"/>

and want to break the @data attribute string into into individual words associated with its title and ref attributes. How do I use "distinct-values(tokenize(@data))" to construct a sequence of <Word> elements from the <Text> element similar to the following? That is, I don't see how to get at the words returned from distinct-values(tokenize(@data)) one at a time to do this.

<Word title="Czech Republic Stamp 664" ref="2010-664.htm">Zlutice</Word>
<Word title="Czech Republic Stamp 664" ref="2010-664.htm">Hymnal</Word>
<Word title="Czech Republic Stamp 664" ref="2010-664.htm">1558</Word>

Thankfully, it is straightforward to do something "for each" value in a sequence:

<xsl:variable name="title" select="@title"/>
<xsl:variable name="ref" select="@ref"/>
<!--walk over each distinct value setting that value as the current node-->
<xsl:for-each select="distinct-values(........)">
  <Word title="{$title}" ref="{$ref}"><xsl:value-of select="."/></Word>
</xsl:for-each>

I hope this helps.

. . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

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.