Name

[2.0] unparsed-entity-public-id()

Returns the public ID of the unparsed entity with the specified name. If there is no such entity, unparsed-entity-public-id() returns an empty string.

Syntax

xs:string unparsed-entity-public-id(xs:string)

Input

The name of the unparsed entity.

Output

The public ID of the unparsed entity with the specified name.

Defined in

XSLT 2.0 section 16.6, “Miscellaneous Additional Functions.”

Example

Unparsed entities are rarely used; they typically refer to non-XML data, as in the entity author-picture defined in this XML document:

<?xml version="1.0"?>
<!-- unparsed-entity.xml -->
<!DOCTYPE book [
  <!ENTITY author-picture PUBLIC "-//OReilly//Author Images//DT"
    "dougtidwell.jpg" NDATA JPEG>
]>

<book>
  <prolog cover-image="author-picture"/>
  <body>
    <p>Pretend that lots of useful content appears here.</p>
  </body>
</book>

We’ll use this stylesheet to return the public ID of our unparsed entity:

<?xml version="1.0"?>
<!-- unparsed-entity-public-id.xsl -->
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:text>&#xA;A test of the unparsed-entity-</xsl:text>
    <xsl:text>public-id() function:</xsl:text>

    <xsl:text>&#xA;&#xA;   </xsl:text>
    <xsl:text>The public ID of the cover image is:&#xA;      </xsl:text>
    <xsl:value-of 
      select="unparsed-entity-public-id(/book/prolog/@cover-image)"/>
    <xsl:text>.&#xA;</xsl:text>
  </xsl:template>

</xsl:stylesheet>

When we transform the XML document with our stylesheet, ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.