Re: [xsl] The identity transform and attributes
Subject: Re: [xsl] The identity transform and attributes|
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 21 Jan 2008 19:01:11 +0100
David Carlisle wrote:
select="child::foo selects the parent of the current node,
match="child::foo" asks if that node is the child of anything.
So unless you find it surprising that something can both have a parent
and be a parent, I'm not sure what is surprising here?
I think Andrew meant that many people start out writing their select
statements equal to their matching patterns. And it takes many people a
long time (unless when going to a good class or reading a good
introductory book) to find out that it is not necessary to have each
select statement matched with a pattern:
<xsl:apply-templates select="books" />
<h1>a lot of books</h1>
<xsl:apply-templates select="book" />
<xsl:template match="book".... etc
If you change that picture to something along the lines of
match="child::book" and select="parent::book" people get confused
(especially to why it isn't working the way they expect it).
Don't get me wrong, this can be a very legitimate approach, but many
people don't know what happens when they have to take out or add one
layer of parents or children and how it affects the current templates,
resulting in trial and error, resulting in weird incomprehensible code.
But we've all been beginners and once someone points us to the right
course or book, we all learn it well (I hope) + 10 years on the XSL-List ;)
-- Abel Braaksma