saxon:transform() and parameters

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

saxon:transform() and parameters

Florent Georges
  Hi

  The documentation of saxon:transform() says nothing about a way of
passing parameters to the stylesheet.  Is there such a way?

  Thanks, regards,

--drkm






















       

       
               
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Michael Kay
>
>   The documentation of saxon:transform() says nothing about a way of
> passing parameters to the stylesheet.  Is there such a way?
>

No, there isn't any way of doing this. I couldn't see any way of doing it
while keeping the function simple to use. You can always modify the
stylesheet tree to set parameter values before compiling it (a well-known
technique in the Microsoft DOM world).

Michael Kay
http://www.saxonica.com/




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Florent Georges
Michael Kay wrote:

> >   The documentation of saxon:transform() says nothing
> > about a way of passing parameters to the stylesheet.  Is
> > there such a way?

> No, there isn't any way of doing this.

  What a pity!  I like the idea to wrote some generation
script entirely in XSLT (thanks to the Saxon fn:collection()
directory facility).  But I need for that to pass parameters.

> I couldn't see any way of doing it while keeping the
> function simple to use.

    saxon:transform($compiled, $doc, ['name', $value]...)

or

    saxon:transform($compiled, $doc, (['name', $value]...))

(that is, with varargs, or with a sequence third argument).
It's what comes first to my mind, so I guess there are
some reasons you discarded these.

> You can always modify the stylesheet tree to set
> parameter values before compiling it (a well-known
> technique in the Microsoft DOM world).

  I didn't think about that.  But to do that, I need to copy
the whole stylesheet (more precisely all the styelsheets) but
the params I want to change, for each run, right?

  Thanks for your usefull and quick reply, as usual.

  Regards,

--drkm




















       

       
               
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Michael Kay
>
>     saxon:transform($compiled, $doc, ['name', $value]...)
>
> or
>
>     saxon:transform($compiled, $doc, (['name', $value]...))
>
> (that is, with varargs, or with a sequence third argument).


Well: varargs aren't supported by the language and can only be simulated by
having N functions with different arity; a sequence-valued argument doesn't
allow sequence-valued parameters; you really need to sequences one for the
names and one for the values (because sequences composed of alternating
pairs are really hard to manage) - there are ways round it but it's hard to
find a solution that's elegant.

Probably the most elegant solution is a callback function which the user
supplies and Saxon calls to get the value of a parameter given its name -
but that's more work to implement.

Michael Kay
http://www.saxonica.com/ 




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: saxon:transform() and parameters

ac-5
In reply to this post by Florent Georges
Hi,

Why not save them to XML and read the file on entry in the stylesheet ?

ac



Florent Georges a écrit :

> Michael Kay wrote:
>
>  
>>>   The documentation of saxon:transform() says nothing
>>> about a way of passing parameters to the stylesheet.  Is
>>> there such a way?
>>>      
>
>  
>> No, there isn't any way of doing this.
>>    
>
>   What a pity!  I like the idea to wrote some generation
> script entirely in XSLT (thanks to the Saxon fn:collection()
> directory facility).  But I need for that to pass parameters.
>
>  
>> I couldn't see any way of doing it while keeping the
>> function simple to use.
>>    
>
>     saxon:transform($compiled, $doc, ['name', $value]...)
>
> or
>
>     saxon:transform($compiled, $doc, (['name', $value]...))
>
> (that is, with varargs, or with a sequence third argument).
> It's what comes first to my mind, so I guess there are
> some reasons you discarded these.
>
>  
>> You can always modify the stylesheet tree to set
>> parameter values before compiling it (a well-known
>> technique in the Microsoft DOM world).
>>    
>
>   I didn't think about that.  But to do that, I need to copy
> the whole stylesheet (more precisely all the styelsheets) but
> the params I want to change, for each run, right?
>
>   Thanks for your usefull and quick reply, as usual.
>
>   Regards,
>
> --drkm
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ___________________________________________________________________________
> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
> Téléchargez sur http://fr.messenger.yahoo.com
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>  




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: saxon:transform() and parameters

Roger Kovack
I do that all the time. I get like 1 ms performance. And in a web
environment, you can cache session info on a network file system for
fast, failover, load balanced performance. Its much easier than EJB with
many of the core features of EJB.

Roger Kovack

ac wrote:

> Hi,
>
> Why not save them to XML and read the file on entry in the stylesheet ?
>
> ac
>
>
>
> Florent Georges a écrit :
>
>> Michael Kay wrote:
>>
>>  
>>
>>>>   The documentation of saxon:transform() says nothing
>>>> about a way of passing parameters to the stylesheet.  Is
>>>> there such a way?
>>>>      
>>>
>>
>>  
>>
>>> No, there isn't any way of doing this.
>>>    
>>
>>
>>   What a pity!  I like the idea to wrote some generation
>> script entirely in XSLT (thanks to the Saxon fn:collection()
>> directory facility).  But I need for that to pass parameters.
>>
>>  
>>
>>> I couldn't see any way of doing it while keeping the
>>> function simple to use.
>>>    
>>
>>
>>     saxon:transform($compiled, $doc, ['name', $value]...)
>>
>> or
>>
>>     saxon:transform($compiled, $doc, (['name', $value]...))
>>
>> (that is, with varargs, or with a sequence third argument).
>> It's what comes first to my mind, so I guess there are
>> some reasons you discarded these.
>>
>>  
>>
>>> You can always modify the stylesheet tree to set
>>> parameter values before compiling it (a well-known
>>> technique in the Microsoft DOM world).
>>>    
>>
>>
>>   I didn't think about that.  But to do that, I need to copy
>> the whole stylesheet (more precisely all the styelsheets) but
>> the params I want to change, for each run, right?
>>
>>   Thanks for your usefull and quick reply, as usual.
>>
>>   Regards,
>>
>> --drkm
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>    
>>
>>    
>>        
>> ___________________________________________________________________________
>> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les
>> tarifs exceptionnels pour appeler la France et l'international.
>> Téléchargez sur http://fr.messenger.yahoo.com
>>
>>
>> -------------------------------------------------------
>> This SF.Net email is sponsored by xPML, a groundbreaking scripting
>> language
>> that extends applications into web and mobile media. Attend the live
>> webcast
>> and join the prime developer group breaking into this new coding
>> territory!
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>> _______________________________________________
>> saxon-help mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>>  
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd_______________________________________________ 
>
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Florent Georges
In reply to this post by Michael Kay
Michael Kay wrote:

> >     saxon:transform($compiled, $doc, ['name', $value]...)

> > or

> >     saxon:transform($compiled, $doc, (['name', $value]...))

> > (that is, with varargs, or with a sequence third argument).

> Well: varargs aren't supported by the language and can only
> be simulated by having N functions with different arity;

  Does this mean that fn:concat() is implemented this way (by
having N overloads, from 2 to N+1 args)?

> a sequence-valued argument doesn't allow sequence-valued
> parameters;

  Yes, it's the whole problem, I didn't think a lot before
posting.

> you really need to sequences one for the names and one for
> the values (because sequences composed of alternating pairs
> are really hard to manage) - there are ways round it but
> it's hard to find a solution that's elegant.

> Probably the most elegant solution is a callback function
> which the user supplies and Saxon calls to get the value of
> a parameter given its name - but that's more work to
> implement.

  Intresting.  Or user functions returning a sequence whose
the first item is a string, the name of the param, allowing
to choose at the calling time (vs. the registering time) to
say "don't pass the param I was supposed to give you the
value, as I even don't give you the name, just an empty
sequence".

  Thanks for these ideas, regards,

--drkm





















       

       
               
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: saxon:transform() and parameters

Florent Georges
In reply to this post by ac-5
ac wrote:

> Why not save them to XML and read the file on entry in the
> stylesheet ?

  It could be a solution, yes.  But I even don't need that,
it's just a little script to run some test cases while
developping.  So I even prefer to get it simpliest and not
polluate the disk with temporary documents (well, I could use
a temporary directory, yes).

  But this require to use the serializer, and I don't know if
it's really a gain of time versus an indentity transformation
all in-memory.

  Thanks for the idea, regards,

--drkm



















       

       
               
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Willink, Ed
In reply to this post by Florent Georges
Hi

XSLT (unlike e.g. C) parameters are not ordered, so why not just
pass an additional Map argument?

        Regards

                Ed Willink

> >
> >     saxon:transform($compiled, $doc, ['name', $value]...)
> >
> > or
> >
> >     saxon:transform($compiled, $doc, (['name', $value]...))
> >
> > (that is, with varargs, or with a sequence third argument).
>
>
> Well: varargs aren't supported by the language and can only
> be simulated by
> having N functions with different arity; a sequence-valued
> argument doesn't
> allow sequence-valued parameters; you really need to
> sequences one for the
> names and one for the values (because sequences composed of
> alternating
> pairs are really hard to manage) - there are ways round it
> but it's hard to
> find a solution that's elegant.
>
> Probably the most elegant solution is a callback function
> which the user
> supplies and Saxon calls to get the value of a parameter
> given its name -
> but that's more work to implement.
>
> Michael Kay
> http://www.saxonica.com/ 
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking
> scripting language
> that extends applications into web and mobile media. Attend
> the live webcast
> and join the prime developer group breaking into this new
> coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&
dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help

*******************************************************************************
This email and any files transmitted with it are intended solely for the use of
the individual or entity to whom they are addressed and may not be divulged to
any third party without the express permission of the originator.  Any views
expressed in this message are those of the individual sender, except where the
sender specifically states them to be the views of Thales Research & Technology
(UK) Limited.
*******************************************************************************



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Michael Kay
>
> XSLT (unlike e.g. C) parameters are not ordered, so why not just
> pass an additional Map argument?

Because there is no such thing as a Map in the XPath type system.

Michael Kay
http://www.saxonica.com/




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Ed Willink
Hi Michael
> > XSLT (unlike e.g. C) parameters are not ordered, so why not
> just pass
> > an additional Map argument?
>
> Because there is no such thing as a Map in the XPath type system.

Oops. Not paying attention, thought we were discussing the Java function.

How about defining a saxon:map document and passing it?

<saxon:map>
   <key name="a" value="b"/>
   <key name="b">
        <value>
                <mylist ..../>
        </value>
   </key>
</saxon:map>

        Regards

                Ed Willink



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Michael Kay
 

> How about defining a saxon:map document and passing it?
>
> <saxon:map>
>    <key name="a" value="b"/>
>    <key name="b">
> <value>
> <mylist ..../>
> </value>
>    </key>
> </saxon:map>

Well, very often you want to pass a node as the value of a parameter.

Michael Kay
http://www.saxonica.com/




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Florent Georges
Michael Kay wrote:

> Well, very often you want to pass a node as the value of
> a parameter.

  And what about something like this:

    <xsl:variable name="params" as="element()+"
                  xmlns="http://saxon.sf.net/">
      <param name="name" select="'something'"/>
      <param name="node" select="some/node"/>
      <param name="tree">
        ...
      </param>
    </xsl:variable>
    <xsl:sequence
        select="saxon:transform($script, $doc, $params)"/>

where {http://saxon.sf.net/}param is evaluated like xsl:variable?

  Regards,

--drkm
























       

       
               
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Florent Georges
In reply to this post by Michael Kay
Michael Kay wrote:

> Well, very often you want to pass a node as the value of
> a parameter.

  And what about something like this:

    <xsl:variable name="params" as="element()+"
                  xmlns="http://saxon.sf.net/">
      <param name="name" select="'something'"/>
      <param name="node" select="some/node"/>
      <param name="tree">
        ...
      </param>
    </xsl:variable>
    <xsl:sequence
        select="saxon:transform($script, $doc, $params)"/>

where {http://saxon.sf.net/}param is evaluated like xsl:variable?

  Regards,

--drkm
























       

       
               
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: saxon:transform() and parameters

Michael Kay
In reply to this post by Florent Georges
>   And what about something like this:
>
>     <xsl:variable name="params" as="element()+"
>                   xmlns="http://saxon.sf.net/">
>       <param name="name" select="'something'"/>
>       <param name="node" select="some/node"/>
>       <param name="tree">
>         ...
>       </param>
>     </xsl:variable>
>     <xsl:sequence
>         select="saxon:transform($script, $doc, $params)"/>

Yes - that's getting back to my original proposal of making it a
higher-order function with a callback to calculate the variable's value.

Michael Kay




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help