This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: NMTOKENS enumeration?


Hi Martijn,

At 11:34 PM 1/18/02, you wrote:
>Is it possible to enumerate a tokenized string as an array as such:
>
><a value="a c b d" />
>
><xsl:for-each select="a">
>   <xsl:for-each select="@value">
>   </xsl:for-each>
></xsl:for-each>

Not like this, but it can be done. XSLT 1.0 sees the entire attribute value 
as a string, which (unlike a node set) you can't iterate over using for-each.

Use a named template which calls itself recursively, chopping up the string 
as it goes. You'll want to use the substring-before() function or its 
equivalent. Examples of this can be found in the FAQ or the list archives: 
search for "tokenizing a string" or such like. Or Mike K. gives you an 
extension function to tokenize in Saxon (saxon:tokenize(), I think), if 
you're using that.

XSLT 2 will be more powerful for such tasks as these.

Good luck (and let us know if you're stumped looking for that solution),
Wendell


======================================================================
Wendell Piez                            mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]