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

Re: multiple range expansion

Subject: Re: multiple range expansion
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 Jun 2009 08:05:05 -0400
Re:  multiple range expansion
At 2009-06-23 11:22 +0530, Ganesh Babu N wrote:
I got the concept and converted successfully. Instead of for-each i
have used for to get spaces between ids.

But that didn't work for you ... what is wrong with <xsl:for-each>?


But one place i am unable to
remove. Please help to achieve this.

Input:

<cross-ref>[<cr refid="MEP_L_bib5">5</cr>-<cr
refid="MEP_L_bib7">7</cr>, <cr refid="MEP_L_bib21">21</cr>-<cr
refid="MEP_L_bib24">24</cr>]</cross-ref>

correct output:
<cross-refs refid="bib5 bib6 bib7 bib21 bib22 bib23 bib24">[5-7,
21-24]</cross-refs>

Output from modified XSL:
<cross-refs refid="bib5 bib6 bib7bib21 bib22 bib23 bib24">[5-7,
21-24]</cross-refs>

Modified XSL code:
<xsl:analyze-string select="." regex="(\d+)(\s*-\s*(\d+))?">
  <xsl:matching-substring>
     <xsl:value-of select="for $i in xs:integer(regex-group(1)) to
(if(regex-group(3)) then xs:integer(regex-group(3)) else
xs:integer(regex-group(1))) return concat('bib', $i)"/>

You didn't copy my concat() as I wrote it, which had the space added.


Just add <xsl:text> </xsl:text> after the <xsl:value-of> and then you are guaranteed to have a space after every token. The last is also included, but that should be irrelevant to the semantics of your attribute value.

For example, in XML and IDREFS attribute can have an arbitrary number of spaces before or after any of the contained IDREF values.

Please suggest. bib7 and bib21 has to be separated.

And they would be if you added a space after every token using <xsl:for-each> or add a space after every use of <xsl:value-of>.


As I evidenced above, a token list is typically allowed to have extra spaces in it. You might be worried about aesthetics, but is that a human looking at it or is it a syntactic constraint you've imposed on the input? Writing a stylesheet for this data I would still probably run normalize-space() on the value before tokenizing to ensure there were no extra spaces.

I hope this helps.

. . . . . . . . . . Ken

--
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
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-2007 All Rights Reserved.