You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Scott Moore <pu...@cox.net> on 2002/09/20 22:27:44 UTC

Bug in Xalan 2.4.0 with position()

I've found what I consider to be a major bug in Xalan.  The following simple
files illustrate the problem:

XML:

<test>
 <pos>1</pos>
 <pos>2</pos>
</test>


XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:template match="/">
  <xsl:apply-templates/>
 </xsl:template>

 <xsl:template match="pos">
  <xsl:message>position() = <xsl:value-of select="position()"/>  Real
position is <xsl:value-of select="."/></xsl:message>
 </xsl:template>
</xsl:stylesheet>


Output:

<?xml version="1.0" encoding="UTF-8"?>

file:///C:/pos.xslt; Line #9;
Column #16; position() = 2  Real position is 1

file:///C:/pos.xslt; Line #9;
Column #16; position() = 4  Real position is 2



This is killing me.  I can't roll back to 2.3.1 because of bugs in that
version with <xsl:variable>.  What's the timeline for a new release of
2.4.x?

Thanks,
Scott




Re: Bug in Xalan 2.4.0 with position()

Posted by Joseph Kesselman <ke...@us.ibm.com>.
See other note; it's a Xerces question and setting the feature is only 
part of the equation.

______________________________________
Joe Kesselman  / IBM Research

Re: Bug in Xalan 2.4.0 with position()

Posted by Scott Moore <pu...@cox.net>.
>
parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whit
> espace", true);

I've actually tried setting this to both true and false.  Neither seems to
make a difference.  Is this the wrong setting for Xerces to remove
whitespace?

Scott


Re: Bug in Xalan 2.4.0 with position()

Posted by Scott Moore <pu...@cox.net>.
> 1) You said include=true, which is the opposite of what you seem to want.

Yeah, I caught that after I sent the email.

> 2) Ignorable whitespace is a bad term. It's really "whitespace in element
> content". This is only recognized if you know what is and isn't element
> content -- in other words, if you have validated the document against a
> DTD (or _maybe_ a schema, though schema validation tends to annotate the
> Infoset rather than changing it and thus may not affect us until XSLT 2.0
> adds schema awareness... and maybe not then).

false doesn't help either I guess because I'm not validating against a DTD.
Ah well.  I did find a solution though: <xsl:strip-space element="*"/>.


Re: Bug in Xalan 2.4.0 with position()

Posted by Joseph Kesselman <ke...@us.ibm.com>.
On Friday, 09/20/2002 at 04:40 AST, "Scott Moore" <pu...@cox.net> 
wrote:
> 
parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whit
> espace", true);
> 
> Shouldn't this remove all whitespace nodes?  I do the transform directly 
on
> the already parsed DOM.

That's a Xerces question rather than a Xalan question, but:

1) You said include=true, which is the opposite of what you seem to want.

2) Ignorable whitespace is a bad term. It's really "whitespace in element 
content". This is only recognized if you know what is and isn't element 
content -- in other words, if you have validated the document against a 
DTD (or _maybe_ a schema, though schema validation tends to annotate the 
Infoset rather than changing it and thus may not affect us until XSLT 2.0 
adds schema awareness... and maybe not then).

______________________________________
Joe Kesselman  / IBM Research

Re: Bug in Xalan 2.4.0 with position()

Posted by Scott Moore <pu...@cox.net>.
Hmm, now I'm really confused.  In my Java code, I'm doing this:

    DOMParser parser = new DOMParser();


parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whit
espace", true);

Shouldn't this remove all whitespace nodes?  I do the transform directly on
the already parsed DOM.

Scott


----- Original Message -----
From: "Scott Moore" <pu...@cox.net>
To: <xa...@xml.apache.org>
Sent: Friday, September 20, 2002 4:33 PM
Subject: Re: Bug in Xalan 2.4.0 with position()


> Okay, nevermind.  I just saw the answer to my bugzilla post.
>
> Now my question is - why does MSXML 4.0 eliminate element whitespace by
> default but Xalan does not?  Which is the correct behavior (if there is
> one).
>
> Thanks,
> Scott
>
> P.S. Sorry about the bogus bug report.
>
>


Re: Bug in Xalan 2.4.0 with position()

Posted by Joseph Kesselman <ke...@us.ibm.com>.
Correct behavior is to retain whitespace unless the user says it can be 
filtered out. As to why MSXML doesn't do that... ask them?

______________________________________
Joe Kesselman  / IBM Research

Re: Bug in Xalan 2.4.0 with position()

Posted by Scott Moore <pu...@cox.net>.
Okay, nevermind.  I just saw the answer to my bugzilla post.

Now my question is - why does MSXML 4.0 eliminate element whitespace by
default but Xalan does not?  Which is the correct behavior (if there is
one).

Thanks,
Scott

P.S. Sorry about the bogus bug report.