Subject: RE: XSLT 2.0 and external parameters: a string -> xsd:integer. How?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 20 May 2003 20:53:34 +0100
|
>
> I guess this is another angle on the typing questions that have been
> floating around the list recently.
>
> Code that worked with Saxon 7.4 (and that I think would work
> in XSLT 1.0)
> is now broken with Saxon 7.5.
>
> How can I supply an external parameter to a Saxon 7.5
> stylesheet which is
> $number and has an integer value and get the XSLT processor
> to treat it as
> an xsd:integer. Well, I don't particularly want the parameter to be
> xsd:integer but I assume I won't be able to do anything
> numeric with it,
> unless I make it explicitly numeric.
If you are passing parameters from a JAXP application, you can pass a
Java Integer.
If you want to do it from the command line, you can only pass strings;
you will have to convert the string to an integer within your own code
(this is exactly the same as writing a Java application that reads
arguments from the command line - they arrive as strings).
>
> If I try to ignore types altogether Saxon 7.5 complains, not
> surprisingly,
> that it cannot compare xsd:string to xsd:integer. If there is
> a way to
> write a type-agnostic stylesheet to accept a parameter that
> is intended to
> be numeric it isn't obvious to me at the moment.
Write:
<xsl:param name="p" as="xs:string"/>
<xsl:variable name="p-as-int" as="xs:integer" select="xs:integer($p)"/>
>
> So I made the input parameter xsd:string and created a new numeric
> parameter using the xsd:integer() constructor function. Same
> error message.
>
> Then I tried making the input parameter xdt:untypedAtomic with the
> xsd:integer() constructor function to create the second
> parameter. Same
> error message.
>
> Then I tried adding an as="xsd:integer". Same error message.
I'm afraid it's difficult to tell from this description exactly what you
did, and exactly what messages you got.
>
> The Saxon 7.5 documentation indicates that "most" such functions are
> supported. Is this one unsupported or am I missing a basic
> trick somewhere?
I think you missed a trick somewhere, but from the description I can't
tell where.
Michael Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|