Name

cx:wait-for-update — Wait for a document to change.

Synopsis

Output portPrimarySequenceContent types
result✔   
Option nameTypeDefault valueRequired
hrefxs:anyURI ✔ 
pausexs:string'PT1S' 
pause-afterxs:string'0' 
Declaration
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
  |   <p:output port="result"/>
  |   <p:option name="href" as="xs:anyURI" required="true"/>
  |   <p:option name="pause" as="xs:string" select="'PT1S'"/>
5 |   <p:option name="pause-after" as="xs:string" select="'0'"/>
  |</p:declare-step>

Description

The cx:wait-for-update step waits for the document identified by the href option to change. The updated document appars on the result port.

Only file:, http:, and https: URIs are supported.

The pause and pause-after options specify durations. Each duration may be specified as an xs:double, indicating a number of seconds, or as a duration using a string that satisfies the constraints of an xs:dayTimeDuration. The duration must not be negative. It is a dynamic error (err:XD0036) if the specified duration is not a positive number or a valid xs:dayTimeDuration.

The step checks if the document exists, then enters a loop: it waits for a duration equal to pause then checks again if the document has changed.

When the document has changed, it waits for a duration equal to pause-after, then loads the document and returns it on the result port.

Waiting for file updates

If the file exists when the step begins, then the step waits until the last modification time on the file becomes greater than the last modification time it had initially.

If the file does not exist when the step begins, then the step waits until the file exists.

Waiting for http/https updates

The step begins by attempting a HEAD request on the URI. If the head request returns a 200 response, then the step waits until the resource has changed. If the initial request does not return a 200 response, then the step waits until a subsequent request does return a 200 response.

The resource is deemed to have changed if it returns a 200 response and the ETag header value has changed or the last modification time reported is greater than initial last modification time reported.

The last modification time is taken from the Last-Modified header, if it’s present, or the Date header. Note: if no last modification time is returned, the step will only return when the ETag changes. If there’s no ETag either, the step will never return.