[Previous slide] [Next slide] Moving to XML

Beginning XSL-T (vii): Patterns

*
matches any element
foo
matches any element whose type is foo
foo | bar
matches any element whose type is foo or bar
foo/bar
matches any bar element with a foo parent
foo//bar
matches any bar element with a foo ancestor
foo[ @bar='baz']
matches any foo element which has a bar attribute which has the value baz
foo[1]
matches any foo element which is the first foo child of its parent
foo[ position() = 1]
matches any foo element which is the first child of its parent
[ position() < 5]
matches any element which is the first, second, third or fourth child of its parent
text()
matches any text element.

This is just the basics. The full definition is here

 


An older version of this course is available here