NPE in Saxon 9.5.1.2 while compiling stylesheet

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

NPE in Saxon 9.5.1.2 while compiling stylesheet

mozer
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xxx="http://www.w3.org/1999/XSL/Transform"
  version="2.0">
  <xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/>
 
  <xsl:template match="/bar">
    <xsl:variable name="bar" as="element(bar)">
    <bar>
      <xsl:copy-of select="@*"/>
      <xsl:copy-of select="node()"/>
    </bar>
    </xsl:variable>
    <xsl:apply-templates select="$bar"/>
  </xsl:template>
  <xsl:template match="/foo">
    <xxx:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:apply-templates select="*"/>
    </xxx:stylesheet>
  </xsl:template>
</xsl:stylesheet>

------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
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: NPE in Saxon 9.5.1.2 while compiling stylesheet

Imsieke, Gerrit, le-tex


On 04.03.2014 15:16, mozer wrote:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xxx="http://www.w3.org/1999/XSL/Transform"
>    version="2.0">
>    <xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/>

If you bind the xxx prefix to an arbitrary namespace URI that is
different from http://www.w3.org/1999/XSL/Transform, then it will work.

In the spec there’s a sentence on what should happen if result-prefix
and stylesheet-prefix are bound to the same URI. But I think the XSLT
namespace is special and stylesheet-prefix must not be bound to that URI.

Gerrit

------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
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: NPE in Saxon 9.5.1.2 while compiling stylesheet

Emanuel Wlaschitz
I certainly hope this is not the case! We have quite a few stylesheets that create XSLT fragments from XML (which in turn replace dummy-XSLT files that basically do no-op).
The stylesheets are pretty simple atm; and for now still XSLT 1.0 (transformed using .NET XslCompiledTransform) - but we're slowly trying to move everything over to SaxonN instead to get all the XSLT 2.0 and beyond goodness; and if that holds true we'll either sooner or later run into that issue, or need to keep those places using the old code.

- Emanuel

-----Original Message-----
From: Imsieke, Gerrit, le-tex [mailto:[hidden email]]
Sent: Dienstag, 04. März 2014 16:06
To: [hidden email]
Subject: Re: [saxon] NPE in Saxon 9.5.1.2 while compiling stylesheet



On 04.03.2014 15:16, mozer wrote:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xxx="http://www.w3.org/1999/XSL/Transform"
>    version="2.0">
>    <xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/>

If you bind the xxx prefix to an arbitrary namespace URI that is
different from http://www.w3.org/1999/XSL/Transform, then it will work.

In the spec there’s a sentence on what should happen if result-prefix
and stylesheet-prefix are bound to the same URI. But I think the XSLT
namespace is special and stylesheet-prefix must not be bound to that URI.

Gerrit

------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
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: NPE in Saxon 9.5.1.2 while compiling stylesheet

Emanuel Wlaschitz
Ok, feel free to ignore that. Just checked back with our developers and read the spec.

http://www.w3.org/TR/xslt#literal-result-element has the mentioned paragraph
"When literal result elements are being used to create element, attribute, or namespace nodes that use the XSLT namespace URI, the stylesheet must use an alias."
...and shows an example where the XSL/Transform has the word "Alias" appended.

The ones we use has the following fragment (to write <x:stylesheet/> etc):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="does-not-matter">
    <xsl:namespace-alias stylesheet-prefix="x" result-prefix="xsl"/>
[...]


-----Original Message-----
From: Emanuel Wlaschitz [mailto:[hidden email]]
Sent: Dienstag, 04. März 2014 16:17
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] NPE in Saxon 9.5.1.2 while compiling stylesheet

I certainly hope this is not the case! We have quite a few stylesheets that create XSLT fragments from XML (which in turn replace dummy-XSLT files that basically do no-op).
The stylesheets are pretty simple atm; and for now still XSLT 1.0 (transformed using .NET XslCompiledTransform) - but we're slowly trying to move everything over to SaxonN instead to get all the XSLT 2.0 and beyond goodness; and if that holds true we'll either sooner or later run into that issue, or need to keep those places using the old code.

- Emanuel

-----Original Message-----
From: Imsieke, Gerrit, le-tex [mailto:[hidden email]]
Sent: Dienstag, 04. März 2014 16:06
To: [hidden email]
Subject: Re: [saxon] NPE in Saxon 9.5.1.2 while compiling stylesheet



On 04.03.2014 15:16, mozer wrote:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xxx="http://www.w3.org/1999/XSL/Transform"
>    version="2.0">
>    <xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/>

If you bind the xxx prefix to an arbitrary namespace URI that is
different from http://www.w3.org/1999/XSL/Transform, then it will work.

In the spec there’s a sentence on what should happen if result-prefix
and stylesheet-prefix are bound to the same URI. But I think the XSLT
namespace is special and stylesheet-prefix must not be bound to that URI.

Gerrit

------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
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: NPE in Saxon 9.5.1.2 while compiling stylesheet

Michael Kay
In reply to this post by mozer
I assume you are aware that the xxx prefix is bound to the standard XSLT namespace.

The effect of this is that your stylesheet has an xxx:stylesheet (=xsl:stylesheet) element appearing as a child of xsl:template. This is an error (the children of xsl:template must all be instructions or literal result elements, and xxx:stylesheet is neither). But before Saxon gets around to reporting this error, it makes an incorrect assumption when processing the xsl:apply-templates child of xxx:stylesheet that the containing xxx:stylesheet element is the "real" stylesheet element.

So your stylesheet is in error, but of course Saxon shouldn't fail with an NPE and I will try to find a way of fixing this.

Normally when you use xsl:namespace-alias to generate stylesheets as your output, you should set stylesheet-prefix to the prefix you are using for instructions (here "xsl"), and result-prefix to the prefix used for generated elements, which should be bound to a DIFFERENT namespace.

Michael Kay
Saxonica


On 4 Mar 2014, at 14:16, mozer <[hidden email]> wrote:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xxx="http://www.w3.org/1999/XSL/Transform"
  version="2.0">
  <xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/>
 
  <xsl:template match="/bar">
    <xsl:variable name="bar" as="element(bar)">
    <bar>
      <xsl:copy-of select="@*"/>
      <xsl:copy-of select="node()"/>
    </bar>
    </xsl:variable>
    <xsl:apply-templates select="$bar"/>
  </xsl:template>
  <xsl:template match="/foo">
    <xxx:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:apply-templates select="*"/>
    </xxx:stylesheet>
  </xsl:template>
</xsl:stylesheet>
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
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: NPE in Saxon 9.5.1.2 while compiling stylesheet

mozer
Mike,

I certainly know all that

My surprise was the NPE of course

Regards,

Xmlizer

2014-03-04 16:43 GMT+01:00 Michael Kay <[hidden email]>:

> I assume you are aware that the xxx prefix is bound to the standard XSLT
> namespace.
>
> The effect of this is that your stylesheet has an xxx:stylesheet
> (=xsl:stylesheet) element appearing as a child of xsl:template. This is an
> error (the children of xsl:template must all be instructions or literal
> result elements, and xxx:stylesheet is neither). But before Saxon gets
> around to reporting this error, it makes an incorrect assumption when
> processing the xsl:apply-templates child of xxx:stylesheet that the
> containing xxx:stylesheet element is the "real" stylesheet element.
>
> So your stylesheet is in error, but of course Saxon shouldn't fail with an
> NPE and I will try to find a way of fixing this.
>
> Normally when you use xsl:namespace-alias to generate stylesheets as your
> output, you should set stylesheet-prefix to the prefix you are using for
> instructions (here "xsl"), and result-prefix to the prefix used for
> generated elements, which should be bound to a DIFFERENT namespace.
>
> Michael Kay
> Saxonica
>
>
> On 4 Mar 2014, at 14:16, mozer <[hidden email]> wrote:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:xxx="http://www.w3.org/1999/XSL/Transform"
>   version="2.0">
>   <xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/>
>
>   <xsl:template match="/bar">
>     <xsl:variable name="bar" as="element(bar)">
>     <bar>
>       <xsl:copy-of select="@*"/>
>       <xsl:copy-of select="node()"/>
>     </bar>
>     </xsl:variable>
>     <xsl:apply-templates select="$bar"/>
>   </xsl:template>
>   <xsl:template match="/foo">
>     <xxx:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>           <xsl:apply-templates select="*"/>
>     </xxx:stylesheet>
>   </xsl:template>
> </xsl:stylesheet>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries.  Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk_______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries.  Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help

------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help