OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: DOCBOOK-APPS: Re: no wonder i'm confused about the node() function


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

/ Bob Stayton <bobs@sco.com> was heard to say:
| On Sun, Mar 02, 2003 at 03:01:32PM -0500, Robert P. J. Day wrote:
|> 
|> "XSLT", Doug Tidwell, p. 51
|> 
|>   "* The node() node test, which selects all nodes in the current
|>   context, regardless of type.  This includes elements, text, comments
|>   processing instuctions, attributes, and namespace nodes."
|> 
|> "XSLT Programmer's Reference", 2nd ed., Michael Kay, p. 432
|> 
|>   "Since root nodes, attribute nodes and namespace nodes are never
|>   children of another node ... they will never be matched by the
|>   pattern node()."
|> 
|> "http://www.w3.org/TR/xslt"
|> 
|>   "* node() matches any node other than an attribute node and
|>   the root node"
|> 
|> 
|> 
|> at this point, i'm scared to read anything else for the fear
|> of getting a *fourth* opinion.
|
| Ask Norm.  He helped write the XSLT Recommendation.[1]

Heh. Thanks, Bob :-)

With respect to the opinions above, I believe Tidwell is mistaken, Kay
is correct, and the quoted part of the XSLT Rec is needs an erratum to
add "namespace node" to that description of node(). On the other hand,
that quote comes under the heading "here are some examples of
patterns" so maybe it's not normative.

The place to look for information about node() is the XPath Rec which
says "a node test node() is true for any node of any type whatsoever."

But I think part of the confusion in this thread is that there are two
things to consider: the test and the axis in which the test is
performed.

In particular, there's no test that you can write

  <xsl:template match="node()">
                       ^^^^^^
                       here

to match an attribute or namespace node. That's just not the way that
template rules are matched.

Now, if you use node() with other axes, then it matches every kind of
node (though note that most axes don't match namespace or attribute
nodes, so it isn't the case that you get them with node()).

Going all the way back to the original question, should this template

  <xsl:template match="node()">

match comments and processing-instructions?

I can't find any reading of the XSLT Rec that would support the answer no.
In particular, consider:

  "The built-in template rules are treated as if they were imported
  implicitly before the stylesheet and so have lower import precedence
  than all other template rules. Thus, the author can override a
  built-in template rule by including an explicit template rule."

Since import precedence is the primary discriminator for template
matching, I think the test above should match comment and processing
instruction nodes.

So I think it's an xsltproc bug that they don't.

                                        Be seeing you,
                                          norm

- -- 
Norman Walsh <ndw@nwalsh.com>      | Unprovided with original learning,
http://www.oasis-open.org/docbook/ | unformed in the habits of
Chair, DocBook Technical Committee | thinking, unskilled in the arts of
                                   | composition, I resolved to write a
                                   | book.--Edward Gibbon
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.7 <http://mailcrypt.sourceforge.net/>

iD8DBQE+c5O4OyltUcwYWjsRAkurAJ4vIaF5UZi2bhpTN8fmI9uC7yGgmQCeNq7t
DCYpyqXR0ich86S5+uSdGTY=
=ZSqu
-----END PGP SIGNATURE-----




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]