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

Re: processing multiple values in a single attribute

Subject: Re: processing multiple values in a single attribute
From: "vasu chakkera" <vasucv@xxxxxxxxx>
Date: Fri, 15 May 2009 23:34:47 +0100 (GMT Daylight Time)
Re:  processing multiple values in a single attribute
>>Of course, having a tokenize function would be loads easier if it's 
>>Available to you... 
Its important to first figure out if xslt 2 is available to him to start
with :) 
-------Original Message------- 
 
From: Matthew L. Avizinis 
Date: 15/05/2009 23:29:50 
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
Subject: Re:  processing multiple values in a single attribute 
 
I would add that you should use <xsl:choose> and have two <xsl:when> tests: 
<xsl:choose> 
<xsl:when test="not($string = '') and contains($string,' ')"> 
<statemanipulation> 
<variableref name="{substring-before($string,' ')}"/> 
<fault fault-code="{substring-before($string,' ')}" 
Fault-state="ok"/> 
</statemanipulation> 
<xsl:call-template name="do-tokens"> 
<xsl:with-param name="string" select="substring-after($string,' ')"/> 
</xsl:call-template> 
</xsl:when> 
<xsl:when test="not($string = '')"> 
<statemanipulation> 
<variableref name="{$string}"/> 
<fault fault-code="{$string}" fault-state="ok"/> 
</statemanipulation> 
</xsl:when> 
</xsl:choose> 
In order to ensure it grabs the last value of the string. 
Of course, having a tokenize function would be loads easier if it's 
Available to you... 
Peace, 
Matthew Avizinis 
Gleim Publications, Inc. (www.gleim.com) 
 
G. Ken Holman wrote: 
> 
> <xsl:template match="FAULT-REF"> 
> <xsl:call-template name="do-tokens"> 
> <xsl:with-param name="string" 
> select="concat(normalize-space(@FAULTS),' ')"/> 
> </xsl:call-template> 
> </xsl:template> 
> 
> <xsl:template name="do-tokens"> 
> <xsl:param name="string"/> 
> <xsl:if test="contains($string,' ')"> 
> <statemanipulation> 
> <variableref name="{substring-before($string,' ')}"/> 
> <fault fault-code="{substring-before($string,' ')}" 
> fault-state="ok"/> 
> </statemanipulation> 
> <xsl:call-template name="do-tokens"> 
> <xsl:with-param name="string" select="substring-after($string,' 
> ')"/> 
> </xsl:call-template> 
> </xsl:if> 
> </xsl:template> 
> 
> </xsl:stylesheet> 
> T:\ftemp>call xslt o.XML o.xsl 
> <?XML version="1.0" encoding="utf-8"?> 
> <statemanipulation> 
> <variableref name="PF01"/> 
> <fault fault-code="PF01" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF02"/> 
> <fault fault-code="PF02" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF03"/> 
> <fault fault-code="PF03" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF04"/> 
> <fault fault-code="PF04" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF05"/> 
> <fault fault-code="PF05" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF06"/> 
> <fault fault-code="PF06" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF07"/> 
> <fault fault-code="PF07" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF08"/> 
> <fault fault-code="PF08" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF09"/> 
> <fault fault-code="PF09" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF10"/> 
> <fault fault-code="PF10" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF11"/> 
> <fault fault-code="PF11" fault-state="ok"/> 
> </statemanipulation> 
> T:\ftemp>type o2.xsl 
> <?xml version="1.0" encoding="US-ASCII"?> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="2.0"> 
> 
> <xsl:output indent="yes"/> 
> 
> <xsl:template match="FAULT-REF"> 
> <xsl:for-each select="tokenize(normalize-space(@FAULTS),' ')"> 
> <statemanipulation> 
> <variableref name="{.}"/> 
> <fault fault-code="{.}" fault-state="ok"/> 
> </statemanipulation> 
> </xsl:for-each> 
> </xsl:template> 
> 
> </xsl:stylesheet> 
> T:\ftemp>call xslt2 o.xml o2.xsl 
> <?xml version="1.0" encoding="UTF-8"?> 
> <statemanipulation> 
> <variableref name="PF01"/> 
> <fault fault-code="PF01" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF02"/> 
> <fault fault-code="PF02" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF03"/> 
> <fault fault-code="PF03" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF04"/> 
> <fault fault-code="PF04" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF05"/> 
> <fault fault-code="PF05" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF06"/> 
> <fault fault-code="PF06" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF07"/> 
> <fault fault-code="PF07" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF08"/> 
> <fault fault-code="PF08" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF09"/> 
> <fault fault-code="PF09" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF10"/> 
> <fault fault-code="PF10" fault-state="ok"/> 
> </statemanipulation> 
> <statemanipulation> 
> <variableref name="PF11"/> 
> <fault fault-code="PF11" fault-state="ok"/> 
> </statemanipulation> 
> T:\ftemp>rem Done! 
> 
> 
> 
> -- 
> XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08 
> 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-2013 All Rights Reserved.