Re: [xsl] Newbie: Embedding styles in XML blocks

Subject: Re: [xsl] Newbie: Embedding styles in XML blocks
From: Brook Ellingwood <brook@xxxxxxxxxxx>
Date: Wed, 24 Sep 2003 10:13:49 -0700
> 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: [xsl] 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

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

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

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:

Current Thread