next up previous contents
Next: Character data the pcdata Up: The standard matchers Previous: The tag+ matcher   Contents


The attr matcher

The attr matcher matches an attribute.

Syntax:

attr name &key how-many possible-values type matches-regexp test-fn $\rightarrow$ matcher

Arguments and Values:

name--One of three things:

  1. A regular expression that will match the name of the attribute. Note that ``^'' and ``$'' are added to the start and end of the regular expression string.
  2. A cons of two regular expressions, both of which have ``^'' and ``$'' added as above, which match each element of the (attribute-name . namespace) cons used by xmls to represent namespaces.
  3. A designator for a function. This is called on the attribute name (which may be a string or a cons, as described above) and returns a boolean representing whether or not the function matches the attribute name.

how-many--a symbol indicating how many times the attribute can match children of its parent tag. One of:

  1. :one--matches one
  2. :one-or-more--matches one or more
  3. :zero-or-more--matches zero or more
  4. :zero-or-one--matches zero or one (an optional matcher, in other words)

possible-values--a list of strings that are all the possible values of the attribute.

type--a type specifier for the type of the attribute's value when it has been read by the Common Lisp reader.

matches-regexp--a regular expression which the attribute's value must match. Note that ``^'' and ``$'' are added to the start and end of the regular expression.

test-fn--a designator for a function that takes the attribute's value as an argument and returns a boolean indicating whether or not the value should be matched. This lets you use the full power of Common Lisp in your sanity checking.

matcher--the matcher object returned.


next up previous contents
Next: Character data the pcdata Up: The standard matchers Previous: The tag+ matcher   Contents
root 2004-10-26