xsl-list
[Top] [All Lists]

Re: how to test for the element type of the current node

2003-07-02 09:53:06

  I didn't know how to select "non-B children of A", now I know that you can 
use 
  match="A/*[not(self::B)]"  (true?)

you can do that but it looks horrible and the normal style is, as I said
to have two templates
 match="A/B" priority="2"
 match="A/*" priority="1"

you don't need to guard the * as the A/B template has higher priority
(That is why templates have a priority, to save you getting the logic
right to make sure all matches are mutually exclusive)

  In fact, using such a template would be required because xsl:template is 
  not scoped and can only occur at the top level, so I can't put one
  inside the xsl:template for A.

I don't know what you would want a template inside a template to mean
(there were several suggestions in early drafts of xslt) so I can't
really comment on this.

  This, btw, appears bad style: you're adding top-level elements
  to your XSL that really only have a meaning inside a subtree
  of your input DOM. 

That is normal XSLT style.

If you have a template  match="td" then that is also probably only
applicable inside a tr element, having match="tr/td" just makes that
explict and is arguably better style.

(Maybe it's a design limitation of XSLT?)

Its not a limitation, it's the basic style of XSLT programming (whether
you _like_ that style is personal choice of course)
the template model is that it is the source that drives the processing
not the stylesheet, so if you have a template match="a" that applies all
over the place wherever there is an <a> in the source.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list