This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 105908 - Incorrect calculation of set intersection / set difference using Michael Kay's method
Summary: Incorrect calculation of set intersection / set difference using Michael Kay'...
Status: RESOLVED WONTFIX
Alias: None
Product: xml
Classification: Unclassified
Component: XSLT Model (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Alexey Yarmolenko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-06 16:59 UTC by jaqenn
Modified: 2007-09-16 23:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Data used to generate bug demonstration (405 bytes, application/octet-stream)
2007-06-06 17:00 UTC, jaqenn
Details
Stylesheet used to demonstrate bug (1.50 KB, application/octet-stream)
2007-06-06 17:01 UTC, jaqenn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jaqenn 2007-06-06 16:59:27 UTC
I am unclear if the XSL processing tools used by the Netbeans Enterprise pack
are provided with Netbeans, or with my JRE.  I may be filing this bug report in
the wrong place.

Using Netbeans to perform an XSL Transformation produces an incorrect result. 
It appears that this is a result of incorrectly evaluating statements like this:

select="root/data[count(. | $subset1) != count($subset1)]"

Applying this stylesheet:
----------------
<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>

    <xsl:template match="/">
        <xsl:variable name="allNodes" select="root/data" />        
        <xsl:variable name="subset1" select="root/data[position() >3]" />        
        <xsl:variable name="subset2" select="root/data[count(. | $subset1) !=
count($subset1)]" />
        
        <xsl:element name="TransformationResults">
            <xsl:element name="SourceNodes">
                <xsl:attribute name="description">All nodes</xsl:attribute>
                <xsl:for-each select="$allNodes">
                    <xsl:copy-of select="." />
                </xsl:for-each>
            </xsl:element>
            
            <xsl:element name="Subset1">
                <xsl:attribute name="description">A subset of all
nodes</xsl:attribute>
                <xsl:for-each select="$subset1">
                    <xsl:copy-of select="." />
                </xsl:for-each>
            </xsl:element>
            
            <xsl:element name="Subset2">
                <xsl:attribute name="description">A subset of nodes calculated
(via Michael Kay's method) as 'All nodes' minus 'Subset 1'</xsl:attribute>
                <xsl:for-each select="$subset2">
                    <xsl:copy-of select="." />
                </xsl:for-each>
            </xsl:element>
        </xsl:element>
        
    </xsl:template>

</xsl:stylesheet>

----------------

To this document:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="BugReportStyleSheet.xsl.xsl"?>

<root>
   <data>A</data>
   <data>B</data>
   <data>C</data>
   <data>D</data>
   <data>E</data>
   <data>F</data>
</root>

----------------

Produces this result when processed by whatever Netbeans uses:
----------------
<TransformationResults>
<SourceNodes description="All nodes">
<data>A</data>
<data>B</data>
<data>C</data>
<data>D</data>
<data>E</data>
<data>F</data>
</SourceNodes>
<Subset1 description="A subset of all nodes">
<data>D</data>
<data>E</data>
<data>F</data>
</Subset1>
<Subset2 description="A subset of nodes calculated (via Michael Kay's method) as
'All nodes' minus 'Subset 1'"/>
</TransformationResults>
----------------

And produces this result when processed by Xalan-J 2.7.0, by Saxon 6.5.5, and by
whatever Firefox 2.0.0.3 uses:
----------------
<transformationresults>
<sourcenodes description="All nodes">
<data>A</data>
<data>B</data>
<data>C</data>
<data>D</data>
<data>E</data>
<data>F</data>
</sourcenodes>

<subset1 description="A subset of all nodes">
<data>D</data>
<data>E</data>
<data>F</data>
</subset1>

<subset2 description="A subset of nodes calculated (via Michael Kay's method) as
'All nodes' minus 'Subset 1'">
<data>A</data>
<data>B</data>
<data>C</data>
</subset2>
</transformationresults>
----------------

Note that the contents of the 'Subset2' node differ between outputs.
Comment 1 jaqenn 2007-06-06 17:00:29 UTC
Created attachment 43322 [details]
Data used to generate bug demonstration
Comment 2 jaqenn 2007-06-06 17:01:01 UTC
Created attachment 43323 [details]
Stylesheet used to demonstrate bug
Comment 3 Alexey Yarmolenko 2007-06-09 12:26:28 UTC
Netbeans uses JRE-Default XSLT processor, so i doubt if we can fix this on our side.
Comment 4 Karthikeyan Rajeswaran 2007-06-11 00:03:29 UTC
As per
http://www.netbeans.org/source/browse/xml/xsl/src/org/netbeans/modules/xsl/utils/TransformUtil.java?rev=1.6.76.1.16.1&view=markup
, the TransformerFactory is obatined via the TransformerFactory.newInstance() call.

From the documentation of
http://java.sun.com/webservices/docs/1.5/api/javax/xml/transform/TransformerFactory.html
,
    Obtain a new instance of a TransformerFactory. This static method creates a
new factory instance. This method uses the following ordered lookup procedure to
determine the TransformerFactory implementation class to load:
    * Use the javax.xml.transform.TransformerFactory system property.
    * Use the properties file "lib/jaxp.properties" in the JRE directory. This
onfiguration file is in standard java.util.Properties format and contains the
fully qualified name of the implementation class with the key being the system
property defined above.
    * Use the Services API (as detailed in the JAR specification), if available,
to determine the classname. The Services API will look for a classname in the
file META-INF/services/javax.xml.transform.TransformerFactory in jars available
to the runtime.
    * Platform default TransformerFactory instance.

Can you try setting property to point to a different xslt processor and see if
it works?