Limiting mapping rule activation with except expressions.
A mapping rule can have one or more except expression. The syntax for except expressions in the <mapping> element’s except attribute is identical to match expressions, i.e:
(ancestorElement/)*element([booleanExpr])?
[<whitespace>(ancestorElement/)*element([booleanExpr])?]*
The except expressions are evaluated in order and a mapping rule R fails to match an element E if any of the except expressions in the mapping rule matches element E.
For example, consider the following rule XML file and mapping rule fragments:
<?xml version="1.0"?> <family-tree> <grandparent> ...</grandparent> <grandparent> ...</grandparent> <grandparent> ...</grandparent> <grandparent> ...</grandparent> <parent> <name>Tristan Read</name> <gender>m</gender> <age>40</age> </parent> <parent> <name>Danielle Read</name> <gender>f</gender> <age>43</age> </parent> <child> <name>Grifffen Read</name> <gender>M</gender> <age>12</age> </child> <family-tree>
Then the following mapping rule would match only the children and parents:
<mapping match=”family-tree/*” except=”grandparent”> ...matches all family members except the grandparents </mapping>
This is quite useful when it is easier/briefer to define a match set negatively (everything but ...) rather than positively (the match is a, or b, or c, or d, ...).