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

Re: Stupid newbie question..

Subject: Re: Stupid newbie question..
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 18 Oct 2002 13:30:47 -0600 (MDT)
Re:  Stupid newbie question..
Jordan S. Jones wrote:
> I am trying to call a template based off of the value of an attribute..  I
> am probably going about it in a dumb manner..
> 
> Here is my xml:
> 
> <?xml version="1.0" ?>
> <document>
>  <description>Test number one</description>
>  <content>
>   <module id="one">
>    <paragraph>
>     <media type="img">image.jpg</media>
>     <title>This is the title</title>
>     blah blah blah blah blah blah blah blah blah.
>    </paragraph>
>   </module>
>  </content>
> </document>
> 
> 
> Here is the xslt:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  <xsl:output method = "html" encoding="Windows-1252" />
> 
>  <xsl:template match="/">
>   <html>
>    <xsl:if test="document/description">
>     <title><xsl:value-of select="document/description" /></title>
>    </xsl:if>
>    <body>
>    <xsl:if test="document/content">
>     <xsl:apply-templates select="document/content" />
>    </xsl:if>
>    </body>
>   </html>
>  </xsl:template>
> 
>  <xsl:template match="document/content">
>   <xsl:apply-templates />
>  </xsl:template>

So far, so good. You could just say match="content" unless you've
got some other 'content' elements that you need to process differently.

>  <xsl:template match="module">
>   <xsl:apply-templates select="@id" />
>  </xsl:template>
> 
>  <xsl:template match="one">
>   This is module one.
>  </xsl:template>

You meant (in place of both of these)

<xsl:template match="module[@id='one']">
  <xsl:text>This is module one.</xsl:text>
</xsl:template>

The xsl:text element is just there to keep the whitespace around the text from
being considered part of the text.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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.