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

Re: Newbie: Embedding styles in XML blocks

Subject: Re: Newbie: Embedding styles in XML blocks
From: Brook Ellingwood <brook@xxxxxxxxxxx>
Date: Wed, 24 Sep 2003 10:13:49 -0700
embedding styles
> From: Arne Claassen <xsl@xxxxxxxxxxxx>
> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Date: 24 Sep 2003 09:23:21 -0700
> To: xsl list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Subject:  Newbie: Embedding styles in XML blocks
> 
> I'm relatively new to XSL, trying to ween myself of customer HTML
> templating solutions. There's a fairly simple issue i've run into a
> couple of times, which is embedding simple style controls in a paragraph
> of XML data, such as:
> 
> <para>This is an <i>important</i> paragraph</para>

Just use "copy-of" instead of "value-of" and your tags will be left as
<i></i>.

There is no such thing as text styling in the proper XSL fashion -- whatever
works best for you in your project is what works. If you did want to give
the element in your XSL a name other than the one you want in the HTML
output, you could. For example, this is one way to turn your <i>'s into
<b>'s.

    <xsl:template match="p">
        <xsl:apply-templates select="./node()"/>
    </xsl:template>
    <xsl:template match="i">
        <xsl:element name="b"><xsl:value-of select="."/></xsl:element>
    </xsl:template>

The question I always ask is whether I'm being more efficient by using an
element I define, or by just putting in some HTML. And efficiency isn't
always about streamlined code -- I'm doing a project now where an end user
with no HTML experience will be updating content that may have embedded
links in the text. In my XML, I used a "link" element with a "url"
attribute, because the user understands those terms already. In the code, it
would have been simpler to use "a" and "href" but I thought that would
increase the likelihood of human error, so I created my own element with
clearer terms. Whatever works best for each project...

-- Brook


 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.