Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help: How to make XSL think non-existing elem is '' in test

Status
Not open for further replies.

hepic

Programmer
Nov 19, 2002
1
US
Hi,

In the following xsl,

<xsl:choose>
<xsl:when test=&quot;page[readOnly='']&quot;>
<!-- turn the page to edit mode -->
</xsl:when>

<xsl:eek:therwise>
<!-- turn the page to read only -->
</xsl:eek:therwise>
</xsl:choose>

The problem is that sometimes element readOnly doesn't exist. In that case, I would like the page to be in edit mode, but it actually turns into read-only. It looks like the the test condition fails if element readOnly doesn't exist. Is there a way we can make XSL evaluate non-existing element to an empty string?

I know I can re-write the condition; however, we have many XSL conditions written in this way, and I wouldn't like to mannually change every one of them if possible.

Thanks a lot for your help!
 
This should work

<xsl:choose>
<xsl:when test=&quot;page[readOnly='']&quot;>
<!-- turn the page to edit mode -->
</xsl:when>
<xsl:eek:therwise>
<xsl:choose>
<xsl:when test=&quot;page[readOnly]&quot;>
<!-- turn the page to read only -->
</xsl:when>
<xsl:eek:therwise>
<!-- turn the page to edit mode -->
</xsl:eek:therwise>
</xsl:choose>
</xsl:eek:therwise>
</xsl:choose>
Build web applications faster with a few lines of XML Code using DataML[tm]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top