[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Determining the type of attribute within the match

Subject: Re: Determining the type of attribute within the matching template
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sun, 9 Feb 2003 10:03:25 +0000
xslt attribute within
Hi James,

>> In the case above, I think you'd be a lot better off splitting the
>> <xsl:choose> into multiple templates:
>
> The reason that I didn't want to do this is that there is a lot of
> common code before the node-specific code, which I snipped in the
> example I gave. I have moved this into a separate named template
> which is called from each node-specific template, but it would have
> been more aesthetic if I could have used an inline "choose"
> construct.

Have another look at the solution that I suggested:

<xsl:template match="*|@*">
  ...
  <xsl:apply-templates select="." mode="content" />
  ...
</xsl:template>

In this first template, the ...s before and after the
<xsl:apply-templates> are placeholders for common code that you want
to use for all the different element and attribute types. The template
is saying, "the output for elements and attributes is always this
common header/footer, with the main content being determined by
processing the element/attribute in 'content' mode."

The 'content' mode templates do the element/attribute-specific
processing:

<!-- resource types -->
<xsl:template match="@rdf:resource" mode="content">
  ...
</xsl:template>

<!-- datatypes -->
<xsl:template match="@rdf:datatype" mode="content">
  ...
</xsl:template>

while the default mode template does the general processing.

Modes are your friends.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.