mirror of
https://github.com/alexandrev/xslt-lab.git
synced 2026-09-18 19:43:16 +00:00
53e90ef86e
Full coverage of XSLT 1.0, 2.0 and 3.0 elements and XPath functions: - 59 XSLT elements (xsl:stylesheet → xsl:use-accumulators) - 170 XPath functions (1.0 node/string/numeric/boolean, 2.0 sequence/ date/QName/string, 3.0 HOF/map/array/JSON/streaming) Each page: description, parameters table, return value, 2 runnable Saxon examples with input XML + stylesheet + output, notes, cross-links. xsltCompletions.js: all 229 entries now have blogSlug for hover links. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.8 KiB
2.8 KiB
title, description, date, version, versionLabel, category, syntax, tags
| title | description | date | version | versionLabel | category | syntax | tags | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| uri-collection() | Returns a sequence of xs:anyURI values from a named collection, giving the URIs of the contained documents. | 2026-04-18T00:00:00Z | 2.0 | XSLT 2.0 | node function | uri-collection(uri?) |
|
Description
uri-collection() returns a sequence of xs:anyURI values — the URIs of documents in a collection — rather than the documents themselves. It is the URI counterpart of collection(): instead of loading each document, it gives you the URIs so you can decide how and when to load them.
This is useful when you want to inspect, filter, or log available URIs before loading, or when you want to load documents selectively.
Formally part of XPath 3.0; supported by Saxon 9.x+ with XSLT 2.0 stylesheets.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
uri |
xs:string? | No | URI identifying the collection. Omit for the default collection. |
Return value
xs:anyURI* — a sequence of URIs of the documents in the collection.
Examples
List available XML files in a directory
Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<file-list>
<xsl:for-each select="uri-collection('file:///data/books/?select=*.xml')">
<file><xsl:value-of select="."/></file>
</xsl:for-each>
</file-list>
</xsl:template>
</xsl:stylesheet>
Output (example):
<file-list>
<file>file:///data/books/book1.xml</file>
<file>file:///data/books/book2.xml</file>
</file-list>
Selectively load large files based on URI pattern
Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<result>
<!-- Only load files whose name starts with 'report-' -->
<xsl:for-each select="uri-collection('file:///data/?select=*.xml')
[matches(., 'report-')]">
<xsl:variable name="doc" select="doc(.)"/>
<entry uri="{.}">
<title><xsl:value-of select="$doc/*/title"/></title>
</entry>
</xsl:for-each>
</result>
</xsl:template>
</xsl:stylesheet>
Notes
- The URI syntax follows the same Saxon-specific conventions as
collection():file:///path/?select=*.xml. uri-collection()does not load the documents; usedoc()ordocument()to load them individually.- Formally part of XPath 3.0; available in Saxon 9.x+ with XSLT 2.0 stylesheets.