You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2004/04/01 09:47:36 UTC

DO NOT REPLY [Bug 28118] New: - Assertion fails in set:difference (2 matching nodesets, one created by a key)

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28118>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28118

Assertion fails in set:difference (2 matching nodesets, one created by a key)

           Summary: Assertion fails in set:difference (2 matching nodesets,
                    one created by a key)
           Product: XalanJ2
           Version: CurrentCVS
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xpath
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: peter.edwards@astrazeneca.com


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. It seems to happen when the two 
sets in the difference are the same and one of them is produced using a key. 
(It works if you simply difference two identical sets, or if the sets are 
different)

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>

Please contact me if you need more info.