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 December 2nd, 2008, 05:12 PM
Friend of Wrox
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default xsl:test, but ignoring whitespace

I am using Saxon9 B

I have need to compare an element value in one file against an element value in another file.

It was easy..

   <xsl:if test="not(. = $piuSubTree//entry[@colname='1'])">
      <xsl:text>Invalid PIU Naming: "</xsl:text>
Problem is, now the users want to ignore leading or trailing whitespace. So I tried this:

   <xsl:analyze-string select="." regex="^\s*({$piuSubTree//entry[@colname='1']})\s*$">
         <xsl:text>Invalid PIU Naming: "</xsl:text>
Probably not surprising to you, but it was to me.. this doesn't work.
My guess is I've munged the regex in one way or another.

Can anyone detect what I've missed?

Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare
Old December 5th, 2008, 05:23 AM
Friend of Wrox
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts

  From the script you have mentioned it seems that there are leading and traiing spaces in the current node which you are matching with "." character. And it specifies that there won't be spaces in the $piuSubTree//entry[@colname='1' element you have specified.
  If you are approaching your target with the above understanding then I'm not sure where the mistake is.


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL Params inside When Test shasto100 XSLT 3 April 21st, 2006 05:45 AM
Sorting a xsl:if test="position()" charmaigne XSLT 2 April 12th, 2006 04:42 AM
XSL Test tclancy XSLT 2 February 3rd, 2006 02:49 PM
<xsl:if test="" Question kwilliams XSLT 2 August 9th, 2005 08:30 AM
Using xsl:if test attributes rdavisiii XSLT 4 November 9th, 2004 12:24 AM

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