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

RE: Possible to use attribute value in pattern ??

Subject: RE: Possible to use attribute value in pattern ??
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Fri, 16 Jul 1999 09:59:46 +0100
RE: Possible to use attribute value in pattern ??
> Perhaps, we're wrong, but our understanding of the spec and 
> our experience with SAXON is that a particular source element can only be 
> matched once during the styling process.

No, it can be matched as often as you like.

  Suppose the source document has:
> <book title="All About Foo" author="Dr. Quux"/>
> and I want to place the title in one part of the result tree 
> and the author
> in another.  To do so, I might have
> <xsl:apply-templates select="book[@title]"/>
> in one place, and
> <xsl:apply-templates select="book[@author]"/>
> in the other.  The problem is that both apply-templates 
> "calls" match the
> same
> source element so only one of them gets generated.

Several points here:
- if you want to have one template for each attribute, you can:
<xsl:template match="book/@title">
<xsl:apply-templates select="book/@title">
<xsl:template match="book/@author">
<xsl:apply-templates select="book/@author">

- normally this isn't necessary. Instead of matching the attribute with a
template,
why not just access its value using <xsl:value-of select="book/@title"/> ?

  In addition, the
> template
> rule triggered by these two apply-templates tags cannot 
> distinguish which
> apply-templates "call" triggered the rule, so it doesn't know which
> attribute
> to style (I'm guessing that this can be handled with a variable).

You could distinguish the calls using a parameter, or using modes. But in
this situation, you don't need to: think in terms of processing the
attributes as nodes, not the elements they belong to.

> 
> Am I missing or misunderstanding something?
Yes! Hope the explanation helps.

Mike Kay


 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.