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

Re: Apply-templates - how to omit top level element ta

Subject: Re: Apply-templates - how to omit top level element tags?
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Wed, 7 Sep 2005 15:01:59 -0500
jonathan mota
On 9/7/05, Mike Schinkel <mikes@xxxxxxxxx> wrote:
> Thanks.  Question, I use "Name" in many contexts in my XML.  How can I do
this when I don't always want "Name" to be handled that way?
>

Check out modes, have choose statements, or be more selective in your
apply-templates selectiong.  Plenty of ways to do this and it's hard
to tell advise any particular method without knowing more about your
XML.templates and your style.  Lets say you have Name appear in two
places, in a description of the company and when the company is
actually used in some text...

so

<description>
<Name>some name</Name>
more nodes
</description>
<text>
whaaa wawa <Name>some name</Name>
</text>
could have two templates (code not tested)

<xsl:template match="description">
<xsl:apply-templates mode="descript"/>
</xsl:template>

<xsl:template match="text">
<xsl:apply-templates mode="text"/>
</xsl:template>

<xsl:template match="Name" mode="descript">
<h1><xsl:value-of select="." /></h1>
</xsl:template>

<xsl:template match="Name" mode="text">
<span class="name"><xsl:value-of select="." /></span>
</xsl:template>


Jon Gorman

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.