Different union behaviour between xslt 1.0 and 2.0 and with and without namespaces

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

Different union behaviour between xslt 1.0 and 2.0 and with and without namespaces

Andrew Welch
With this XML:

<doc xmlns="def">
        <doc.title>title</doc.title>
</doc>

And this transform:

<xsl:transform version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:aa="abc"
        xmlns:bb="def">
       
<xsl:template match="/">
        1. <xsl:value-of select="/aa:doc/aa:doc.title|/bb:doc/bb:doc.title"/>
        2. <xsl:value-of select="/bb:doc/bb:doc.title"/>
</xsl:template>

</xsl:transform>

The output is:

<?xml version="1.0" encoding="UTF-8"?>
        1.
        2. title

Note that for some reason the second part of the union in 1. selects nothing.

If the transform is performed using xslt 1.0 (changing the version
attribute to 1.0), the output is:

<?xml version="1.0" encoding="utf-8"?>
        1. title
        2. title

Equally, removing the namespaces makes it work in both 1.0 and 2.0.

(Transformed using Saxon 6.5.4 and 8.6.1)

cheers
andrew


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Different union behaviour between xslt 1.0 and 2.0 and with and without namespaces

Michael Kay
>
> With this XML:
>
> <doc xmlns="def">
> <doc.title>title</doc.title>
> </doc>
>
> And this transform:
>
> <xsl:transform version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:aa="abc"
> xmlns:bb="def">
>
> <xsl:template match="/">
> 1. <xsl:value-of
> select="/aa:doc/aa:doc.title|/bb:doc/bb:doc.title"/>
> 2. <xsl:value-of select="/bb:doc/bb:doc.title"/>
> </xsl:template>
>
> </xsl:transform>
>
> The output is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> 1.
> 2. title
>
> Note that for some reason the second part of the union in 1.
> selects nothing.
>

I can't reproduce this. With Saxon 8.6.1 under JDK 1.5 I get

<?xml version="1.0" encoding="UTF-8"?>
        1. title
        2. title

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




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Understanding XSLT Performance

Matthias Born-3
Hi,

i've to review a customers stylesheet and to check the performance too. course
i'm not realy firm in how a xslt processer think and works, i've got a
question for you.

i've got very long xpath-expressions in nearly all match-patterns. sth. like
that:

<xsl:template match="/document/vendor_specific/vb:bib/vb:patdoc/vb:wopat/vb:
sdobi/vb:b200">

does this means, the processor always check all the ancestors?! if true, do
i've to keep the match-patterns as short as possible (here would <xsl:template
match="vb:b200"> be enought)? or does it makes no difference so i can let the
long xpaths for better understanding the context.

thx!

matze


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Understanding XSLT Performance

Michael Kay
 

> i've got very long xpath-expressions in nearly all
> match-patterns. sth. like
> that:
>
> <xsl:template
> match="/document/vendor_specific/vb:bib/vb:patdoc/vb:wopat/vb:
> sdobi/vb:b200">
>
> does this means, the processor always check all the
> ancestors?!

Yes, the processor will check that the element has all the required
ancestors.

> if true, do
> i've to keep the match-patterns as short as possible (here
> would <xsl:template
> match="vb:b200"> be enought)?

It's certainly more efficient to specify only as much of the ancestry as is
necessary to distinguish the element uniquely. Whether this actually makes a
measurable difference to the overall performance of your stylesheet is
another matter - the only way to find out is by measuring it.

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




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Different union behaviour between xslt 1.0 and 2.0 and with and without namespaces

Andrew Welch
In reply to this post by Michael Kay
> > With this XML:
> >
> > <doc xmlns="def">
> >       <doc.title>title</doc.title>
> > </doc>
> >
> > And this transform:
> >
> > <xsl:transform version="2.0"
> >       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >       xmlns:aa="abc"
> >       xmlns:bb="def">
> >
> > <xsl:template match="/">
> >       1. <xsl:value-of
> > select="/aa:doc/aa:doc.title|/bb:doc/bb:doc.title"/>
> >       2. <xsl:value-of select="/bb:doc/bb:doc.title"/>
> > </xsl:template>
> >
> > </xsl:transform>
> >
> > The output is:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >       1.
> >       2. title
> >
> > Note that for some reason the second part of the union in 1.
> > selects nothing.
> >
>
> I can't reproduce this. With Saxon 8.6.1 under JDK 1.5 I get
>
> <?xml version="1.0" encoding="UTF-8"?>
>         1. title
>         2. title

Sorry - It seems I was using Saxon 8.6 SA (not 8.6.1).... I hadn't
updated the -cp classpath properly on my work machine.

I get the expected output now.

cheers
andrew


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help