xsl-list
[Top] [All Lists]

Re: [xsl] An xsl:number problem

2008-07-10 02:40:48
Xalan 1.9 returns the following:
<?xml version="1.0" encoding="UTF-8"?>
<doc nr="0">
 <a mark="true" nr="0"/>
 <a nr="2"/>
 <a nr="3"/>
 <a nr="4"/>
 <a mark="true" nr="0"/>
 <a nr="6"/>
 <a nr="7"/>
 <a nr="8"/>
</doc>

Edwin

On Thu, Jul 10, 2008 at 10:57 AM, Michael Kay <mike(_at_)saxonica(_dot_)com> 
wrote:
I've raised a bug report against the spec on this one, but I would be
interested to know how various processors handle it. Please try it and
report the results. The bug report is at

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5849

Source document:

<?xml version="1.0"?>
<doc>
 <a mark="true"/>
 <a/>
 <a/>
 <a/>
 <a mark="true"/>
 <a/>
 <a/>
 <a/>
</doc>

Stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
<xsl:output indent="yes"/>

<xsl:template match="*">
 <xsl:copy>
   <xsl:copy-of select="@*"/>
   <xsl:attribute name="nr">
     <xsl:number from="a[(_at_)mark='true']" count="a" level="any"/>
   </xsl:attribute>
   <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>

</xsl:stylesheet>

The output of Saxon 9.1 and other recent releases is clearly wrong, and is
being fixed by a patch. After correction, the output is still strange, but I
believe it is correct according to the spec:

<?xml version="1.0" encoding="UTF-8"?>
<doc nr="">
 <a mark="true" nr=""/>
 <a nr="2"/>
 <a nr="3"/>
 <a nr="4"/>
 <a mark="true" nr="5"/>
 <a nr="2"/>
 <a nr="3"/>
 <a nr="4"/>
</doc>

This is the Saxon 6.5.5 output:

<?xml version="1.0" encoding="utf-8"?>
<doc nr="">
  <a mark="true" nr="1"/>
  <a nr="1"/>
  <a nr="2"/>
  <a nr="3"/
  <a mark="true" nr="4"/>
  <a nr="1"/>
  <a nr="2"/>
  <a nr="3"/>
</doc>

The 1.0 spec is so terse that it's quite hard to decide whether this is
correct or not, but it's certainly not intuitive.

I would be interested to know what other XSLT 1.0 or 2.0 processors do with
this one.

I think the intuitively correct result is:

<?xml version="1.0" encoding="UTF-8"?>
<doc nr="">
 <a mark="true" nr="1"/>
 <a nr="2"/>
 <a nr="3"/>
 <a nr="4"/>
 <a mark="true" nr="1"/>
 <a nr="2"/>
 <a nr="3"/>
 <a nr="4"/>
</doc>

Do you agree?

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 
Edwin
PoeticTerror.Com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>