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

Re: Correct way to handle nested tags

Subject: Re: Correct way to handle nested tags
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 13 Jun 2001 03:36:37 -0700 (PDT)
img styles
Athanasios Gaitatzes wrote:

> > I have the xml:
> > <text>
> >   some text <img src="img1.gif"/>
> >   more text <img src="img2.gif"/>
> >   some more text <img src="img3.gif"/>
> >   end of text
> > </text>
> >
> > How would I generate the html:
> > "some text <img src="img1.gif"> more text <img src="img2.gif"> some
more
> > text <img src="img3.gif"> end of text"
> 
> Sorry about my previous post. I wanted to apply different styles to the
> images so the html should be:
> "some text <img style="some style" src="img1.gif"> more text <img
> style="some style" src="img2.gif"> some more
> text <img style="some style" src="img3.gif"> end of text"

source xml:
----------
<text>
  some text <img src="img1.gif"/>
  more text <img src="img2.gif"/>
  some more text <img src="img3.gif"/>
  end of text
</text>

stylesheet:
----------
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:template match="img">
    <xsl:copy>
      <xsl:attribute name="style">
       <xsl:text>some style</xsl:text>
      </xsl:attribute>
      <xsl:apply-templates select="@*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="img/@*">
    <xsl:copy-of select="."/>
  </xsl:template>
</xsl:stylesheet>


Result:
------

  some text <img style="some style" src="img1.gif">
  more text <img style="some style" src="img2.gif">
  some more text <img style="some style" src="img3.gif">
  end of text



In case you prefer not to use the XSLT default processing, you must have a template
matching "text":

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


Hope this helped.

Cheers,
Dimitre Novatchev.



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

 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.