Subject: Re: [xsl] Using XSLT to build an index From: "Mark" <mark@xxxxxxxxxxxx> Date: Mon, 31 Oct 2011 05:10:49 -0700 |
Ken, I just ran your code and it produced the expected results. Thanks, Mark
Michael's answer gives you source document context of each item, which can be very useful.
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>
-- 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using XSLT to build an in, Mark | Thread | Re: [xsl] Using XSLT to build an in, Dimitre Novatchev |
Re: [xsl] Using XSLT to build an in, Mark | Date | Re: [xsl] Using XSLT to build an in, Michael Kay |
Month |