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

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

August 14th, 2006, 08:44 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

August 14th, 2006, 08:52 AM
|
|
Authorized User
|
|
Join Date: Aug 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 14th, 2006, 08:59 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

August 14th, 2006, 09:07 AM
|
|
Authorized User
|
|
Join Date: Aug 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 14th, 2006, 09:31 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|
 |