index.html 25.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.3.6), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
<title>Document Templating Steps for XProc</title>
<link rel="alternate" title="XML" href="xproc-template.xml" />
<link rel="alternate" title="Latest editor's draft" href=
"http://www.w3.org/XML/XProc/docs/langspec.html" />
<link rel="alternate" title="Latest Public Working Draft" href=
"http://www.w3.org/TR/xproc/" />
<link rel="stylesheet" type="text/css" href=
"http://www.w3.org/StyleSheets/TR/base.css" />
<link rel="stylesheet" type="text/css" href="xproc.css" />
<link rel="stylesheet" type="text/css" href=
"http://www.w3.org/StyleSheets/TR/W3C-WG-NOTE.css" />
</head>
<body>
<div class="specification">
<div class="head" id="spec.head">
<p><a href="http://www.w3.org/"><img height="48" width="72" alt=
"W3C" src="http://www.w3.org/Icons/w3c_home" /></a></p>
<h1>Document Templating Steps for XProc</h1>
<h2>W3C Working Group Note 25 January 2011</h2>
<dl>
<dt>This Version:</dt>
<dd><a href=
"http://www.w3.org/TR/2011/NOTE-xproc-template-20110125/">http://www.w3.org/TR/2011/NOTE-xproc-template-20110125/</a></dd>
<dt>Latest Version:</dt>
<dd><a href=
"http://www.w3.org/TR/xproc-template/">http://www.w3.org/TR/xproc-template/</a></dd>
<dt>Editor:</dt>
<dd><span class="personname">Norman Walsh</span>, <span class=
"orgname">MarkLogic Corporation</span> <tt class=
"email">&lt;<a href=
"mailto:norman.walsh@marklogic.com">norman.walsh@marklogic.com</a>&gt;</tt></dd>
</dl>
<p>This document is also available in these non-normative formats:
<a href="xproc-template.xml">XML</a></p>
<p class="copyright"><a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
© 2011 <a href="http://www.w3.org/"><acronym title=
"World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href=
"http://www.csail.mit.edu/"><acronym title=
"Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
"http://www.ercim.org/"><acronym title=
"European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
W3C <a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a href=
"http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<hr />
<div class="abstract">
<h2>Abstract</h2>
<p>This note describes two new XProc steps designed to make it
easier to construct documents within an XProc pipeline using values
computed by that pipeline.</p>
</div>
<div class="status">
<h2>Status of this Document</h2>
<p><em>This section describes the status of this document at the
time of its publication. Other documents may supersede this
document. A list of current W3C publications and the latest
revision of this technical report can be found in the <a href=
"http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>This is the first publication of this document as a Working
Group Note. This document is a product of the <a href=
"http://www.w3.org/XML/Processing/">XML Processing Model Working
Group</a> as part of the W3C <a href=
"http://www.w3.org/XML/Activity">XML Activity</a>. The English
version of this specification is the only normative version.
However, for translations of this document, see <a href=
"http://www.w3.org/2003/03/Translations/byTechnology?technology=xproc-template">
http://www.w3.org/2003/03/Translations/byTechnology?technology=xproc-template</a>.</p>
<p>This Note defines some additional optional steps for use in
XProc pipelines. The XML Processing Model Working Group expects
that these new steps will be widely implemented and used.</p>
<p>Please report errors in this document to the public mailing list
<a href=
"mailto:public-xml-processing-model-comments@w3.org">public-xml-processing-model-comments@w3.org</a>
(public <a href=
"http://lists.w3.org/Archives/Public/public-xml-processing-model-comments/">
archives</a> are available).</p>
<p>Publication as a Working Group Note does not imply endorsement
by the W3C Membership. This is a draft document and may be updated,
replaced or obsoleted by other documents at any time. It is
inappropriate to cite this document as other than work in
progress.</p>
<p>This document was produced by a group operating under the
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
February 2004 W3C Patent Policy</a>. W3C maintains a <a href=
"http://www.w3.org/2004/01/pp-impl/38398/status">public list of any
patent disclosures</a> made in connection with the deliverables of
the group; that page also includes instructions for disclosing a
patent. An individual who has actual knowledge of a patent which
the individual believes contains <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">
Essential Claim(s)</a> must disclose the information in accordance
with <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">
section 6 of the W3C Patent Policy</a>.</p>
</div>
</div>
<hr />
<div id="spectoc">
<div class="toc">
<h2 id="TableOfContents">Table of Contents</h2>
<dl class="toc">
<dt><span>1&#160;<a href=
"#introduction">Introduction</a></span></dt>
<dt><span>2&#160;<a href="#terminology">Terminology</a></span></dt>
<dt><span class="ext-optional">3&#160;<a href=
"#c.in-scope-names">p:in-scope-names</a></span></dt>
<dt><span class="ext-optional">4&#160;<a href=
"#c.template">p:template</a></span></dt>
</dl>
</div>
<h3><a name="appendices" id="appendices"></a>Appendices</h3>
<div class="toc">
<dl class="toc">
<dt><span>A&#160;<a href="#references">References</a></span></dt>
<dd>
<dl class="toc">
<dt><span>A.1&#160;<a href="#normative-references">Normative
References</a></span></dt>
</dl>
</dd>
<dt><span>B&#160;<a href="#errors-list">List of Error
Codes</a></span></dt>
<dd>
<dl class="toc">
<dt><span>B.1&#160;<a href="#app.step-errors">Step
Errors</a></span></dt>
</dl>
</dd>
</dl>
</div>
</div>
<div class="section">
<h3><a name="introduction" id=
"introduction"></a>1&#160;Introduction</h3>
<p>It's quite common in [<a href="#xproc"><span class=
"abbrev">XProc: An XML Pipeline Language</span></a>] to construct
documents using values computed by the pipeline. This is
particularly (but not exclusively) the case when the pipeline uses
the <tt class="tag-element">p:http-request</tt> step. The input to
<tt class="tag-element">p:http-request</tt> is a <tt class=
"tag-element">c:request</tt> document; attributes on the <tt class=
"tag-element">c:request</tt> element control most of the request
parameters; the body of the document forms the body of request.</p>
<p>A typical example looks like this:</p>
<div class="programlisting">
<pre>
&lt;c:request method="POST" href="http://example.com/post"
           username="user" password="password"&gt;
&lt;c:body&gt;
  &lt;computed-content/&gt;
&lt;/c:body&gt;
&lt;/c:request&gt;
</pre></div>
<p>If we assume that the <tt class="tag-attribute">href</tt> value
and the computed content come from an input document, and the
username and password are options, then a typical pipeline to
compute the request becomes quite complex.</p>
<div class="programlisting">
<pre>
&lt;p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
            xmlns:c="http://www.w3.org/ns/xproc-step"
            name="main" version="1.0"&gt;
&lt;p:option name="username" required="true"/&gt;
&lt;p:option name="password" required="true"/&gt;

&lt;p:identity&gt;
  &lt;p:input port="source"&gt;
    &lt;p:inline&gt;
      &lt;c:request method="POST"/&gt;
    &lt;/p:inline&gt;
  &lt;/p:input&gt;
&lt;/p:identity&gt;

&lt;p:add-attribute match="/c:request" attribute-name="href"&gt;
  &lt;p:with-option name="attribute-value" select="/doc/request/@uri"&gt;
    &lt;p:pipe step="main" port="source"/&gt;
  &lt;/p:with-option&gt;
&lt;/p:add-attribute&gt;

&lt;p:add-attribute match="/c:request" attribute-name="username"&gt;
  &lt;p:with-option name="attribute-value" select="$username"/&gt;
&lt;/p:add-attribute&gt;

&lt;p:add-attribute match="/c:request" attribute-name="password"&gt;
  &lt;p:with-option name="attribute-value" select="$password"/&gt;
&lt;/p:add-attribute&gt;

&lt;p:insert position="first-child" match="/c:request"&gt;
  &lt;p:input port="insertion" select="/doc/request"&gt;
    &lt;p:pipe step="main" port="source"/&gt;
  &lt;/p:input&gt;
&lt;/p:insert&gt;

&lt;p:unwrap match="/c:request/request"/&gt;

&lt;/p:pipeline&gt;
</pre></div>
<p>There's nothing wrong with this pipeline, but it requires
several steps to accomplish with the pipeline author probably
considers a single operation. What's more, the result of these
steps is not immediately obvious on casual inspection.</p>
<p>In order to make this simple construction case both literally
and conceptually simpler, this note introduces two new XProc steps
in the XProc namespace. Support for these steps is optional, but we
strongly encourage implementors to provide them.</p>
<p>The new steps are <a href="#c.in-scope-names"><tt class=
"tag-element">p:in-scope-names</tt></a> and <a href=
"#c.template"><tt class="tag-element">p:template</tt></a>. Taken
together, they greatly simplify the pipeline:</p>
<div class="programlisting">
<pre>
&lt;p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
            xmlns:c="http://www.w3.org/ns/xproc-step"
            name="main" version="1.0"&gt;
&lt;p:option name="username" required="true"/&gt;
&lt;p:option name="password" required="true"/&gt;

&lt;p:in-scope-names name="vars"/&gt;

&lt;p:template&gt;
  &lt;p:input port="template"&gt;
    &lt;p:inline&gt;
      &lt;c:request method="POST" href="{/doc/request/@uri}"
                 username="{$username}" password="{$password}"&gt;
        { /doc/request/node() }
      &lt;/c:request&gt;
    &lt;/p:inline&gt;
  &lt;/p:input&gt;
  &lt;p:input port="source"&gt;
    &lt;p:pipe step="main" port="source"/&gt;
  &lt;/p:input&gt;
  &lt;p:input port="parameters"&gt;
    &lt;p:pipe step="vars" port="result"/&gt;
  &lt;/p:input&gt;
&lt;/p:template&gt;

&lt;/p:pipeline&gt;
</pre></div>
<p>The <a href="#c.in-scope-names"><tt class=
"tag-element">p:in-scope-names</tt></a> step provides all of the
in-scope options and variables in a <tt class=
"tag-element">c:param-set</tt> (this operation is exactly analagous
to what the <tt class="tag-element">p:parameters</tt> step does,
except that it operates on the options and variables instead of on
parameters).</p>
<p>The <a href="#c.template"><tt class=
"tag-element">p:template</tt></a> step searches for XPath
expressions, delimited by curly braces, in a template document and
replaces each with the result of evaluating the expression. All of
the parameters passed to the <a href="#c.template"><tt class=
"tag-element">p:template</tt></a> step are available as in-scope
variable names when evaluating each XPath expression.</p>
<p>Where the expressions occur in attribute values, their string
value is used. Where they appear in text content, their node values
are used.</p>
</div>
<div class="section">
<h3><a name="terminology" id=
"terminology"></a>2&#160;Terminology</h3>
<p>In this note the words <span class="rfc2119">must</span>,
<span class="rfc2119">must not</span>, <span class=
"rfc2119">should</span>, <span class="rfc2119">should not</span>,
<span class="rfc2119">may</span> and <span class=
"rfc2119">recommended</span> are to be interpreted as described in
[<a href="#rfc2119"><span class="abbrev">RFC 2119</span></a>].</p>
</div>
<div class="section">
<h3><a name="c.in-scope-names" id=
"c.in-scope-names"></a>3&#160;p:in-scope-names</h3>
<p>The <tt class="code">p:in-scope-names</tt> step exposes all of
the in-scope variables and options as a set of parameters in a
<tt class="tag-element">c:param-set</tt> document.</p>
<p class="element-syntax element-syntax-declare-step-opt">
<span class="decl"><code>&lt;p:declare-step</code> <code class=
"attr type-attr">type</code><code>="</code><code class=
"value type-value">p:in-scope-names</code><code>"</code><code>&gt;</code></span><br />

&#160;&#160;&#160;&#160;&#160;<span class=
"input"><code>&lt;p:output</code> <code class=
"attr port-attr">port</code><code>="</code><code class=
"value port-value">result</code><code>"</code> <code class=
"attr primary-attr">primary</code><code>="</code><code class=
"value primary-value">false</code><code>"</code><code>/&gt;</code></span><br />

<code>&lt;/p:declare-step&gt;</code></p>
<p>Each in-scope variable and option is converted into a <tt class=
"tag-element">c:param</tt> element. The resulting <tt class=
"tag-element">c:param</tt> elements are wrapped in a <tt class=
"tag-element">c:param-set</tt> and the parameter set document is
written to the <tt class="port">result</tt> port. <a name="impl-1"
id="impl-1"></a>The order in which <tt class=
"tag-element">c:param</tt> elements occur in the <tt class=
"tag-element">c:param-set</tt> is <em class=
"glossterm">implementation-dependent</em>.</p>
<p>For consistency and user convenience, if any of the variables or
options have names that are in a namespace, the <tt class=
"tag-attribute">namespace</tt> attribute on the <tt class=
"tag-element">c:param</tt> element <span class=
"rfc2119">must</span> be used. Each <tt class=
"tag-attribute">name</tt> <span class="rfc2119">must</span> be an
NCName.</p>
<p>The base URI of the output document is the URI of the pipeline
document that contains the step.</p>
<p>For consistency with the <tt class=
"tag-element">p:parameters</tt> step, the <tt class=
"port">result</tt> port is not primary.</p>
<div class="section">
<h4><a name="ex-in-scope-names" id=
"ex-in-scope-names"></a>3.1&#160;Example</h4>
<p>This unlikely pipeline demonstrates the behavior of <a href=
"#c.in-scope-names"><tt class=
"tag-element">p:in-scope-names</tt></a>:</p>
<div class="programlisting">
<pre>
&lt;p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                name="main" version="1.0"&gt;
&lt;p:output port="result"&gt;
  &lt;p:pipe step="vars" port="result"/&gt;
&lt;/p:output&gt;

&lt;p:option name="username" required="true"/&gt;
&lt;p:option name="password" required="true"/&gt;
&lt;p:variable name="host" select="'http://example.com/'"/&gt;

&lt;p:in-scope-names name="vars"/&gt;

&lt;/p:declare-step&gt;
</pre></div>
<p>Assuming the values supplied for the username and password
options are “<tt class="literal">user</tt>” and “<tt class=
"literal">pass</tt>”, respectively, the output would be:</p>
<div class="programlisting">
<pre>
&lt;c:param-set xmlns:c="http://www.w3.org/ns/xproc-step"&gt;
  &lt;c:param name="username" namespace="" value="user"/&gt;
  &lt;c:param name="host" namespace="" value="http://example.com/"/&gt;
  &lt;c:param name="password" namespace="" value="pass"/&gt;
&lt;/c:param-set&gt;
</pre></div>
</div>
</div>
<div class="section">
<h3><a name="c.template" id="c.template"></a>4&#160;p:template</h3>
<p>The <tt class="code">p:template</tt> replaces each XPath
expression, delimited with curly braces, in the <tt class=
"port">template</tt> document with the result of evaluating that
expression.</p>
<p class="element-syntax element-syntax-declare-step-opt">
<span class="decl"><code>&lt;p:declare-step</code> <code class=
"attr type-attr">type</code><code>="</code><code class=
"value type-value">p:template</code><code>"</code><code>&gt;</code></span><br />

&#160;&#160;&#160;&#160;&#160;<span class=
"input"><code>&lt;p:input</code> <code class=
"attr port-attr">port</code><code>="</code><code class=
"value port-value">template</code><code>"</code><code>/&gt;</code></span><br />

&#160;&#160;&#160;&#160;&#160;<span class=
"input"><code>&lt;p:input</code> <code class=
"attr port-attr">port</code><code>="</code><code class=
"value port-value">source</code><code>"</code> <code class=
"attr sequence-attr">sequence</code><code>="</code><code class=
"value sequence-value">true</code><code>"</code> <code class=
"attr primary-attr">primary</code><code>="</code><code class=
"value primary-value">true</code><code>"</code><code>/&gt;</code></span><br />

&#160;&#160;&#160;&#160;&#160;<span class=
"input"><code>&lt;p:input</code> <code class=
"attr port-attr">port</code><code>="</code><code class=
"value port-value">parameters</code><code>"</code> <code class=
"attr kind-attr">kind</code><code>="</code><code class=
"value kind-value">parameter</code><code>"</code><code>/&gt;</code></span><br />

&#160;&#160;&#160;&#160;&#160;<span class=
"input"><code>&lt;p:output</code> <code class=
"attr port-attr">port</code><code>="</code><code class=
"value port-value">result</code><code>"</code><code>/&gt;</code></span><br />

<code>&lt;/p:declare-step&gt;</code></p>
<p>While evaluating each expression, the names of any parameters
passed to the step are available as variable values in the XPath
dynamic context.</p>
<p>The step searches for XPath expressions in attribute values,
text content (adjacent text nodes, if they occur in the data model,
must be coalesced; this step always processes maximal length text
nodes), processing instruction data, and comments. XPath
expressions are identified by curly braces, similar to attribute
value templates in XSLT or enclosed expressions in XQuery.</p>
<p>In order to allow curly braces to appear literally in content,
they can be escaped by doubling them. In other words, where
<tt class="code">{</tt>” would start an XPath expression,
<tt class="code">{{</tt>” is simply a <em>single</em>, literal
opening curly brace. The same applies for closing curly braces.</p>
<p>Inside an XPath expression, strings quoted by single (<tt class=
"code">'</tt>) or double (<tt class="code">"</tt>) quotes are
treated literally. Outside of quoted text, it is an error for an
opening curly brace to occur. A closing curly brace ends the XPath
expression (whether or not it is followed immediately by another
closing curly brace).</p>
<p>These parsing rules can be described by the following algorithm,
though implementations are by no means required to implement the
parsing in exactly this way, provided that they achieve the same
results.</p>
<div class="itemizedlist">
<ul>
<li>
<p>The parser begins in <em>regular-mode</em> at the start of each
unit of content where expansion may occur. In
<em>regular-mode</em>:</p>
<div class="orderedlist">
<ol style="list-style: decimal;">
<li>
<p><tt class="code">{{</tt>” is replaced by a single “<tt class=
"code">{</tt>”.</p>
</li>
<li>
<p><tt class="code">}}</tt>” is replaced by a single “<tt class=
"code">}</tt>”.</p>
<p>Note: <a name="err.inline.C0067" id="err.inline.C0067"></a>It is
a <em class="glossterm">dynamic error</em>&#160;(<a href=
"#err.C0067"><code class="errqname">err:XC0067</code></a>) to
encounter a single closing curly brace “<tt class="code">}</tt>
that is not immediately followed by another closing curly
brace.</p>
</li>
<li>
<p>A single opening curly brace “<tt class="code">{</tt>” (not
immediately followed by another opening curly brace) is discarded
and the parser moves into <em>xpath-mode</em>. The inital
expression is empty.</p>
</li>
<li>
<p>All other characters are copied without change.</p>
</li>
</ol>
</div>
</li>
<li>
<p>In <em>xpath-mode</em>:</p>
<div class="orderedlist">
<ol style="list-style: decimal;">
<li>
<p><a name="err.inline.C0067.1" id="err.inline.C0067.1"></a>It is a
<em class="glossterm">dynamic error</em>&#160;(<a href=
"#err.C0067"><code class="errqname">err:XC0067</code></a>) to
encounter an opening curly brace “<tt class="code">{</tt>”.</p>
</li>
<li>
<p>A closing curly brace “<tt class="code">}</tt>” is discarded and
ends the expression. The expression is evaluated and the result of
that evaluation is copied to the output. The parser returns to
<em>regular-mode</em>.</p>
<p>Note: Braces cannot be escaped by doubling them in
<em>xpath-mode</em>.</p>
</li>
<li>
<p>A single quote (<tt class="code">'</tt>) is added to the current
expression and the parser moves to <em>single-quote-mode</em>.</p>
</li>
<li>
<p>A double quote (<tt class="code">"</tt>) is added to the current
expression and the parser moves to <em>double-quote-mode</em>.</p>
</li>
<li>
<p>All other characters are appended to the current expression.</p>
</li>
</ol>
</div>
</li>
<li>
<p>In <em>single-quote-mode</em>:</p>
<div class="orderedlist">
<ol style="list-style: decimal;">
<li>
<p>A single quote (<tt class="code">'</tt>) is added to the current
expression and the parser moves to <em>xpath-mode</em>.</p>
</li>
<li>
<p>All other characters are appended to the current expression.</p>
</li>
</ol>
</div>
</li>
<li>
<p>In <em>double-quote-mode</em>:</p>
<div class="orderedlist">
<ol style="list-style: decimal;">
<li>
<p>A double quote (<tt class="code">"</tt>) is added to the current
expression and the parser moves to <em>xpath-mode</em>.</p>
</li>
<li>
<p>All other characters are appended to the current expression.</p>
</li>
</ol>
</div>
</li>
</ul>
</div>
<p><a name="err.inline.C0067.2" id="err.inline.C0067.2"></a>It is a
<em class="glossterm">dynamic error</em>&#160;(<a href=
"#err.C0067"><code class="errqname">err:XC0067</code></a>) if the
parser reaches the end of the unit of content and it is not in
<em>regular-mode</em>.</p>
<p>The context node used for each expression is the document passed
on the <tt class="port">source</tt> port. <a name=
"err.inline.C0068" id="err.inline.C0068"></a>It is a <em class=
"glossterm">dynamic error</em>&#160;(<a href=
"#err.C0068"><code class="errqname">err:XC0068</code></a>) if more
than one document appears on the <tt class="port">source</tt> port.
In an XPath 1.0 implementation, if <tt class=
"tag-element">p:empty</tt> is given or implied on the <tt class=
"port">source</tt> port, an empty document node is used as the
context node. In an XPath 2.0 implementation, the context item is
undefined. <a name="err.inline.C0026" id="err.inline.C0026"></a>It
is a <em class="glossterm">dynamic error</em>&#160;(<a href=
"#err.C0026"><code class="errqname">err:XC0026</code></a>) if any
XPath expression makes reference to the context node, size, or
position when the context item is undefined.</p>
<p>In an attribute value, processing instruction, or comment, the
string value of the XPath expression is used. In text content, an
expression that selects nodes will cause those nodes to be copied
into the template document.</p>
<div class="admonition">
<div class="admon-title">Note</div>
<p>Depending on which version of XPath an implementation supports,
and possibly on the <tt class="tag-attribute">xpath-version</tt>
setting on the <tt class="tag-element">p:template</tt>, some
implementations may report errors, or different results, than other
implementations in those cases where the interpretation of an XPath
expression differs between the versions of XPath.</p>
</div>
<p>An example of <tt class="tag-element">p:document</tt> appears in
<a href="#introduction" title="Introduction">Section&#160;1,
“Introduction”</a>.</p>
</div>
<div class="appendix">
<h2><a name="references" id="references"></a>A&#160;References</h2>
<div class="section">
<h3><a name="normative-references" id=
"normative-references"></a>A.1&#160;Normative References</h3>
<div class="bibliolist">
<div class="bibliomixed" id="rfc2119">
<p>[<span class="abbrev">RFC 2119</span>] <a href=
"http://www.ietf.org/rfc/rfc2119.txt"><span class=
"citetitle"><cite>Key words for use in RFCs to Indicate Requirement
Levels</cite></span></a>. S. Bradner. Network Working Group, IETF,
Mar 1997.</p>
</div>
<div class="bibliomixed" id="xproc">
<p>[<span class="abbrev">XProc: An XML Pipeline Language</span>]
<a href="http://www.w3.org/TR/xproc/"><span class=
"citetitle"><cite>XML: An XML Pipeline Language</cite></span></a>.
Norman Walsh, Alex Milowski, and Henry S. Thompson, editors. W3C
Recommedation 11 May 2010.</p>
</div>
</div>
</div>
</div>
<div class="appendix">
<h2><a name="errors-list" id="errors-list"></a>B&#160;List of Error
Codes</h2>
<div class="section">
<h3><a name="app.step-errors" id=
"app.step-errors"></a>B.1&#160;Step Errors</h3>
<p>The following <em class="glossterm">dynamic errors</em> are
explicitly called out in this note.</p>
<div id="step-error-summary">
<h5>Step Errors</h5>
<dl class="errs">
<dt><a name="err.C0026" id="err.C0026"></a><code class=
"errqname">err:XC0026</code></dt>
<dd>
<p>It is a dynamic error if any XPath expression makes reference to
the context node, size, or position when the context item is
undefined.</p>
<p>See: <a href="#err.inline.C0026">p:template</a></p>
</dd>
<dt><a name="err.C0067" id="err.C0067"></a><code class=
"errqname">err:XC0067</code></dt>
<dd>
<p>It is a dynamic error to encounter a single closing curly brace
“}” that is not immediately followed by another closing curly
brace.</p>
<p>See: <a href="#err.inline.C0067">p:template</a>, <a href=
"#err.inline.C0067.1">p:template</a>, <a href=
"#err.inline.C0067.2">p:template</a></p>
</dd>
<dt><a name="err.C0068" id="err.C0068"></a><code class=
"errqname">err:XC0068</code></dt>
<dd>
<p>It is a dynamic error if more than one document appears on the
source port.</p>
<p>See: <a href="#err.inline.C0068">p:template</a></p>
</dd>
</dl>
</div>
<p>Other errors may also arise, see [<a href="#xproc"><span class=
"abbrev">XProc: An XML Pipeline Language</span></a>] for a complete
discussion of error codes.</p>
</div>
</div>
</div>
</body>
</html>