Running Saxon from the command line without a source xml

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Running Saxon from the command line without a source xml

Andrew Welch
Is it possible to start Saxon 8.5.x from the command line without
giving a source xml file?

I currently transform a directory of XML files using the collection()
function, and to execute the transform I apply the stylesheet to
itself - is there any way to just specify a stylesheet?

thanks
andrew


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running Saxon from the command line without a source xml

George Cristian Bina
Hi Andrew,

You need to set a name for the main template if you do not have that
already and then use:

***
-it template
       

Selects the initial named template to be executed. If this is
namespaced, it can be written as {uri}localname. When this option is
used, the source file should be omitted.

and eventually:
-im modename
       

Selects the initial mode for the transformation. If this is namespaced,
it can be written as {uri}localname
***
See for full details:
http://www.saxonica.com/documentation/using-xsl/commandline.html

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


andrew welch wrote:

> Is it possible to start Saxon 8.5.x from the command line without
> giving a source xml file?
>
> I currently transform a directory of XML files using the collection()
> function, and to execute the transform I apply the stylesheet to
> itself - is there any way to just specify a stylesheet?
>
> thanks
> andrew
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running Saxon from the command line without a source xml

Andrew Welch
On 9/9/05, George Cristian Bina <[hidden email]> wrote:

> Hi Andrew,
>
> You need to set a name for the main template if you do not have that
> already and then use:
>
> ***
> -it template
>
>
> Selects the initial named template to be executed. If this is
> namespaced, it can be written as {uri}localname. When this option is
> used, the source file should be omitted.
>
> and eventually:
> -im modename
>
>
> Selects the initial mode for the transformation. If this is namespaced,
> it can be written as {uri}localname
> ***
> See for full details:
> http://www.saxonica.com/documentation/using-xsl/commandline.html

Hi George,

I meant run the transform without a source XML file eg:

java net.sf.saxon.Transform stylesheet.xslt

currently I have to apply the stylesheet to itself:

java net.sf.saxon.Transform stylesheet.xslt stylesheet.xslt

This is fine, I was just wondering if there was a switch to allow the
omission of the source xml file.

(Maybe that is what you have given me and I've missed something...?)


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running Saxon from the command line without a source xml

George Cristian Bina
Hi Andrew,

Yes, the -it option allows you to do exactly that, see:

-it template


Selects the initial named template to be executed. If this is
namespaced, it can be written as {uri}localname. *When this option is
used, the source file should be omitted.*
------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


andrew welch wrote:

> On 9/9/05, George Cristian Bina <[hidden email]> wrote:
>
>>Hi Andrew,
>>
>>You need to set a name for the main template if you do not have that
>>already and then use:
>>
>>***
>>-it template
>>
>>
>>Selects the initial named template to be executed. If this is
>>namespaced, it can be written as {uri}localname. When this option is
>>used, the source file should be omitted.
>>
>>and eventually:
>>-im modename
>>
>>
>>Selects the initial mode for the transformation. If this is namespaced,
>>it can be written as {uri}localname
>>***
>>See for full details:
>>http://www.saxonica.com/documentation/using-xsl/commandline.html
>
>
> Hi George,
>
> I meant run the transform without a source XML file eg:
>
> java net.sf.saxon.Transform stylesheet.xslt
>
> currently I have to apply the stylesheet to itself:
>
> java net.sf.saxon.Transform stylesheet.xslt stylesheet.xslt
>
> This is fine, I was just wondering if there was a switch to allow the
> omission of the source xml file.
>
> (Maybe that is what you have given me and I've missed something...?)
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running Saxon from the command line without a source xml

Andrew Welch
On 9/9/05, George Cristian Bina <[hidden email]> wrote:

> Hi Andrew,
>
> Yes, the -it option allows you to do exactly that, see:
>
> -it template
>
>
> Selects the initial named template to be executed. If this is
> namespaced, it can be written as {uri}localname. *When this option is
> used, the source file should be omitted.*
> ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Yes, sorry George, I took it from your initial response that you could
do it somehow without having a named template.


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Running Saxon from the command line without a source xml

Michael Kay
If there's no source file then you can't start processing at <xsl:template
match="/">, because "/" wouldn't match anything - so you have to start at a
named template.

Michael Kay

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> andrew welch
> Sent: 09 September 2005 14:40
> To: [hidden email]
> Subject: Re: [saxon] Running Saxon from the command line
> without a source xml
>
> On 9/9/05, George Cristian Bina <[hidden email]> wrote:
> > Hi Andrew,
> >
> > Yes, the -it option allows you to do exactly that, see:
> >
> > -it template
> >
> >
> > Selects the initial named template to be executed. If this is
> > namespaced, it can be written as {uri}localname. *When this
> option is
> > used, the source file should be omitted.*
> > ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Yes, sorry George, I took it from your initial response that you could
> do it somehow without having a named template.
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development
> Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams *
> Testing & QA
> Security * Process Improvement & Measurement *
> http://www.sqe.com/bsce5sf
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running Saxon from the command line without a source xml

Andrew Welch
On 9/9/05, Michael Kay <[hidden email]> wrote:
> If there's no source file then you can't start processing at <xsl:template
> match="/">, because "/" wouldn't match anything - so you have to start at a
> named template.
 
...but if / is a named template then you can?

Everything seems to work fine if I give the root matching template
name and specify that with -it

which makes me wonder why you couldnt start processing at / when no
source file and no initial template has been given?

Maybe it's because internally you can't execute a template unless it
has a name or you have something for it to match?  Just thinking out
loud now...


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running Saxon from the command line without a source xml

Colin Paul Adams
>>>>> "Andrew" == andrew welch <[hidden email]> writes:

    Andrew> On 9/9/05, Michael Kay <[hidden email]> wrote:
    >> If there's no source file then you can't start processing at
    >> <xsl:template match="/">, because "/" wouldn't match anything -
    >> so you have to start at a named template.
 
    Andrew> ...but if / is a named template then you can?

Yes.
FXSL for XSLT 2.0 has all the initial templates declared as:

<xsl:template match="/" name="initial" >

if a source document is not required.
That way, Dmitre can specify a dummy source document (as that is the
way he prefers to work), and I can specify an initial template (as I
like to work from the command line).

    Andrew> which makes me wonder why you couldnt start processing at
    Andrew> / when no source file and no initial template has been
    Andrew> given?

    Andrew> Maybe it's because internally you can't execute a template
    Andrew> unless it has a name or you have something for it to
    Andrew> match?  Just thinking out loud now...

Yes.
Basically, you have nothing for '/' to match against.
When you have no source document, there is no initial context node.
--
Colin Adams
Preston Lancashire


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Running Saxon from the command line without a source xml

Michael Kay
In reply to this post by Andrew Welch
>
> which makes me wonder why you couldnt start processing at / when no
> source file and no initial template has been given?
>

The draft spec did at one stage say that there must always be a source
document, and if you don't supply an explicit source document you get a
dummy document that just contains a document node. But the WG decided it was
better to have the initial context node undefined in this situation, so that
you get an error if there are any global variables that rely on an initial
context node.

It wouldn't make sense to start processing at "/" if there's no source
document, because someone writing a template that starts <xsl:template
match="/"> (and indeed a processor compiling such a template rule) is
entitled to assume that there is a context node and it will be a document
node.

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




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Loading...