The logo is a pig framed between two angle brackets.

XProc 3.0 Tutorial

What is XProc?

XProc is a declarative programming language with an XML syntax for processing data in pipelines.

  • XProc is based on the concept of pipelines.
  • Pipelines take data as input and generate output data.
  • A pipeline consists of steps which perform various actions on the data.
  • These actions range from reading and writing data, Web requests and complex transformations and validations.
  • XProc is mainly focused on manipulating XML but can handle HTML, JSON, text and binary data as well.

Why should I use XProc?

Many programmers combine XML processing steps such as XSLT transformations, XQuery queries, and schema validations with some form of glue code. Scripting and programming languages ​​are usually used for this, most of them usually offer only poor support for XML. Frequently, the code is not declarative, depends on installed tools and lacks reusability and interoperability. XProc has several advantages over this approach:

  • XProc provides a declarative syntax and a high level of abstraction to write complex pipelines.
  • XProc offers a large step library for checking and manipulating XML data.
  • Build your own step library: Your Proc pipelines can be reused as custom steps in other XProc pipelines.
  • The powerful XML expression and query language XPath is included.
  • Modern XProc processors allow to process pipelines more efficiently with parallel execution and caching

What is this tutorial about?

This tutorial provides an introduction into the fundamentals of XProc 3.0 like pipelines, ports and steps. You learn how to write your own pipelines and set up an XProc processor to execute your pipelines. Advanced programming concepts such as conditionals, iterations, and error handling are covered. Each step of the XProc step library is described and illustrated with code examples to start your journey.

What is this tutorial not?

This tutorial should not be confused with a full-fledged programmer reference. I want to keep the barriers low and not overwhelm readers with all the peculiarities and nuances that are not essential to start coding with XProc 3.0. Speaking of the version number, the tutorial does not touch the not so subtle differences to prior versions. People who used XProc before will notice the changes anyways.

Lessons

  1. Fundamentals
    1. Key Concepts of XProc
    2. The XProc Processor
    3. XProc’s Basic Syntax
    4. Declaring Input and Output Ports
    5. Using and Defining Steps
    6. Working With Documents
  2. XPath in XProc
    1. Selecting Nodes With XPath Expressions
    2. Attribute and Text Value Templates (AVTs and TVTs)
    3. Managing Key/Value Pairs With Maps
    4. XProc’s Extension Functions
  3. Advanced Concepts
    1. Rerouting and Interrupting the Data Flow
    2. Declaring Variables
    3. Grouping With <p:group/>
    4. Conditional Expressions: <p:if/> and <p:choose/>
    5. Iterations: <p:for-each/> and <p:viewport/>
    6. Error Handling With <p:try/>
  4. Frequently Used Steps
    1. Steps for Basic XML Manipulations
  5. Further Reading
    1. More Resources on XProc

Read more…