xsl-list
[Top] [All Lists]

[xsl] dynamic-context type-branching

2008-02-03 12:36:35
Hi,

In schema unaware xslt2 environments, what would be the best way to select action depending on the result type (ex: string, text node(s), attribute(s), element(s)) of saxon:evaluate(), ex:

idealy (v1) something like ...
   <xsl:template match="context" mode="foo">
       <xsl:param name="xpathstring" select="... some xpath string ... "/>
<xsl:apply-templates select="saxon:eval(saxon:evaluate($xpathstring)" mode="lama"/>
   </xsl:template>

but since you cannot apply-templates on atomic types, alternately (v2) ...
   <xsl:template match="context" mode="foo">
       <xsl:param name="xpathstring" select="... some xpath string ... "/>
<xsl:variable name="tmp" select="saxon:eval(saxon:evaluate($xpathstring)"/>
       <xsl:choose>
<xsl:when test="$tmp instance of xs:anyAtomicType"><xsl:value-of select="$tmp"/></xsl:when> <xsl:otherwise><xsl:apply-templates select="$tmp" mode="lama"/></xsl:otherwise>
       </xsl:choose>
   </xsl:template>

Assuming mode="lama" has templates with appropriate matches for the different types.

Thanks,
ac


--~------------------------------------------------------------------
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>
--~--