xsl-list
[Top] [All Lists]

RE: [xsl] fallback to a default template in xsl processing

2008-04-24 12:39:31
One approach for this is to use the following:

<xsl:template match="*">
  ...
</xsl:template> 

Jim Earley
XML Architect
Flatirons Solutions Corp.
 


-----Original Message-----
From: Daly, April [mailto:april(_at_)dalyweb(_dot_)com] 
Sent: Thursday, April 24, 2008 1:29 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] fallback to a default template in xsl processing

Hi!

I have what I hope is a simple question for the xsl/xpath gurus!


I would like to be able to apply a default template within xsl 1.0 if no match 
is found.
Currently I'm using an ugly  'brute-force' approach using <xsl:choose>:

<xsl:choose>
   <xsl:when test="name()='A' or name()='B'">
      <xsl:apply-templates mode='namedTemplates' select='.'/>
   </xsl:when>
   <xsl:otherwise>
      <xsl:apply-templates mode='defaultTemplates' select='.'/>
   </xsl:otherwise>
</xsl:choose>


this is a simplfied example, but I hope it shows what I'm trying to do.

Is there a better way to apply a named template if 'found' otherwise apply a 
default
template?

Thanks (in advance) for your help!

April
April L Daly
Daly Web, Inc.

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


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