Saxon-HE, call-out to (eg) Java, to generate GUIDs

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

Saxon-HE, call-out to (eg) Java, to generate GUIDs

Kerry, Richard

 

I am developing a stylesheet which needs to generate a couple of GUIDs for each file it processes.

I can easily generate a number of them from my Windows batch file that I'm using to run Saxon, and pass them in as parameters.  However, I don't actually know how many I'll need as that depends on the contents of another file.  So I think I need to make a call to some other program each time I need one.

I have found a method to do that [1].  However, when I try it I am advised by Saxon that "Reflexive calls to Java methods are not available under Saxon-HE".  Is there any way to call out to another application (whether Java or not) from Saxon-HE ?

If I can't do that I think I will need to do my whole process in several stages, first to count the number needed, then back to the batch file to actually generate them, then back into XSL to use them.

 

Regards,

Richard.

 

Richard Kerry

BNCS Engineer, SI SOL Telco & Media Vertical Practice

 

T: +44 (0)20 3618 2669

M: +44 (0)7812 325518

Lync: +44 (0) 20 3618 0778

Room G300, Stadium House, Wood Lane, London, W12 7TA

[hidden email]

 

 

 

Atos, Atos Consulting, Worldline and Canopy The Open Cloud Company are trading names used by the Atos group. The following trading entities are registered in England and Wales: Atos IT Services UK Limited (registered number 01245534), Atos Consulting Limited (registered number 04312380), Atos Worldline UK Limited (registered number 08514184) and Canopy The Open Cloud Company Limited (registration number 08011902). The registered office for each is at 4 Triton Square, Regent’s Place, London, NW1 3HG.The VAT No. for each is: GB232327983.

This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information. If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it. Please notify the sender immediately and delete this email from your systems. As emails may be intercepted, amended or lost, they are not secure. Atos therefore can accept no liability for any errors or their content. Although Atos endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos by email.

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

_______________________________________________
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
|

Saxon-HE, call-out to (eg) Java, to generate GUIDs

Kerry, Richard

 

I am developing a stylesheet which needs to generate a couple of GUIDs for each file it processes.

I can easily generate a number of them from my Windows batch file that I'm using to run Saxon, and pass them in as parameters.  However, I don't actually know how many I'll need as that depends on the contents of another file.  So I think I need to make a call to some other program each time I need one.

I have found a method to do that [1].  However, when I try it I am advised by Saxon that "Reflexive calls to Java methods are not available under Saxon-HE".  Is there any way to call out to another application (whether Java or not) from Saxon-HE ?

If I can't do that I think I will need to do my whole process in several stages, first to count the number needed, then back to the batch file to actually generate them, then back into XSL to use them.

 

Regards,

Richard.

 

PS

Apologies if this has turned up more than once for anyone.  I’ve only just subscribed and I seem to have had a bit of a syntax problem.

 

 

Richard Kerry

BNCS Engineer, SI SOL Telco & Media Vertical Practice

 

T: +44 (0)20 3618 2669

M: +44 (0)7812 325518

Lync: +44 (0) 20 3618 0778

Room G300, Stadium House, Wood Lane, London, W12 7TA

[hidden email]

 

 

 

Atos, Atos Consulting, Worldline and Canopy The Open Cloud Company are trading names used by the Atos group. The following trading entities are registered in England and Wales: Atos IT Services UK Limited (registered number 01245534), Atos Consulting Limited (registered number 04312380), Atos Worldline UK Limited (registered number 08514184) and Canopy The Open Cloud Company Limited (registration number 08011902). The registered office for each is at 4 Triton Square, Regent’s Place, London, NW1 3HG.The VAT No. for each is: GB232327983.

This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information. If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it. Please notify the sender immediately and delete this email from your systems. As emails may be intercepted, amended or lost, they are not secure. Atos therefore can accept no liability for any errors or their content. Although Atos endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos by email.

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

_______________________________________________
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
|

Saxon-HE, call-out to (eg) Java, to generate GUIDs

Kerry, Richard
In reply to this post by Kerry, Richard
I am developing a stylesheet which needs to generate a couple of GUIDs for each file it processes.
I can easily generate a number of them from my Windows batch file that I'm using to run Saxon, and pass them in as parameters.  However, I don't actually know how many I'll need as that depends on the contents of another file.  So I think I need to make a call to some other program each time I need one.
I have found a method to do that [1].  However, when I try it I am advised by Saxon that "Reflexive calls to Java methods are not available under Saxon-HE".  Is there any way to call out to another application (whether Java or not) from Saxon-HE ?
If I can't do that I think I will need to do my whole process in several stages, first to count the number needed, then back to the batch file to actually generate them, then back into XSL to use them.

Regards,
Richard.

PS
Apologies if this has turned up more than once for anyone.  I’ve only just subscribed and I seem to have had a bit of a syntax problem.
May be ok this time as it should now be plain text.




Richard Kerry
BNCS Engineer, SI SOL Telco & Media Vertical Practice

T: +44 (0)20 3618 2669
M: +44 (0)7812 325518
Lync: +44 (0) 20 3618 0778
Room G300, Stadium House, Wood Lane, London, W12 7TA
[hidden email]





Atos, Atos Consulting, Worldline and Canopy The Open Cloud Company are trading names used by the Atos group. The following trading entities are registered in England and Wales: Atos IT Services UK Limited (registered number 01245534), Atos Consulting Limited (registered number 04312380), Atos Worldline UK Limited (registered number 08514184) and Canopy The Open Cloud Company Limited (registration number 08011902). The registered office for each is at 4 Triton Square, Regent’s Place, London, NW1 3HG.The VAT No. for each is: GB232327983.

This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information. If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it. Please notify the sender immediately and delete this email from your systems. As emails may be intercepted, amended or lost, they are not secure. Atos therefore can accept no liability for any errors or their content. Although Atos endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos by email.
------------------------------------------------------------------------------
_______________________________________________
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-HE, call-out to (eg) Java, to generate GUIDs

Florent Georges-3
Hi,

Reflexive calls means for Saxon to call a Java function based on
mapping a namespace to a Java class, following some naming
conventions.  I don't remember the exact details, but the idea is
something like:

    <xsl:sequence
       xmlns:c="java:org.example.project.MyClass"
       select="c:java-function('param')"/>

You can even instantiate objects and call methods on them (above, it
would look for a static function).  Actual details may vary, but
that's the idea: a dynamic lookup performed by Saxon, based on a
namespace-to-class-name mapping.

The alternative is to write integrated functions.  You create a class
that implements a specific interface (representing an extension
function).  The class implements methods providing information about
an XPath function: its name, its parameters, and a method that
actually implements the XPath function when it is invoked (e.g. from
XSLT, in your case that's the part calculating and returning a GUID).

There are 4 main differences from a user (of Saxon) perspective
between both approaches:

- for integrated function you have to write code specific to Saxon
- you need to configure Saxon with the integrated functions (either in
your Java application, or by using a config file or an initializer)
- with integrated functions, your XSLT and XQuery code remains
portable (the namespace mapping is specific to Saxon)
- integrated functions are available in HE, reflexive are not

Usually, I would say reflexive extensions (if you have a commercial
license) are convenient when you want to call some Java code in a
one-shot XSLT script, nothing used in production.  If you have HE, or
if you want to use extension in production, I prefer to use integrated
functions anyway.

The project https://github.com/expath/tools-saxon provides some tools
for writing integrated extension functions, hiding some of the
complexity.  Especially WRT writing the definition of the function
(its name, the type of the parameters, etc.)

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 17 December 2015 at 16:51, Kerry, Richard wrote:

> I am developing a stylesheet which needs to generate a couple of GUIDs for each file it processes.
> I can easily generate a number of them from my Windows batch file that I'm using to run Saxon, and pass them in as parameters.  However, I don't actually know how many I'll need as that depends on the contents of another file.  So I think I need to make a call to some other program each time I need one.
> I have found a method to do that [1].  However, when I try it I am advised by Saxon that "Reflexive calls to Java methods are not available under Saxon-HE".  Is there any way to call out to another application (whether Java or not) from Saxon-HE ?
> If I can't do that I think I will need to do my whole process in several stages, first to count the number needed, then back to the batch file to actually generate them, then back into XSL to use them.
>
> Regards,
> Richard.
>
> PS
> Apologies if this has turned up more than once for anyone.  I’ve only just subscribed and I seem to have had a bit of a syntax problem.
> May be ok this time as it should now be plain text.
>
>
>
>
> Richard Kerry
> BNCS Engineer, SI SOL Telco & Media Vertical Practice
>
> T: +44 (0)20 3618 2669
> M: +44 (0)7812 325518
> Lync: +44 (0) 20 3618 0778
> Room G300, Stadium House, Wood Lane, London, W12 7TA
> [hidden email]
>
>
>
>
>
> Atos, Atos Consulting, Worldline and Canopy The Open Cloud Company are trading names used by the Atos group. The following trading entities are registered in England and Wales: Atos IT Services UK Limited (registered number 01245534), Atos Consulting Limited (registered number 04312380), Atos Worldline UK Limited (registered number 08514184) and Canopy The Open Cloud Company Limited (registration number 08011902). The registered office for each is at 4 Triton Square, Regent’s Place, London, NW1 3HG.The VAT No. for each is: GB232327983.
>
> This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information. If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it. Please notify the sender immediately and delete this email from your systems. As emails may be intercepted, amended or lost, they are not secure. Atos therefore can accept no liability for any errors or their content. Although Atos endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos by email.
> ------------------------------------------------------------------------------
> _______________________________________________
> 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-HE, call-out to (eg) Java, to generate GUIDs

Florent Georges-3
On 17 December 2015 at 17:31, Florent Georges wrote:

> The project https://github.com/expath/tools-saxon provides some tools
> for writing integrated extension functions, hiding some of the
> complexity.

I forgot to mention...  You can have a look at the following classes,
for a real example of a et of extension functions using the above
tools:

https://github.com/fgeorges/expath-file-java/tree/master/file-saxon/src/org/expath/file/saxon

The class in that directory is a library, which contains 32 extension
functions, all in the same namespace, implemented each by a class in
one of the 3 sub-directories.

Hope that helps, regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/

------------------------------------------------------------------------------
_______________________________________________
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-HE, call-out to (eg) Java, to generate GUIDs

honyk
Hi Florent,

On 2015-12-17 Florent Georges wrote:

> On 17 December 2015 at 17:31, Florent Georges wrote:
>
> > The project https://github.com/expath/tools-saxon provides some tools
> > for writing integrated extension functions, hiding some of the
> > complexity.
>
> I forgot to mention...  You can have a look at the following classes,
> for a real example of a et of extension functions using the above
> tools:
>
> https://github.com/fgeorges/expath-file-java/tree/master/file-
> saxon/src/org/expath/file/saxon
>
> The class in that directory is a library, which contains 32 extension
> functions, all in the same namespace, implemented each by a class in
> one of the 3 sub-directories.
>

it looks cool, but to be honest, I'd be grateful for any less technical
step-by-step description how to utilize this framework for checking e.g.
whether the path specified as an xml attribute exists.

I mean example xml, xsl and steps how to configure saxon to be able to
process all this stuff.

I scanned GitHub pages quickly and haven't found something like that.

Thanks, Jan


------------------------------------------------------------------------------
_______________________________________________
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-HE, call-out to (eg) Java, to generate GUIDs

Florent Georges-3
In reply to this post by Florent Georges-3
On 17 December 2015 at 20:15, Jan Tosovsky wrote:

Hi,

> it looks cool, but to be honest, I'd be grateful for any less technical
> step-by-step description how to utilize this framework for checking e.g.
> whether the path specified as an xml attribute exists.

> I mean example xml, xsl and steps how to configure saxon to be able to
> process all this stuff.

Not sure what you mean by "whether the path specified as an xml
attribute exists" or by "to process all this stuff", in the context of
writing extension functions for Saxon.

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/

------------------------------------------------------------------------------
_______________________________________________
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-HE, call-out to (eg) Java, to generate GUIDs

Martin Honnen-2
Florent Georges wrote:
> On 17 December 2015 at 20:15, Jan Tosovsky wrote:

>> it looks cool, but to be honest, I'd be grateful for any less technical
>> step-by-step description how to utilize this framework for checking e.g.
>> whether the path specified as an xml attribute exists.
>
>> I mean example xml, xsl and steps how to configure saxon to be able to
>> process all this stuff.
>
> Not sure what you mean by "whether the path specified as an xml
> attribute exists" or by "to process all this stuff", in the context of
> writing extension functions for Saxon.

Is http://cxan.org/ not working? I do get a 500 error for
http://cxan.org/ as well as for http://cxan.org/pkg/expath/file-saxon.
Are the binaries of EXPath for Saxon HE available somewhere?


------------------------------------------------------------------------------
_______________________________________________
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-HE, call-out to (eg) Java, to generate GUIDs

Florent Georges-3
Thanks Martin.

I am upgrading Servlex on CXAN, for new developments.  The prod server
should be up and running now.  the test server is purposefully shut
down.  Sorry for the trouble, I should put a "maintenance page" in
that case.

The Tools JAR files are anyway available on the EXPath website, are
they are not packages themselves (they are Java helper classes for
writing such extensions, and are shipped with the repo manager and
Servlex):

http://expath.org/files

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 17 December 2015 at 21:59, Martin Honnen wrote:

> Florent Georges wrote:
>> On 17 December 2015 at 20:15, Jan Tosovsky wrote:
>
>>> it looks cool, but to be honest, I'd be grateful for any less technical
>>> step-by-step description how to utilize this framework for checking e.g.
>>> whether the path specified as an xml attribute exists.
>>
>>> I mean example xml, xsl and steps how to configure saxon to be able to
>>> process all this stuff.
>>
>> Not sure what you mean by "whether the path specified as an xml
>> attribute exists" or by "to process all this stuff", in the context of
>> writing extension functions for Saxon.
>
> Is http://cxan.org/ not working? I do get a 500 error for
> http://cxan.org/ as well as for http://cxan.org/pkg/expath/file-saxon.
> Are the binaries of EXPath for Saxon HE available somewhere?
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> 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-HE, call-out to (eg) Java, to generate GUIDs

honyk
In reply to this post by Florent Georges-3
On 2015-12-17 Florent Georges wrote:

> On 17 December 2015 at 20:15, Jan Tosovsky wrote:
> >
> > it looks cool, but to be honest, I'd be grateful for any less
> > technical step-by-step description how to utilize this framework
> > for checking e.g. whether the path specified as an xml attribute
> > exists.
>
> > I mean example xml, xsl and steps how to configure saxon to be
> > able to process all this stuff.
>
> Not sure what you mean by "whether the path specified as an xml
> attribute exists" or by "to process all this stuff", in the context of
> writing extension functions for Saxon.

Curently I use something like this (not in HE):

xml:
<node path="D:/test.pdf"/>

xsl (snippet):
<xsl:if test="file:exists(file:new(@path))" xmlns:file="java.io.File">
  <xsl:text>file exists</xsl:text>
</xsl:if>

No additional settings is required.

You offer an alternative, but I am lost in technical details. I believe a
small 'example of use' would be beneficial for anybody entering your project
pages to have a rough idea how much effort is needed to get the same result.

Thanks, Jan


------------------------------------------------------------------------------
_______________________________________________
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-HE, call-out to (eg) Java, to generate GUIDs

Florent Georges-3
In reply to this post by Florent Georges-3
On 17 December 2015 at 22:26, Jan Tosovsky wrote:

> Curently I use something like this (not in HE):

> xml:
> <node path="D:/test.pdf"/>

> xsl (snippet):
> <xsl:if test="file:exists(file:new(@path))" xmlns:file="java.io.File">
>   <xsl:text>file exists</xsl:text>
> </xsl:if>

> No additional settings is required.

> You offer an alternative, but I am lost in technical details. I believe a
> small 'example of use' would be beneficial for anybody entering your project
> pages to have a rough idea how much effort is needed to get the same result.

Right.  Saxon Tools are helpers to write plain integrated functions,
so I more or less expect people interested to already know how to
write them, just looking for some classes to ease the task.

But it would not harm to explain how to write a (library of) extension
function(s) for Saxon, from scratch.

Thanks for the feedback!

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/

------------------------------------------------------------------------------
_______________________________________________
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-HE, call-out to (eg) Java, to generate GUIDs

Florent Georges-3
FYI, I added more comprehensive documentation, as well as how to
register the extensions against Saxon (either from Java code or from
the command line) at the end:

https://github.com/expath/tools-saxon/tree/master/doc

For any further comments, I guess we should leave the Saxon mailing
list quiet, and switch to the EXPath mailing list.

But the rule is: these tools help defining integrated functions for
Saxon.  You can register them like any other integrated functions.
Because they ARE integrated functions.

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 17 December 2015 at 22:55, Florent Georges wrote:

> On 17 December 2015 at 22:26, Jan Tosovsky wrote:
>
>> Curently I use something like this (not in HE):
>
>> xml:
>> <node path="D:/test.pdf"/>
>
>> xsl (snippet):
>> <xsl:if test="file:exists(file:new(@path))" xmlns:file="java.io.File">
>>   <xsl:text>file exists</xsl:text>
>> </xsl:if>
>
>> No additional settings is required.
>
>> You offer an alternative, but I am lost in technical details. I believe a
>> small 'example of use' would be beneficial for anybody entering your project
>> pages to have a rough idea how much effort is needed to get the same result.
>
> Right.  Saxon Tools are helpers to write plain integrated functions,
> so I more or less expect people interested to already know how to
> write them, just looking for some classes to ease the task.
>
> But it would not harm to explain how to write a (library of) extension
> function(s) for Saxon, from scratch.
>
> Thanks for the feedback!
>
> Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/

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