XSLT Match Pattern Examples

XSLT match pattern allows you to do very specific or narrow searches. For example, you may search for certain text in certain attributes in certain elements. For the complete syntax of XSLT match pattern, please refer to XSLT Standard V1.0.

Note:

XSLT match pattern matches only against elements with specific content (and never text or attributes).

Here are several examples of XSLT match patterns:

Find All XML Comments

comment()

In colspec Elements find attribute containing colwidth

colspec[@colwidth]

Find all elements with attribute url that is equal to mypic.gif

*[@url="mypic.gif"]

In colspec Elements find attribute containing colwidth that equals "3pt"

colspec[@colwidth="3pt"]

Find title elements that are children of section elements

section/title

In row elements find second element entry that has attribute align equal to left

row/entry[2][@align="left"]

Find sup elements with text literal equal to "x"

sup/text()[string()="x"]