Fedor Alexander Steeman
Fedor Alexander Steeman

Reputation: 1561

XSLT: How to pass a node value to a custom xsl:function ?

I have a simple function that I want to pass the value of a node to.

   <xsl:function name="f:getdatetimetype" as="xs:string">
   <xsl:param name="code" as="xs:int"/>
   <xsl:choose>
      <xsl:when test="$code = 137">
          <xsl:text>DocumentMessageDateTime</xsl:text>
      </xsl:when>
      <xsl:otherwise>
         <xsl:text>Unspecified</xsl:text>
      </xsl:otherwise>
  </xsl:choose>
</xsl:function>

How do I do that?

I don't suppose I can do like this:

<xsl:value-of select="f:getdatetimetype(<xsl:value-of select="DTM01/DTM0101"/>)"/>

Upvotes: 1

Views: 2075

Answers (2)

Fedor Alexander Steeman
Fedor Alexander Steeman

Reputation: 1561

Solved it:

<xsl:value-of select="f:getdatetimetype(DTM01/DTM0101/text())"/>

Upvotes: 1

Rubens Farias
Rubens Farias

Reputation: 57926

You should go with

<xsl:value-of select="f:getdatetimetype(DTM01/DTM0101)"/>

Upvotes: 3

Related Questions