Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 3120

saxon-manual-9.4.0.9-2.mga7.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="xsl-elements" page="patterns" subpage="syntax"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Pattern syntax</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: Pattern syntax"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Pattern syntax</h1>
      <p>Saxon supports the full XSLT syntax for patterns. The rules below describe
a simplified form of this syntax (for example, it omits the legal but useless pattern
'@comment()'):</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>
pattern          ::= path ( '|' path )*
path             ::= anchor? remainder? (Note 1)

anchor           ::= '/' | '//' | id | key
id               ::= 'id' '(' value ')'
key              ::= 'key' '(' literal ',' value ')'
value            ::= literal | variable-reference

remainder        ::= path-part ( sep path-part )* 
sep              ::= '/' | '//'
path-part        ::= node-match predicate+
node-match       ::= kind-match | type-match   
kind-match       ::= element-match | 
                     text-match | 
					 attribute-match | 
					 pi-match | 
					 any-node-match
element-match    ::= 'child::'? ( name | '*' ) 
text-match       ::= 'text' '(' ')' 
attribute-match  ::= ('attribute::' | '@') ( name | '*' ) 
pi-match         ::= 'processing-instruction' '(' literal? ')'
any-node-match   ::= 'node' '(' ')'

type-match       ::= ('element'|'attribute') 
                        '(' ('*'|node-name) (',' type-name) ')'

predicate        ::= '[' ( boolean-expression | 
                           numeric-expression ) ']'
</code>
         </pre>
      </div>
      <p>Note 1: not all combinations are allowed.
 If the anchor is '//' then the remainder is mandatory.</p>
      <p>The form of a literal is as defined in expressions; and a predicate is itself a boolean
 or numeric expression. As with predicates in expressions, a numeric predicate <code>[P]</code> is shorthand
 for the boolean predicate <code>[position()=P]</code>.</p>
      <p>Informally, a pattern consists of either a single path or a sequence of paths separated
 by vertical bars. An element matches the match-pattern if it matches any one of the paths.</p>
      <p>A path consists of a sequence of path-parts separated by either "/" or "//".
 There is an optional separator ("/" or "//") at the start; a "//" has no effect and
 can be ignored. The last path-part may be an element-match, a text-match, an
  attribute-match, a pi-match, or a node-match; in practice, a path-part other than the last
   should be an element-match. </p>
      <p>The axis syntax <code>child::</code> and <code>attribute::</code> may also be used in patterns, as described in the XSLT
specification.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="patterns-30.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>