Re: Saxon implementation of result interface

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Saxon implementation of result interface

Julia.Nissen

Hello,

 

using the s9api another question came up:

 

In the xsl script to be executed we have parameters like this:

      <xsl:param name="minCount"     as="xs:integer" select="1"/>
     
<xsl:param name="sectionTitle" as="xs:string?"/>

 

Using the JAXP API we’ve set these parameters from java with this code:

transformer.setParameter(paramName, paramValue);

where paramName and paramValue are both of type String. And it was working fine.

 

Now using s9api we changed this to:

xsltTransformer.setParameter(new QName(paramName), new XdmAtomicValue(paramValue))

 

Now when the script is executed we get an error:

„Required item type of value of variable $minCount is xs:integer; supplied value has item type xs:string“

 

Is there any class we can use as parameter value that can be casted dynamically to xs:string as well as xs:integer (and float, boolean, …)?

 

Thanks and Regards,

 

Julia

 


Systemarchitektur & IT-Projekte

Fon:

Fax:

Mail:

[hidden email]

GDV-DL-Logo GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
20095 Hamburg
Web:
gdv-dl.de


Sitz & Registergericht:
Hamburg
HRA 93 894
USt.-IdNr: DE 205183123

Geschäftsführer: Dr. Jens Bartenwerfer
Michael Bathke

Volker Sonnenburg






Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon implementation of result interface

Martin Honnen-2
Julia Nissen wrote:

> using the s9api another question came up:
>
> In the xsl script to be executed we have parameters like this:
>
> <xsl:paramname="minCount"    as="xs:integer"select="1"/>
> <xsl:paramname="sectionTitle"as="xs:string?"/>
>
> Using the JAXP API we’ve set these parameters from java with this code:
>
> transformer.setParameter(paramName, paramValue);
>
> where paramName and paramValue are both of type String. And it was
> working fine.
>
> Now using s9api we changed this to:
>
> xsltTransformer.setParameter(new QName(paramName), new
> XdmAtomicValue(paramValue))
>
> Now when the script is executed we get an error:
>
> „Required item type of value of variable $minCount is xs:integer;
> supplied value has item type xs:string“

You need to construct an XdmAtomicValue, it has some direct constructors
for some Java types, for others there is
http://saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/XdmAtomicValue.html#XdmAtomicValue%28java.lang.String,%20net.sf.saxon.s9api.ItemType%29 
so doing

   new XdmAtomicValue(paramValue, ItemType.INTEGER)




------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon implementation of result interface

Michael Kay
In reply to this post by Julia.Nissen
s9api adopts the same rules for type-checking of stylesheet parameters as for XPath function calls: the supplied value will be cast to the required type if it is untypedAtomic, otherwise it must match the required type (subject to atomization, etc).

You can create an untyped atomic value using

new XdmAtomicValue("142", ItemType.UNTYPED_ATOMIC)

If you prefer you can also determine the required type of the parameter using

ItemType type = xsltExecutable.getParameterDetails().get(new QName("minCount")).getDeclaredItemType();
XdmValue value = new XdmAtomicValue("142", type);

Michael Kay
Saxonica




On 18 Nov 2015, at 12:32, Julia Nissen <[hidden email]> wrote:

Hello,

 

using the s9api another question came up:

 

In the xsl script to be executed we have parameters like this:

      <xsl:param name="minCount"     as="xs:integer" select="1"/>
     
<xsl:param name="sectionTitle" as="xs:string?"/>

 

Using the JAXP API we’ve set these parameters from java with this code:

transformer.setParameter(paramName, paramValue);

where paramName and paramValue are both of type String. And it was working fine.

 

Now using s9api we changed this to:

xsltTransformer.setParameter(new QName(paramName), new XdmAtomicValue(paramValue))

 

Now when the script is executed we get an error:

„Required item type of value of variable $minCount is xs:integer; supplied value has item type xs:string“

 

Is there any class we can use as parameter value that can be casted dynamically to xs:string as well as xs:integer (and float, boolean, …)?

 

Thanks and Regards,

 

Julia

 


Systemarchitektur & IT-Projekte

Fon:

Fax:

Mail:

[hidden email]

GDV-DL-Logo GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
20095 Hamburg
Web:
gdv-dl.de


Sitz & Registergericht:
Hamburg
HRA 93 894
USt.-IdNr: DE 205183123

Geschäftsführer: Dr. Jens Bartenwerfer
Michael Bathke

Volker Sonnenburg






Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon implementation of result interface

Julia.Nissen

Hello,

 

Thanks. We created an untyped atomic value like you suggested and that works fine.

Additionally, we use XsltExecutable.*getGlobalParameters*() to check if the parameter actually exists in the script. I assume that’s the method you were referring to.

 

Thanks and regards,

Julia

 

 



------------------------------------------------------------------
Systemarchitektur & IT-Projekte
Tel:
Fax:
E-Mail:
[hidden email]


Von: Michael Kay [mailto:[hidden email]]
Gesendet: Freitag, 20. November 2015 01:21
An: Mailing list for the SAXON XSLT and XQuery processor
Betreff: Re: [saxon] Saxon implementation of result interface

 

s9api adopts the same rules for type-checking of stylesheet parameters as for XPath function calls: the supplied value will be cast to the required type if it is untypedAtomic, otherwise it must match the required type (subject to atomization, etc).

 

You can create an untyped atomic value using

 

new XdmAtomicValue("142", ItemType.UNTYPED_ATOMIC)

 

If you prefer you can also determine the required type of the parameter using

 

ItemType type = xsltExecutable.getParameterDetails().get(new QName("minCount")).getDeclaredItemType();

XdmValue value = new XdmAtomicValue("142", type);

 

Michael Kay

Saxonica

 

 

 

 

On 18 Nov 2015, at 12:32, Julia Nissen <[hidden email]> wrote:

 

Hello,

 

using the s9api another question came up:

 

In the xsl script to be executed we have parameters like this:

      <xsl:param name="minCount"     as="xs:integer" select="1"/>
      <xsl:param name="sectionTitle" as="xs:string?"/>

 

Using the JAXP API we’ve set these parameters from java with this code:

transformer.setParameter(paramName, paramValue);

where paramName and paramValue are both of type String. And it was working fine.

 

Now using s9api we changed this to:

xsltTransformer.setParameter(new QName(paramName), new XdmAtomicValue(paramValue))

 

Now when the script is executed we get an error:

„Required item type of value of variable $minCount is xs:integer; supplied value has item type xs:string“

 

Is there any class we can use as parameter value that can be casted dynamically to xs:string as well as xs:integer (and float, boolean, …)?

 

Thanks and Regards,

 

Julia
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help

 

GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123

Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153

Geschäftsführer:
Dr. Jens Bartenwerfer
Michael Bathke
Volker Sonnenburg

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help