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/19 10:47:06 UTC

Problem with set:difference

I have found a problem that manifests itself in the set:difference extension
function. 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