xsl-list
[Top] [All Lists]

RE: [xsl] Converting individual words in a string to nodes

2007-04-26 05:26:38
In 2.0 it's simply

<NodeSet>
  <xsl:for-each select="tokenize(., '/')"/>
    <PlaceNode>
      <xsl:value-of select="."/>
    </PlaceNode>
  </xsl:for-each>
</NodeSet>

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Andy Carr1 [mailto:CARRA(_at_)uk(_dot_)ibm(_dot_)com] 
Sent: 26 April 2007 13:16
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Converting individual words in a string to nodes

I am using XSLT 2.0 to transform a WordML document and have 
run into a spot of trouble.

I have a / delimited string and need to create a node for 
each word in the string.



WordML snippet:
<w:p>
   <w:r>
      <w:t>UK/England/Yorkshire/Hull</w:t>
   </w:r>
</w:p>

needs to be output as:

<NodeSet>
   <PlaceNode>UK</PlaceNode>
   <PlaceNode>England</PlaceNode>
   <PlaceNode>Yorkshire</PlaceNode>
   <PlaceNode>Hull</PlaceNode>
</NodeSet>

The number of words in the string is unlimited.

I can tokenize the string and count the number of words in 
the string, but 
I can't create a node for each word and it is really frustrating. 

Can anyone help?

Regards
Andy

Andy Carr
Senior IT Specialist
Tel: Internal - 298037 External - 01252 558037
Mail Point  M1C IBM Application Services
Meudon House, Meudon Avenue, Farnborough, GU14 7NB
(Notes) Andy Carr1/UK/IBM(_at_)IBMGB 
(Internet)CARRA(_at_)uk(_dot_)ibm(_dot_)com






Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales 
with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, 
Hampshire PO6 3AU







--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>