Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old July 26th, 2006, 11:44 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Item Missing in Transformed Document

I am transforming an XML document to HTML. The XML document may or may not contain a certain element. If the element is present it will contain a numeric value within a range of 0 to 5.

In the HTML output I want to display a checkbox and have the checked attribute of the checkbox depend on the value contained in the XML element. Even if the element is not present in the XML document I want the checkbox to show in the HTML output. The code I wrote does not work - the checkbox does not display when the element is not present in the XML document. Below is a snippet of the code:

<td class="b33_row">NOB
      <xsl:if test="PROF=0"><input type="checkbox" id="b33_nob_cbx" checked="checked"/></xsl:if>
      <xsl:if test="PROF!=0"><input type="checkbox" id="b33_nob_cbx"/></xsl:if>
</td>

In this case PROF is the name of the XML element. Can anyone tell what I am doing wrong?

Regards,

Rich

  #2 (permalink)  
Old July 26th, 2006, 11:54 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

PROF=0 will be true if the element is present and equal to zero.

PROF!=0 will be true if the element is present and not equal to zero.

You probably want not(PROF=0) which is true if the element is not present or not equal to zero.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old July 27th, 2006, 12:09 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mr. Kay,

Your suggestion worked. Thanks for taking the time to respond.

Regards,

Rich



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding XSLT transformed XML content dynamically jacob ASP.NET 1.x and 2.0 Application Design 2 December 1st, 2005 04:40 PM
How do I remove xmlns from transformed document? Matt Ruby XSLT 2 October 27th, 2005 08:20 AM
Add XSLT transformed XML (html) on an aspx page humour XSLT 2 September 30th, 2004 05:13 AM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM
Find Out First Item of each item Group Jane SQL Language 1 November 22nd, 2003 12:42 PM





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