[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: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 May 2009 20:32:00 -0400
Re:  processing multiple values in a single attribute
At 2009-05-15 19:36 -0400, Matthew L. Avizinis wrote:
Despite my slight embarrassment earlier, dare I ask a further question
for my own curiosity please?
Suppose (I'm not saying OPs data could ever fit this condition) instead of
<FAULT-REF FAULTS="PF01 PF02 PF03 PF04 PF05 PF06 PF07 PF08 PF09 PF10
you had

Very valid point, Matthew ... my solution falls apart. Well spotted.

Would you change the templates at all? If so, how?

I would wrap the initial call with a single <xsl:if> so as to introduce a single test regardless of the number of tokens rather than introduce any test in the template that would be repeated when not necessary:

<xsl:template match="FAULT-REF">
  <xsl:if test="normalize-space(@FAULTS)">
    <xsl:call-template name="do-tokens">
      <xsl:with-param name="string"
                      select="concat(normalize-space(@FAULTS),' ')"/>

<xsl:template name="do-tokens">
  <xsl:param name="string"/>
  <xsl:if test="contains($string,' ')">
      <variableref name="{substring-before($string,' ')}"/>
       <fault fault-code="{substring-before($string,' ')}" fault-state="ok"/>
    <xsl:call-template name="do-tokens">
      <xsl:with-param name="string" select="substring-after($string,' ')"/>

In this way I still have only a single test= in the loop, and I only call the loop if I know I have some tokens.

Thank you for bringing light to this.

. . . . . . . . . . . Ken

-- 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


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.
First Name
Last Name
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.