EXSLT - func:function - Use Case 3

Category: example
XML Definition: func.function.xml

This use case tests a function definition with an argument.

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 an EXSLT function with arguments  -->
<func:function name="func:initial">
   <xsl:param name="size" />
   <func:result select="substring(.,1,$size)" />
</func:function>
<xsl:template match="text()">
   <xsl:value-of select="func:initial(3)" />
</xsl:template>
<xsl:template match="*">
   <xsl:copy>
      <xsl:apply-templates />
   </xsl:copy>
</xsl:template>

Result (view)

<doc>
   <section>
      <section>
         <p>Hel</p>
         <p>Its</p>
      </section>
   </section>
   <section>
      <p>Jam</p>
      <section>
         <p>Mar</p>
         <p>And</p>
      </section>
      <section>
         <p>Wit</p>
         <p>On </p>
      </section>
      <p>Del</p>
      <section>
         <p>Ful</p>
         <p>You</p>
      </section>
   </section>
</doc>

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.3.html last modified 2001-04-28