[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Why does my XSLT produce a Warning message with n

Subject: Re: Why does my XSLT produce a Warning message with never-executed code that divides a blank by 10?
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 31 Mar 2024 08:43:13 -0000
Re:  Why does my XSLT produce a Warning message with  n
On Sun, 2024-03-31 at 07:57 +0000, Roger L Costello costello@xxxxxxxxx
wrote:
>
> How can the XSLT code be written so that, when executed, it doesn't
> produce a Warning message?B 

You may find that reversing the sense of the test gts rid of the
warning -

if (normalize-space($test) ne '')
then xs:integer($test) div 10
else ()

The XPath spec says that dynamic errors must not be raised from the
if/else branch not taken. This is a warning, not an error, but since
the spec explicitly allows this use of if/else, it seems like an
inappropriate warning to me. But it's a judgement call.

A better way to write this, though, might be

if (normalize-space($text) castable as xs:integer)
then xs:intefer(normalize-space($test)) div 10
else ()

liam


--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.