xsl-list
[Top] [All Lists]

RE: Apply-templates - how to omit top level element tags?

2005-09-07 16:07:34
Jay Bryant>> How do you want it to be handled? For that matter, what do
you mean by "handled"? 

By handled, I mean that sometimes "Name" would have <h1></h1> around it,
and other times it be output a different way, i.e. with <a
href="..."></a> around it.  And I use "Name" in various parts of my XML
in different contexts.

Jay Bryant>> Do you dislike the apply and match scheme (XSLT's native
idiom) 

Good question. Honestly I don't think I currently think that way so I
don't know (such as an English speaker has to translate from German to
be able to understand, whereas a fluent German speaker "thinks" in
German.)  It seems fraught with side-effects, however, and it seems hard
to verify that output is "correct" when using that idiom.

Jay Bryant>> you mean that you don't always want it be inserted into an
h1 element?

Yes, that is the case.

Jay Bryant>> Generally, on this list, we can help if you tell us the
input you have and the output you want. So what do you want for output?

I provided that in detail in a prior email.  I will copy that for you
here (or was this not the detail you'd need?):

======================
======================
======================
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="myns:TrademarkSymbol" name="myns: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(_at_)howtoselectguides(_dot_)com
404-591-5701 (V)
404-591-5731 (F) 
======================
======================
======================



-----Original Message-----
From: JBryant(_at_)s-s-t(_dot_)com [mailto:JBryant(_at_)s-s-t(_dot_)com] 
Sent: Wednesday, September 07, 2005 4:04 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] 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?

How do you want it to be handled? For that matter, what do you mean by
"handled"? Do you dislike the apply and match scheme (XSLT's native
idiom) or do you mean that you don't always want it be inserted into an
h1 element?

Generally, on this list, we can help if you tell us the input you have
and the output you want. So what do you want for output?

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

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



<Prev in Thread] Current Thread [Next in Thread>