XProc steps

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

p:wrap-sequence

<p:declare-step type="p:wrap-sequence">
   <p:input port="source" sequence="true"/>
   <p:output port="result" sequence="true"/>
   <p:option name="wrapper" required="true"/> <!-- QName -->
   <p:option name="wrapper-prefix"/> <!-- NCName -->
   <p:option name="wrapper-namespace"/> <!-- anyURI -->
   <p:option name="group-adjacent"/> <!-- XPathExpression -->
</p:declare-step>

With the help of the <p:wrap-sequence> step, documents can be enclosed with a new element. Whereas <p:wrap> can be specifically used in the document by appropriate XSLT expressions, <p:wrap-sequence> always encloses the complete document with the new wrapper element. As the name of the “wrap-sequence“ step implies, several sequences (normally documents) can be processed with this step. The name of the new wrapper is indicated in the “wrapper“ option. In addition, a further namespace and prefix can be assigned to this element by the options “wrapper-prefix“ and “wrapper-namespace“. With the help of the  “group-adjacent“ option can be determined that elements which are directly adjecent and match with the XPath expression required by the option will be grouped into the new wrapper element. The documents to be processed are loaded at the input port (“source“). The result is written on the output port (“result“).

Example

In the example the known example document (“FilmCollection“) is provided with a wrapper.

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
   <p:input port="source">
      <p:document href="FilmCollection.xml"/>
   </p:input>
   <p:output port="result"/>
   <p:wrap-sequence wrapper="VideoLibrary"/>
</p:declare-step>
 

The new wrapper in the example is called “VideoLibrary“. The result of this process would be as follows (excerpt):

<VideoLibrary>
   <FilmCollection>
      <Film>
         <Title>Star Wars: Episode IV - A New Hope</Title>
         <Year>1978</Year>
[...]