O'Reilly logo

XSLT by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

element-available() Function — Determines if a given element is available to the XSLT processor. This function allows you to design stylesheets that react gracefully if a particular element is not available to process an XML document.

Synopsis

boolean element-available(
               string
               )

Inputs

The element’s name. The name should be qualified with a namespace; if the namespace URI is the same as the XSLT namespace URI, then the element name refers to an element defined by XSLT. Otherwise, the name refers to an extension element. If the element name has a null namespace URI, then the element-available function returns false.

Output

The boolean value true if the element is available; false otherwise.

Defined in

XSLT section 15, Fallback.

Example

We’ll use the following example to test the element-available() function:

<?xml version="1.0"?> <book> <title>XSLT</title> <chapter> <title>Getting Started</title> <para>If this chapter had any text, it would appear here.</para> </chapter> <chapter> <title>The Hello World Example</title> <para>If this chapter had any text, it would appear here.</para> </chapter> <chapter> <title>XPath</title> <para>If this chapter had any text, it would appear here.</para> </chapter> <chapter> <title>Stylesheet Basics</title> <para>If this chapter had any text, it would appear here.</para> </chapter> <chapter> <title>Branching and Control Elements</title> <para>If this chapter had any text, it would appear here.</para> </chapter> <chapter> <title>Functions</title> <para>If ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required