[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: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 8 Sep 2005 14:06:52 +0100
RE:  Apply-templates - how to omit top level element ta
<xsl:template match="Product/Name">...</xsl:template>
<xsl:template match="Customer/Name">...</xsl:template>

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Mike Schinkel [mailto:mikes@xxxxxxxxx]
> Sent: 07 September 2005 20:50
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Apply-templates - how to omit top level
> element tags?
>
> 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?
>
> -Mike
>
> -----Original Message-----
> From: Antsnio Mota [mailto:amsmota@xxxxxxxxx]
> Sent: Wednesday, September 07, 2005 3:44 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Apply-templates - how to omit top level
> element tags?
>
> You should use
> <h1><xsl:apply-templates select="Name"/></h1>
>
> and then a  template for Name
>
> <xsl:template match="Name">
>   <xsl:value-of select="."/>
> </xsl:template>
>
> or better
>
> <xsl:apply-templates select="Name"/>
> <xsl:template match="Name">
>    <h1>
>       <xsl:value-of select="."/>
>    </h1>
> </xsl:template>
>
>
>
> On 9/7/05, Mike Schinkel <mikes@xxxxxxxxx> wrote:
> > To all:
> >
> > I'm trying to figure out how to use <xsl:apply-templates>
> (or anything
> > else) to get the right output:
> >
> > I've got an XML file and am generated XHTML.
> >
> > In my XSL file, I have the following variable and template:
> >
> > ==========================================
> > <xsl:variable name="trademark-symbol">&#8482;</xsl:variable>
> > <xsl:template match="htsg:TrademarkSymbol"
> name="htsg:TrademarkSymbol">
> >         <xsl:value-of select="$trademark-symbol"/> </xsl:template>
> > ==========================================
> >
> > In my XML file, I have a fragment that looks like this:
> >
> > ==========================================
> > <Name>This is the Title of the
> > Publication<myns:TrademarkSymbol/></Name>
> > ==========================================
> >
> > I want to generate output that looks like this:
> >
> > ==========================================
> > <h1>This is the Title of the Publication(tm)</h1>
> > ==========================================
> >
> > However, if I use this in my XSL:
> >
> > ==========================================
> > <h1><xsl:apply-templates select="Name"/></h1>
> > ==========================================
> >
> > I get the following that includes the <Name> element:
> >
> > ==========================================
> > <h1><Name>This is the Title of the Publication(tm)</Name></h1>
> > ==========================================
> >
> > When I try instead to use this:
> >
> > ==========================================
> > <h1><xsl:value-of select="Name/text()"/></h1>
> > ==========================================
> >
> > I just get this w/o the trademark:
> >
> > ==========================================
> > <h1>This is the Title of the Publication</h1>
> > ==========================================
> >
> > Again, this is what I want to generate as output:
> >
> > ==========================================
> > <h1>This is the Title of the Publication(tm)</h1>
> > ==========================================
> >
> >
> > I look forward and appreciate any suggestions, even those
> that might
> > have be taking a completely different route, but I also
> really want to
> > understand how to accomplish this using apply-templates or
> value-of or
> > whatever.
> >
> > Thanks in advance for your help.
> >
> > -Mike Schinkel
> > Publisher - How-To-Select(tm) Guides
> > http://www.howtoselectguides.com/
> > mailto:mikes@xxxxxxxxxxxxxxxxxxxxx
> > 404-591-5701 (V)
> > 404-591-5731 (F)

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.