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

Re: template selection based on attributes

Subject: Re: template selection based on attributes
From: JBryant@xxxxxxxxx
Date: Wed, 29 Dec 2004 09:56:59 -0600
layoutpos
I tested the following, and it works:

<xsl:template match="Page">
  <div class="col01">
    <xsl:apply-templates select="Article[@layoutpos='col01']"/>
  </div>
  <div class="col02">
    <xsl:apply-templates select="Article[@layoutpos='col02']"/>
  </div>
</xsl:template>

By the way, the / in the match of your original doesn't do anything for 
you. At best, your XSL processor will ignore it. At worst, it'll cause an 
error.

Jay Bryant
Bryant Communication Services





"Wong Chin Shin" <publicbbs@xxxxxxxxxxxxxxxx> 
12/29/2004 06:28 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
<xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
cc

Subject
 template selection based on attributes






Hi,

I've got a 2-column page where I want to display articles in. The articles
appear in both columns. Normally, I would create my XML file in this way:
<Page>
<Col1>
<Article></Article>
<Article></Article>
</Col1>
<Col2>
<Article></Article>
<Article></Article>
</Col2>
</Page>

And the XSLT is pretty simple to produce from here.

But I would like to declare all the articles in a single list and then
decide where to put them as an attribute as such:

<Page>
<Article layoutpos="col01"></Article>
<Article layoutpos="col01"></Article>
<Article layoutpos="col02"></Article>
<Article layoutpos="col02"></Article>
</Page>

And then in the XSLT file itself, find some way to iterate through the 
list
and selectively display the articles.

<xsl:template match="/Page">
<div class="col01">
###Call template for Article but filter for col01###
</div>
<div class="col02">
###Call template for Article but filter for col02###
</div>
</xsl:template>

Is there a way to do this?

Thanks!
Wong

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.