[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|