[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl: Changing the order of presenation
> 1. I need to give hyperlinks from each page to the figures that > appear in it-- > I do not want to show the picture in line, but want to > give a hyperlink; > The filename of the figure is stored in a tag > that looks > like > <fig>figname</fig> > How do I do this? OK, how's this look: Given: ~~~~~~ <para>This is an image file: <fig>image1.jpg</fig> that we would like to like to link to </para> Then the xsl (excerpt): ~~~~~~~~~~~~~~~~~~~~~~~ <xsl:template match="para"> <p><xsl:apply-templates/></p> </xsl:template> <xsl:template match="fig"> <xsl:variable name="figure"><xsl:value-of select="."/></xsl:variable> <a href="{$figure}"><xsl:apply-templates/></a> </xsl:template> Gives: ~~~~~~ This is an image file: image1.jpg that we would like to like to link to With: ~~~~~ the text: 'image1.jpg' being a hypertext link to the file 'image1.jpg' Some thoughts: ~~~~~~~~~~~~~~ - I'm not sure if there's another way other then using variables, but it seemed the only way to get the value of "fig" into the href attribute. - You can probably: 1) get it so that you have <fig>image1</fig> which produces <a href="image1.jpg"... jpg being hardcoded. or 2) do: <fig type="jpg">image1</fig> But I'm too new to this to figure it out quickly. - Beware: I've only been doing XSL(T) for a week, and have probably messed up some stuff. But this was a good excercise, if only it helped myself! :) The full xsl: ~~~~~~~~~~~~~ <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <html> <head> <title>Image Link</title> </head> <body> <h1>Image Link</h1> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="para"> <p><xsl:apply-templates/></p> </xsl:template> <xsl:template match="fig"> <xsl:variable name="figure"><xsl:value-of select="."/></xsl:variable> <a href="{$figure}"><xsl:apply-templates/></a> </xsl:template> </xsl:stylesheet> Cheers, Brent Kobayashi Technology - High quality computer training, development and support http://www.kobayashi.ca/ MEDUSA creative e-services http://www.medusacreative.com/ 2889A Danforth Ave Toronto, Ontario M4C 1M3 Phone: 416 410-3266 Fax: 416 694-5495 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|