The unparsed-entity-public-id() function gives access to the public identifier of unparsed entities declared in the DTD of the source document.
This function is new in XSLT 2.0.
Argument | Data Type | Meaning |
---|---|---|
name | xs:string | Specifies the name of the unparsed entity required. The value of the string should be an XML Name. |
Result | xs:string | The public identifier of the unparsed entity with the given name, if there is one. Otherwise, a zero-length string. |
This function operates on the document containing the context node. An error is reported if the context item is undefined, or if it is not a node, or if it is a node in a tree whose root is not a document node.
If the document containing the context node includes an unparsed entity whose name is equal to the supplied string, and if the unparsed entity has a public identifier (signaled by the PUBLIC keyword in XML) then the public identifier is returned. In all other cases, it returns a zero-length string.
Unparsed entities are one of the more rarely used features of XML; they derive from SGML, and this explains why people who use unparsed entities are also inclined to use public identifiers to refer to them. Public identifiers were designed to tackle the same problem as URNs, namely to provide a way of giving unique names to objects, without becoming locked in to the location where the object can be found. They are often used in conjunction with Oasis catalogs.
Note that it is the public identifier of the unparsed entity that is returned, not the public identifier of the notation named in its NDATA clause. The data model does not provide any information about notations.
For example, if the DTD contains the declaration:
<!ENTITY weather-map SYSTEM "weather.jpeg" PUBLIC "-//MEGACORP//WEATHER/"NDATA JPEG>
then the expression «unparsed-entity-public-id('weather-map') » returns the public identifier «-//MEGACORP//WEATHER/ » .
unparsed-entity-uri () in the following section.