Project

Profile

Help

Support #5942

closed

Handling of elements without text() child elements changed between 9.8.x.x and 9.9.x.x

Added by Marijn Sanderse almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
Start date:
2023-03-27
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Java

Description

If I have an XML document

* <EmptyDoc />*

and I perform the following test

*<xsl:if test="EmptyDoc/text()=''">*

that test is TRUE in 9.8.x.x but it is FALSE in 9.9.x.x and 11.5

I can see the reasoning behind the change (there is no text node so it cannot be equal to "") and I can see the impossibility in you changing this back after so much time but it is a bit of a headache for me given the 300+ services I am maintaining that could all suffer from this when I upgrade to a more current Saxon version.

Are there any pointers you could give me about how to handle this? Like:

  • is there I flag I can provide that reinstates previous behaviour?
  • what kind of statements also to look for?

Any help is really appreciated, thanks in advance

SaxonEE on Java


Files

saxon-textnode.tgz (2.66 KB) saxon-textnode.tgz problem reproducer Marijn Sanderse, 2023-03-28 15:19
Actions #1

Updated by Marijn Sanderse almost 2 years ago

That xml document is

Actions #2

Updated by Marijn Sanderse almost 2 years ago

  <EmptyDoc />
Actions #3

Updated by Michael Kay almost 2 years ago

  • Description updated (diff)
Actions #4

Updated by Michael Kay almost 2 years ago

If what you're saying is correct, then that would most definitely be a bug in 9.8. It seems a rather unlikely one, and certainly with a quick test using Saxon-HE 9.8.0.15, I can't reproduce it. I suspect something more subtle is going on. Perhaps you could put together a repro that demonstrates the problem, a test cases that produces different results under different releases?

One possible explanation might be, for example, that the input is supplied as a programmatically-constructed DOM tree in which there is a zero-length text node. That's something that the XDM data model used by XPath doesn't allow, and over time we might have become better at "repairing" it to be conformant. That's a wild guess, but I suspect that getting to the bottom of it is going to involve some set of specific circumstances like that.

Actions #5

Updated by Marijn Sanderse almost 2 years ago

Constructing the repro taught me that the "problem" is indeed a bit different than I initially thought: in 9.8 and before it was possible to cast a string value to a node() and then get its value from the text() node. In that scenario $var/text()='' did return true and now return false.

See testTextNodeFromEmpty2() in MyTransformerTest in the attached reproducer.

That is not something I expect or hope you will solve so I will be cleaning up my xslt's

Actions #6

Updated by Michael Kay almost 2 years ago

Thanks. I haven't been able to track down a specific issue here, but from what you're saying it looks as if Saxon 9.8 for

<xsl:variable name="x">
  <xsl:value-of select="''"/>
</xsl:variable>

was incorrectly producing a document node containing a single empty text node child, rather than a document node with no children.

Actions #7

Updated by Michael Kay over 1 year ago

I've confirmed that the bug was present in 9.9.1.4 but was fixed in 9.9.1.5.

Unfortunately, that hasn't enabled me to locate the specific bug issue.

But out of insatiable curiosity I traced the execution in a 9.8 build, and found it was bug #4246.

Bug #4246 is documented as being fixed in 9.9.1.7 rather than 9.9.1.5 - that's because we found that 9.9.1.5 only contained a partial fix, it didn't solve it in the case of bytecode generation, and the full fix only came in 9.9.1.7.

Not that this information is useful to anyone, I'm afraid.

Actions #8

Updated by Michael Kay over 1 year ago

  • Status changed from New to Closed

Please register to edit this issue

Also available in: Atom PDF