<html>
<head>
<title>element-available() ֐</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME">element-available() ֐</td>
<td valign="top" class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr>
<td valign="top" colspan="2" class="description">
w肳ꂽvf XSLT vZbTɑ΂ėpł邩ǂ𒲂ׂ܂B̊֐gpƁAXML hLg邽߂ɓ̗vfpłȂꍇłAX^CV[g݌vł܂B </td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>vf̖OB̖O͖OԂgpĐݒ肵܂BO URI  XSLT ̖O URI ƓłꍇAvf XSLT ɂĒ`vfQƂ܂BȊȌꍇA̖O͊gvfQƂ܂Bvf null O URI ꍇA<span class="LITERAL">element-available</span> ֐ <span class="LITERAL">false</span> Ԃ܂B </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">o</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>vfpłꍇ̓u[l <span class="LITERAL">true</span>AȊȌꍇ <span class="LITERAL">false</span>B </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">`</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>XSLT 15 ߁uFallbackv</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>̗gp <span class="LITERAL">element-available()</span> ֐eXg܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;book&gt;
  &lt;title&gt;XSLT&lt;/title&gt;
  &lt;chapter&gt;
    &lt;title&gt;Getting Started&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;The Hello World Example&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;XPath&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;Stylesheet Basics&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;Branching and Control Elements&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;Functions&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;Creating Links and Cross-References&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;Sorting and Grouping Elements&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
  &lt;chapter&gt;
    &lt;title&gt;Combining XML Documents&lt;/title&gt;
    &lt;para&gt;If this chapter had any text, it would appear here.&lt;/para&gt;
  &lt;/chapter&gt;
&lt;/book&gt;</pre></span>
<p>X^CV[ĝ͎ƂłB</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
<!--<?troff .Nd 10?>-->
  xmlns:saxon="http://icl.com/saxon"
  extension-element-prefixes="redirect saxon"&gt;

  &lt;xsl:output method="html"/&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="element-available('redirect:write')"&gt;
        &lt;xsl:for-each select="/book/chapter"&gt;
          &lt;redirect:write select="concat('chapter', position(), '.html')"&gt;
            &lt;html&gt;
              &lt;head&gt;
                &lt;title&gt;&lt;xsl:value-of select="title"/&gt;&lt;/title&gt;
              &lt;/head&gt;
              &lt;body&gt;
                &lt;h1&gt;&lt;xsl:value-of select="title"/&gt;&lt;/h1&gt;
                &lt;xsl:apply-templates select="para"/&gt;
                &lt;xsl:if test="not(position()=1)"&gt;
                  &lt;p&gt;
                    &lt;a href="chapter{position()-1}.html"&gt;Previous&lt;/a&gt;
                  &lt;/p&gt;
                &lt;/xsl:if&gt;
                &lt;xsl:if test="not(position()=last())"&gt;
                  &lt;p&gt;
                    &lt;a href="chapter{position()+1}.html"&gt;Next&lt;/a&gt;
                  &lt;/p&gt;
                &lt;/xsl:if&gt;
              &lt;/body&gt;
            &lt;/html&gt;
          &lt;/redirect:write&gt;
        &lt;/xsl:for-each&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:when test="element-available('saxon:output')"&gt;
        &lt;xsl:for-each select="/book/chapter"&gt;
          &lt;saxon:output file="chapter{position()}.html"&gt;
            &lt;html&gt;
              &lt;head&gt;
                &lt;title&gt;&lt;xsl:value-of select="title"/&gt;&lt;/title&gt;
              &lt;/head&gt;
              &lt;body&gt;
                &lt;h1&gt;&lt;xsl:value-of select="title"/&gt;&lt;/h1&gt;
                &lt;xsl:apply-templates select="para"/&gt;
                &lt;xsl:if test="not(position()=1)"&gt;
                  &lt;p&gt;
                    &lt;a href="chapter{position()-1}.html"&gt;Previous&lt;/a&gt;
                  &lt;/p&gt;
                &lt;/xsl:if&gt;
                &lt;xsl:if test="not(position()=last())"&gt;
<!--<?troff .Nd 10?>-->
                  &lt;p&gt;
                    &lt;a href="chapter{position()+1}.html"&gt;Next&lt;/a&gt;
                  &lt;/p&gt;
                &lt;/xsl:if&gt;
              &lt;/body&gt;
            &lt;/html&gt;
          &lt;/saxon:output&gt;
        &lt;/xsl:for-each&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;html&gt;
          &lt;head&gt;
            &lt;title&gt;&lt;xsl:value-of select="/book/title"/&gt;&lt;/title&gt;
          &lt;/head&gt;
          &lt;xsl:for-each select="/book/chapter"&gt;
            &lt;h1&gt;&lt;xsl:value-of select="title"/&gt;&lt;/h1&gt;
            &lt;xsl:apply-templates select="para"/&gt;
          &lt;/xsl:for-each&gt;
        &lt;/html&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
    &lt;xsl:if test="not(element-available('write'))"&gt;
      &lt;xsl:message terminate="no"&gt;
        The &lt;write&gt; element is not available!
      &lt;/xsl:message&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="para"&gt;
    &lt;p&gt;&lt;xsl:apply-templates select="*|text()"/&gt;&lt;/p&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre></span>
<p>̃X^CV[ǵAXML t@C̃Rec󂯎Äꕔʂ HTML t@CɏƂ܂Bŏ <span class="LITERAL">&lt;chapter&gt;</span> vf̓t@C <filename>chapter1.html</filename>A2 Ԗڂ <span class="LITERAL">&lt;chapter&gt;</span> vf̓t@C <filename>chapter2.html</filename>Â悤ɏ܂܂B̃X^CV[ǵAŏ Xalan  <span class="LITERAL">&lt;redirect:write&gt;</span> vfgp悤Ƃ܂B̗vfpłȂꍇ́ASaxon  <span class="LITERAL">&lt;saxon:output&gt;</span> vf`FbN܂B̗̂vfpłȂꍇAׂĂ <span class="LITERAL">&lt;chapter&gt;</span> vf̃Rec𓯂o̓Xg[ɏ݂܂B̃X^CV[ǵAݒ肳ĂȂvf <span class="LITERAL">write</span> gp <span class="LITERAL">element-available()</span> ֐Ăяo܂B̌Ăяo͏ <span class="LITERAL">false</span> Ԃ܂A͗vfOԂŐݒ肳ĂȂ߂łB </p>
<p>Xalan gpÃX^CV[g XML t@CłꍇAR\[̌ʂ͎̂悤ɂȂ܂B</p>
<span class="PROGRAMLISTING"><pre>
file:///D:/O'Reilly/XSLT/bookSamples/AppendixC/elementavailable.xsl; Line 66; 
Column 35; The &lt;write&gt; element is not available!</pre></span>
<!--<?troff .Nd 10?>-->
<p>X^CV[g̓t@C <filename>chapter1.html</filename> ` <filename>chapter9.html</filename> 𐶐܂Bet@Cɂ́Ãt@C <span class="LITERAL">&lt;chapter&gt;</span> vf 1 ̃f[^܂܂܂B̃X^CV[g͏͂̃t@CԂ̃nCp[N܂B<filename>chapter3.html</filename> Ɏ܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;html&gt;
   &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
   
      &lt;title&gt;XPath&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
      &lt;h1&gt;XPath&lt;/h1&gt;
      &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
      &lt;p&gt;&lt;a href="chapter2.html"&gt;Previous&lt;/a&gt;&lt;/p&gt;
      &lt;p&gt;&lt;a href="chapter4.html"&gt;Next&lt;/a&gt;&lt;/p&gt;
   &lt;/body&gt;
&lt;/html&gt;</pre></span>
<p>̃t@ĆAuEUŕ\ƁA<link linkend="xslt-appc-c1">} C-1</link> ̂悤ɂȂ܂B</p>
<figure id="xslt-appc-c1" label="C-1">
<p class="TITLE">HTML ̃Tvo̓t@C</p>
        <graphic depth="205" width="386" fileref="figs/xslt.ac01.gif"/>
      </figure>
<p>[Previous] NNbNƃt@C <filename>chapter2.html</filename> ɈړA[Next] NNbN <filename>chapter4.html</filename> Ɉړ܂B</p>
<p>Saxon ŃX^CV[ggp (R}h <span class="LITERAL">java com.icl.saxon.StyleSheet chapterlist.xml elementavailable.xsl</span> gp)AR\[ł́Â悤ɓľʂ܂B</p>
<span class="PROGRAMLISTING"><pre>
The &lt;write&gt; element is not available!</pre></span>
<p>bZ[W̃tH[}bg͏قȂ܂A HTML t@C̏o͓͂ɂȂ܂B </p>
<!--<?troff .Nd 10?>-->
<p>ŌɁAOracle XML p[T[gpƁANG[vf͂ǂpłȂȂ̂ŁAׂĂ̏o͂ 1 ̃t@Cɏ܂܂B̃R}hŃvZbTĂяo܂B̃R}h 1 słKv܂B</p>
<span class="PROGRAMLISTING"><pre>
java oracle.xml.parser.v2.oraxsl chapterlist.xml 
  elementavailable.xsl chapters.html</pre></span>
<p>R\[o͂Ɏ܂B</p>
<span class="PROGRAMLISTING"><pre>
Message: The &lt;write&gt; element is not available!</pre></span>
<p>o̓t@C <filename>chapters.html</filename> ͎̂ƂłB</p>
<span class="PROGRAMLISTING"><pre>
&lt;html xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect" 
  xmlns:saxon="http://icl.com/saxon"&gt;
   &lt;head&gt;
      &lt;META http-equiv="Content-Type" content="text/html"&gt;
      &lt;title&gt;XSLT&lt;/title&gt;
   &lt;/head&gt;
   &lt;h1&gt;Getting Started&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;The Hello World Example&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;XPath&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;Stylesheet Basics&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;Branching and Control Elements&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;Functions&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;Creating Links and Cross-References&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;Sorting and Grouping Elements&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
   &lt;h1&gt;Combining XML Documents&lt;/h1&gt;
   &lt;p&gt;If this chapter had any text, it would appear here.&lt;/p&gt;
&lt;/html&gt;</pre></span>
<p>̏o͂̕\<link linkend="xslt-appc-c2">} C-2</link> Ɏ܂B</p>
<figure id="xslt-appc-c2" label="C-2">
<p class="TITLE">ׂĂ̏͂̈ꗗ܂܂ꂽ HTML hLg</p>
        <graphic depth="361" width="386" fileref="figs/xslt.ac02.gif"/>
      </figure>
<p>̗ <span class="LITERAL">element-available()</span> ֐gpƁAǂ̂悤ȏ@\pł邩𒲂ׁAǂ̂悤ȗvfɑ΂Ă悤ɂł܂B </p>
</td>
</tr>
</table>
</div>
</body>
</html>
