Project

Profile

Help

Support #5339

closed

document-uri() returns empty sequence

Added by Johan Gheys almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2022-02-19
Due date:
% Done:

0%

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

Description

With version 10.6, document-uri() gives the uri of the loaded document (retrived using collection()): whereas in version 11.2 document-uri() returns an empty sequence: In both versions, base-uri() remains correct.


Files

document-uri-10.6-ok.png (12.1 KB) document-uri-10.6-ok.png Johan Gheys, 2022-02-19 15:40
document-uri-11.2-nok.png (8.75 KB) document-uri-11.2-nok.png Johan Gheys, 2022-02-19 15:43
batch.xslt (2.52 KB) batch.xslt Johan Gheys, 2022-02-19 15:46
Actions #1

Updated by Michael Kay almost 3 years ago

This change is almost certainly due to the way in which we decided to solve the problem described in bug #4837 - we were returning a document-uri() for documents in situations where we could not guarantee that every document would have a unique document URI.

I haven't looked at the detail of your test case yet, but it's not a surprise that the design change causes some existing code to break. We made the change very reluctantly, but spec conformance always comes first.

Actions #4

Updated by Michael Kay almost 3 years ago

Extracting the relevant information from bug #4837, the main problem is that by default in Saxon, the collection() function is not stable, while the doc() function is, which means that if you read the same collection twice, you can get two documents that have the same document-uri(), and this breaks the contract for document-uri(). But even if collections were stable, it's possible for two different collections to include the same underlying file, and there's no guarantee they will include the same version of that file; if both versions of the file have the same document-uri(), then there's no way of guaranteeing the basic equivalence that doc(document-uri($X)) is $X. The only resolution we could find is that documents returned by the collection() function should not have a document URI.

I do appreciate that we've made a change here that inconveniences users for what might seem rather pendantic conformance reasons. However, bug #4837 was not a theoretical problem, it was a real bug affecting a user-written application.

I wonder if base-url() or saxon:system-id() would meet the requirement?

Actions #5

Updated by Johan Gheys almost 3 years ago

OK, I will replace document-uri() with base-uri() everywhere.

Actions #6

Updated by Johan Gheys almost 3 years ago

For documents created in memory with xsl:document or temporary trees in general, the result of saxon:system-id() corresponds more closely to document-uri() than base-uri(), so I prefer saxon:system-id().

Actions #7

Updated by Michael Kay over 2 years ago

  • Tracker changed from Bug to Support
  • Status changed from New to Closed

Please register to edit this issue

Also available in: Atom PDF