Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 8th, 2014, 10:13 AM
Authorized User
 
Join Date: Jun 2012
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default using substring before instead of Tokeniser in xslt 1.0

I'm attempting to write an XSLT stylesheet that need to handle string separate with space and return into single element.

in xml code:
<node name="code" type="T">#JU#UAES# #JU#USAM# #JU#NEDS# #JU#NRT#</node>

need output as:

<element>#JU#UAES#</element>
<element>#JU#USAM#</element>
<element>#JU#NEDS#</element>
<element>#JU#NRT#</element>


<xsl:variable name="codeextract">
<xsl:value-of select="//node[@name='code']"/>
</xsl:variable>


<xsl:for-each select="//node[@name='code']">
<xsl:choose>
<xsl:when test="contains($codeextract,' ')">
<xsl:element name="element">
<xsl:value-of select="substring-before($codeextract,' ')"/>
</xsl:element>
<xsl:element name="element">
<xsl:value-of select="substring-after($codeextract,' ')"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="element">
<xsl:value-of select="$codeextract"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>

</xsl:for-each>


but i'm getting output as


<element>#JU#UAES#</element>
<element>#JU#USAM#</element>
 
Old July 15th, 2014, 10:01 AM
Authorized User
 
Join Date: Jun 2012
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

any help on this#??





Similar Threads
Thread Thread Starter Forum Replies Last Post
Retreiving substring using XSLT nelly78 XSLT 5 February 28th, 2013 07:29 AM
Convert substring to node set in XSLT 1.0 JessicaD XSLT 3 July 30th, 2009 02:51 PM
substring-before and substring-after 2BOrNot2B XSLT 1 January 21st, 2009 05:06 PM
substring in c# sudhirbharti C# 1 February 21st, 2008 01:29 PM
SubString prasanta2expert Access VBA 1 November 17th, 2006 10:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.