XSLT and XPath function reference in alphabetical order
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)
Association and localisation of nodes and resources at runtime
A URI of xs:anyURI type; the URI string of an external, unparsed entity. For this purpose, the base URIs of the involved resources are taken into account (DTD/Schema, stylesheet, source document and result document) in order to ensure the subsequent correct embedding of the entity.
The argument passed on must be the identifier of an unparsed entity. If no ENTITY declaration for this identifier exists, the function returns an empty string.
Purpose of use:
The function returns the URI resolved against the base URI of that unparsed entity whose entity name was passed on to it. The function always refers to the document in which the context node being valid at the moment of the function call is located.
It is an error if the function is called up in case the context item is not a node or the tree in which the context node lies does not have a document node (ERR XTDE1370).
The XSLT function unparsed-entity-uri() is used in order to adjust the paths between the generated document and an external resource in such a way that the URI relation is maintained. In the simple case of an internal DTD, the return value of the function corresponds to the path between the reference and the resource. The XSLT processor may complete the path to an absolute path which takes into acount the position of the generated XML document; for WWW files an absolute URL is the result.
In the simple case of an internal DTD and under the condition that the source document and the result document reside in the same directory, the function outputs the absolute address of the result document and attaches to the address the relative path to the entity.
The matter becomes more complex in case of an external DTD. Here, in addition to the path between DTD and entity, also the path between source document and DTD is included. If the result document additionally resides in another directory, it is also included in the path.
Example – resolution of the URI of an unparsed entity:
If the DTD contains a declaration in the following form:
<!ENTITY image SYSTEM "images/my_image.jpg" NDATA JPEG>
resturns a HTML <img> tag whose href attribute contains the (absolute) URI of the image. The function automatically resolves paths which result from the path relations of the source document and the result document and the DTD (which, for example, may reside in different directories).
unparsed-entity-uri(string) => string
unparsed-entity-uri($entity-name as xs:string) as xs:anyURI
Possible compatibility problems XSLT 2.0 to XSLT 1.0:
In XSLT 2.0 there is a theoretical possibility to call the function without having a valid current node – however, this causes a runtime error (dynamic error).
|<< back||next >>|
Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany