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

Re: inline troubles

Subject: Re: inline troubles
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 05 Sep 2006 17:18:19 -0400
inline text decoration
Dear Luke,

Use templates.

This is XSLT 101:

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

<xsl:template match="a">
  <fo:inline text-decoration="underline">
    <xsl:apply-templates/>
  </fo:inline>
</xsl:template>

<xsl:template match="d">
  <fo:inline text-decoration="line-through">
    <xsl:apply-templates/>
  </fo:inline>
</xsl:template>

I like to teach beginners never to use xsl:for-each at all unless they have a good reason. Good reasons do not include "I didn't know how to use a template", since to learn XSLT is to learn how to use them. :-)

Cheers,
Wendell

At 05:12 PM 9/5/2006, you wrote:
I'm having some trouble trying to underline and line-through specific
text from my xml.  My xml is formatted like so:

///XML///

<line number=3>
        This is some regular old text, <a> and now I want this
        underlined </a> and then maybe some more regular old text,
        <d>and this to be line-through</d> and finish up with some
        regular text.
</line>

Here is what I currently have in my xsl:

///XSL///
<xsl: for-each select = "line">
        <xsl:value-of select="./@number>
        <xsl:for-each select = "a">
                <fo:inline text-decoration="underline">
                        <xsl:value-of select="."/>
                </fo:inline>
        </xsl:for-each>
        <xsl:for-each select = "d">
                <fo:inline text-decoration="line-through">
                        <xsl:value-of select="."/>
                </fo:inline>
        </xsl:for-each>
</xsl:for-each>

The above xsl however prints the line with both the underline/strike
through section and the non formatted version, giving me repeated lines.
Any ideas on how to properly handle this?

Thanks,
L

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.