Name
[2.0]
unparsed-text-available()
Given a URI, returns true if that document is available,
false otherwise. This function
allows you to check the existence and availability of a document
before you attempt to open it with unparsed-text(). If you attempt to
open a document that is unavailable, the XSLT processor raises a
fatal error.
Syntax
xs:booleanunparsed-text-available(xs:string)xs:booleanunparsed-text-available(xs:string,xs:string)
Inputs
An xs:string specifying
the URI of the requested document. An optional second string
specifies the document’s encoding.
Output
true if the document is
unavailable; false
otherwise.
Defined in
XSLT 2.0 section 16.2, “Reading Text Files.”
Example
Here’s a short stylesheet that checks to see whether three different files are available:
<?xml version="1.0"?> <!-- unparsed-text-available.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>
Here are some tests of the </xsl:text> <xsl:text>unparsed-text-available() function:</xsl:text> <xsl:text>

 unparsed-text-available</xsl:text> <xsl:text>('header.html') = </xsl:text> <xsl:value-of select="unparsed-text-available('header.html')"/> <xsl:text>

 unparsed-text-available</xsl:text> <xsl:text>('disclaimer.html') = </xsl:text> <xsl:value-of select="unparsed-text-available('disclaimer.html')"/> <xsl:text>

 unparsed-text-available</xsl:text> <xsl:text>('footer.html') = </xsl:text> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access