You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by "Edwards, Peter" <Pe...@astrazeneca.com> on 2004/03/31 10:43:58 UTC

Problem with set:difference (please respond)

I have sent this message to both the dev and the user lists but had no
responses. I'm pretty sure there is a problem and I have provided a test
case - please could someone have a look.

I have used xalan for years and am hoping that if I have identified a
problem, this will help keep it the quality product it is.

Thanks
Pete


-----Original Message-----
From: Edwards, Peter 
Sent: 19 March 2004 09:47
To: 'xalan-j-users@xml.apache.org'
Subject: Problem with set:difference


I have found a problem that manifests itself in the set:difference extension
function using Xalan 2.6.0. The error I get is 
  "Assertion fails: Can not get a DTM unless a DTMManager has been set"
in org.apache.xpath.NodeSet.addNodes (line 441)

In the sample below you get the exception, but it succeeds if you remove one
of the continent elements from the input document.

Example document:
  <doc>
    <continent>Europe</continent>
  <!-- remove next line to see stylesheet succeed -->
    <continent>Africa</continent> 
    <city name="Paris" continent="Europe"/>
    <city name="Madrid" continent="Europe"/>
    <city name="Cairo" continent="Africa"/>
  </doc>

Example stylesheet:
  <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:set="http://exslt.org/sets" 
    xmlns:exsl="http://exslt.org/common" 
    extension-element-prefixes="set exsl" 
    exclude-result-prefixes="set exsl">

    <xsl:key name="cityByContinent" match="//city" use="@continent"/>

    <xsl:template match="/">
      <out>
        <xsl:variable name="continents" select="//continent"/>
        <xsl:variable name="list" 
             select="key('cityByContinent', set:distinct($continents))"/>
        <xsl:copy-of select="set:difference(//city, $list)"/>
      </out>
    </xsl:template>
  </xsl:stylesheet>

It looks like a bug to me but I do not know the code well enough to be sure.

Pete Edwards

Re: Problem with set:difference (please respond)

Posted by Morris Kwan <mk...@ca.ibm.com>.



Hi, Peter

This looks like a bug in Xalan. Can you create a bug in the Apache bugzilla
database (http://nagoya.apache.org/bugzilla)? The developers might be busy
and do not have time to try the testcase at the moment. If you create a bug
report, people can look at the problem at a later time.

Thanks for reporting the problem.

Morris Kwan
XSLT Development
IBM Toronto Lab
Tel: (905)413-3729
Email: mkwan@ca.ibm.com



                                                                           
             "Edwards, Peter"                                              
             <Peter.Edwards@as                                             
             trazeneca.com>                                             To 
                                       "'xalan-j-users@xml.apache.org'"    
             03/31/2004 03:43          <xa...@xml.apache.org>      
             AM                                                         cc 
                                                                           
                                                                   Subject 
                                       Problem with set:difference (please 
                                       respond)                            
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




I have sent this message to both the dev and the user lists but had no
responses. I'm pretty sure there is a problem and I have provided a test
case - please could someone have a look.

I have used xalan for years and am hoping that if I have identified a
problem, this will help keep it the quality product it is.

Thanks
Pete


-----Original Message-----
From: Edwards, Peter
Sent: 19 March 2004 09:47
To: 'xalan-j-users@xml.apache.org'
Subject: Problem with set:difference


I have found a problem that manifests itself in the set:difference
extension
function using Xalan 2.6.0. The error I get is
  "Assertion fails: Can not get a DTM unless a DTMManager has been set"
in org.apache.xpath.NodeSet.addNodes (line 441)

In the sample below you get the exception, but it succeeds if you remove
one
of the continent elements from the input document.

Example document:
  <doc>
    <continent>Europe</continent>
  <!-- remove next line to see stylesheet succeed -->
    <continent>Africa</continent>
    <city name="Paris" continent="Europe"/>
    <city name="Madrid" continent="Europe"/>
    <city name="Cairo" continent="Africa"/>
  </doc>

Example stylesheet:
  <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:set="http://exslt.org/sets"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="set exsl"
    exclude-result-prefixes="set exsl">

    <xsl:key name="cityByContinent" match="//city" use="@continent"/>

    <xsl:template match="/">
      <out>
        <xsl:variable name="continents" select="//continent"/>
        <xsl:variable name="list"
             select="key('cityByContinent', set:distinct($continents))"/>
        <xsl:copy-of select="set:difference(//city, $list)"/>
      </out>
    </xsl:template>
  </xsl:stylesheet>

It looks like a bug to me but I do not know the code well enough to be
sure.

Pete Edwards