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 August 14th, 2006, 08:40 AM
Authorized User
 
Join Date: Aug 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT - Function to test value


Hello,

Does anyone know what function should I use to test if the value inside the number1 is populated or not? I am using this value to do a condition check. if the value is populated, do one thing, otherwise, do other thing.

<Field>
  <Number1>123456<Number1>
</Field>

Thank you very much in advance!
Haixia

 
Old August 14th, 2006, 08:44 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The most obvious is

<xsl:if test="Number1 = ''">



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 14th, 2006, 08:52 AM
Authorized User
 
Join Date: Aug 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Michael,

I made a mistake, the element looks like this and I would like to test if there is any value inside Number1

<Field>
  <Field id ="Number1"></Number1>
</Field>

Thanks,
Haixia

 
Old August 14th, 2006, 08:59 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your previous example was well-formed XML, this one isn't, so you're heading rapidly downhill.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 14th, 2006, 09:07 AM
Authorized User
 
Join Date: Aug 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I know. But we have no control of changing it as it's sent by our client. Is there any ways to test if there is any value inside of the number1?

Thanks,
Haixia

 
Old August 14th, 2006, 09:31 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If your client is really sending you

<Field id ="Number1"></Number1>

then I suggest you talk to him about the benefits that would be gained by using XML instead.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt replace function rajesh_css XSLT 7 October 30th, 2008 08:39 PM
XSLT TRIM Function sagrock XSLT 1 November 23rd, 2007 08:39 AM
XSLT Function very urgent alapati.sasi XSLT 3 May 23rd, 2007 03:45 AM
contains function in XSLT 1.0 NEO1976 XSLT 4 February 7th, 2007 06:01 AM
XSLT - test the value is true or false haixia XSLT 1 August 21st, 2006 01:38 PM





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