I'm using Saxon 8.7.1J.
I have output from a database in the form of an XML document that I transform
using XSLT. As an expediant, the persons in responsible positions decided to
encode data in a text field in order to accomplish a goal rather than wait
until the application and database are upgraded.
Some records will contain this "packed" information and others will not. I need
to determine if an element in the output XML document contains the packed
information or does not, and process each type differently.
One of the data items packed into this text field is a date. I have substringed
the text so as to construct a date (YYYY-MM-DD) if there is indeed a date
encoded in the field.
I thought to use "castable as" in order to distinguish between those fields
containing the packed information and those that do not. Here the relevant
section of my stylesheet:
<xsl:variable name="is-date" select="if(DATE_PACKED_XSD castable as xs:date)
then '1' else('0')" />
<xsl:choose>
<xsl:when test="$is-date = '1'">
... some processing here
</xsl:when>
<xsl:otherwise>
... some different processing here
</xsl:otherwise>
</xsl:choose>
What I expected to happen was that when the stylesheet processed a
DATE_PACKED_XSD element that could not be cast as a date ($is-date = 0),
processing would pass to the <xsl:otherwise> branch.
What did happen was this:
stylesheet.xslt:423: Fatal Error! Invalid date "208 2-01-1 2". Non-numeric
component
What am I misapprehending about "castable as"?
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--