xsl-list
[Top] [All Lists]

Re: Catch ALL | Failed template rule

2005-03-22 14:02:21
Hi Stef,

At 03:20 PM 3/22/2005, you wrote:
Jumping in at the eleventh hour and probably am hugely
wrong here, but, wouldn't the following work ?

<xsl:apply-template select="*[not(foo/bar[(_at_)a='b'])]" 
mode="unmatchedresults"/>


No, this matches an element (*) that does not have a foo child with a bar child with @a='b'.

What you are trying to express would probably be

*[not(self::bar[parent::foo][(_at_)a='b']

which would match any element not itself a bar with a foo parent and an @a='b'.

This would match any node that did not have the foo/bar
entity with an attribute of a that was b. you would (of
course) need to provide some other search criteria such
as name()="corefoo" so that it didn't match elements
you were not interested in.

Yes, exactly.

As a sidenote, I have used the following in my xslt to
match any sub-element that was -not- a prev, next or
alternativenames

<xsl:for-each select="*[not(name()='prev') and not(name()='next') and no
t(name()='alternativenames')]">

Is there any 'cleaner' or 'saner' way to write this ?

Yes, an XPath junkie would probably prefer

*[not(self::prev|self::next|self::alternativenames)]

which will select any child element not itself a prev, next or alternativesnames.

We generally like to leave name testing for the Perl hackers. :->

Cheers,
Wendell

again, apologies if this is not what was asked for,
I am simply trying to offer something that has worked
for me in a somewhat similiar fashion.

Not a problem. The bottom line is, don't think about matching without thinking about selecting. Match is only the Yin to the select's Yang.

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--