EXSLT - func:function - Use Case 6

Category: example
XML Definition: func.function.xml

This use case tests the effect of element-available() and function-available().

Use Case

Source (view)

<doc>
   <section index="section1"
            index2="atr2val">
      <section index="subSection1.1">
         <p>Hello</p>
         <p>Its me again.</p>
      </section>
   </section>
   <section index="section2">
      <p>Jam</p>
      <section index="subSection2.1">
         <p>Marmalade</p>
         <p>And Honey</p>
      </section>
      <section index="subSection2.2">
         <p>With peanut butter</p>
         <p>On toast</p>
      </section>
      <p>Delicious!</p>
      <section index="subSection2.3">
         <p>Full up now?</p>
         <p>You bet.</p>
      </section>
   </section>
</doc>

Stylesheet (view)

<!--  Test the effect of function-available() and element-available()  -->
<func:function name="f:total">
   <xsl:param name="n1"
              select="0" />
   <xsl:param name="n2"
              select="0" />
   <xsl:param name="n3"
              select="0" />
   <xsl:param name="n4"
              select="0" />
   <xsl:param name="n5"
              select="0" />
   <xsl:param name="n6"
              select="0" />
   <xsl:param name="n7"
              select="0" />
   <func:result select="$n1+$n2+$n3+$n4+$n5+$n6+$n7" />
</func:function>
<xsl:template match="/">
   <out>
;
              <true>
         <xsl:value-of select="function-available('f:total')" />
      </true>
;
              <false>
         <xsl:value-of select="function-available('f:jabberwocky')" />
      </false>
;
              <true>
         <xsl:value-of select="element-available('func:result')" />
      </true>
;
              <false>
         <xsl:value-of select="element-available('func:function')" />
      </false>
;
            <!--  note, this should return false because func:function is not an INSTRUCTION  -->
      <false>
         <xsl:value-of select="element-available('func:jeni-tennison')" />
      </false>
;
      
   </out>
</xsl:template>

Result (view)

<out>
;
           <true>true</true>
;
           <false>false</false>
;
           <true>true</true>
;
           <false>false</false>
;
            
           <false>false</false>
;
      
</out>

Change History

Previous Version: ..NaN.html

VersionModifiedByDetails
12001-04-28Mike Kay

Tests functionality of func:function.

http://www.exslt.org/func/elements/function/func.function.use-case.6.html last modified 2001-04-28