Project

Profile

Help

Bug #6227

closed

document-uri() not working when using collection()

Added by Daniel Haley 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Start date:
2023-10-18
Due date:
% Done:

0%

Estimated time:
Found in version:
Fixed in version:
Platforms:

Description

I'm using saxonche version 12.3.0 installed using pip.

When using collection() in XSLT, document-uri() doesn't seem to be working.

I've created a small test and have attached a zip containing the Python, XSLT, and input files.

Python (using version 3.11.5)

import saxonche

with saxonche.PySaxonProcessor(license=False) as proc:
    xsltproc = proc.new_xslt30_processor()
    executable = xsltproc.compile_stylesheet(stylesheet_file="test.xsl")
    content = executable.call_template_returning_string()

    print(f"\ncontent:\n{content}")

XSLT 3.0

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" expand-text="yes">
    <xsl:output indent="yes" omit-xml-declaration="yes"/>
    <xsl:strip-space elements="*"/>
        
    <xsl:template name="xsl:initial-template">
        <xsl:for-each select="collection('input?select=*.(xml|XML)&amp;content-type=application/xml')">
            <xsl:message>Processing "{document-uri()}"...</xsl:message>
            <xsl:copy-of select="."/>
        </xsl:for-each>
    </xsl:template>
    
</xsl:stylesheet>

Output

Processing ""...
Processing ""...
Processing ""...

content:
<doc>First test XML instance.</doc>
<doc>Second test XML instance.</doc>
<doc>Third test XML instance.</doc>

The document URI is not in the "Processing" messages.


Files

test_saxonche_collection.zip (1.42 KB) test_saxonche_collection.zip Daniel Haley, 2023-10-19 01:05
Actions #1

Updated by Michael Kay 6 months ago

Please see bugs #5640 and #4837.

See in particular the comment:

Note that a document retrieved using the collection() function has a document-uri() property if and only if the collection is stable.

Actions #2

Updated by Daniel Haley 6 months ago

Michael Kay wrote in #note-1:

Please see bugs #5640 and #4837.

See in particular the comment:

Note that a document retrieved using the collection() function has a document-uri() property if and only if the collection is stable.

I must not be very good with the plan.io search feature. Thank you for pointing me in the right direction.

Actions #3

Updated by Michael Kay 6 months ago

More details at

https://www.saxonica.com/documentation12/index.html#!functions/fn/document-uri

I agree that the restrictions on document-uri() are very frustrating; they are a consequence of the way the function is specified in the W3C spec, but they are not a consequence that anyone predicted. There's an open issue on the 4.0 specs to reexamine this area (see https://github.com/qt4cg/qtspecs/issues/339) but it's not one that we have made any progress on resolving.

Actions #4

Updated by Michael Kay 6 months ago

When searching this site, a useful tip is to search across all projects. You encountered the problem in SaxonC, but the information you needed was in the plan.io Saxon project, which covers SaxonJ and SaxonCS. However, they are built from the same code so many problems are common across platforms.

Actions #5

Updated by Daniel Haley 6 months ago

Thank you for the additional info on document-uri() and the search tip. Very helpful!

Actions #6

Updated by O'Neil Delpratt 6 months ago

  • Status changed from New to Closed

I am closing this bug issue as questions have been answered.

Please register to edit this issue

Also available in: Atom PDF