xsl-list
[Top] [All Lists]

Re: [xsl] Custom function in template match predicate

2008-09-23 13:40:29
Ian Stokes-Rees wrote:

  Hi

  <xsl:function name="my:test">
    <xsl:param name="fmtcode"/>
    <xsl:param name="context"/>
    <xsl:choose>
      <xsl:when test="substring-after($context/@format,':') =
$fmtcode and

namespace-uri-for-prefix(substring-before($context/@format,':'),$context)
        = 'http://example.com/schemas/formats' ">
        <xsl:value-of select="boolean(1)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="boolean(0)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:function>

  I would use instead:

    <xsl:function name="my:test" as="xs:boolean">
       <xsl:param name="fmtcode" as="xs:string"/>
       <xsl:param name="context" as="element()"/>
       <xsl:sequence select="[ content of your when/@test ]"/>
    </xsl:function>

  Anyway, I would rather use resolve-QName() directly.

  PS: It is a good thing to include any error message you get when
posting.

  Regards,

--drkm























      

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--