Basic pipelines

Minimal pipeline

Our first pipeline uses the RequestGenerator to output the request attributes in XML.

Sitemap excerpt

<map:match id="requestPipeline" pattern="dump-request">
<map:generate id="12" type="request"/>
<map:serialize type="xml"/>
</map:match>

Typical output

Shown below is the result of a request to dump-request?param=xyz. The response is XML as specified by the serializer, and describes the request attributes and parameters, converted to XML by the RequestGenerator component.

<h:request target="/samples/blocks/tour/pipelines/docs/basic-pipelines.html" sitemap="dump-request" source="">
<h:requestHeaders>
<h:header name="accept"> */* </h:header>
<h:header name="user-agent"> Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) </h:header>
<h:header name="accept-encoding"> gzip, br, zstd, deflate </h:header>
<h:header name="host"> digitalhumanities.org:8081 </h:header>
</h:requestHeaders>
<h:requestParameters>
<h:parameter name="param">
<h:value> xyz </h:value>
</h:parameter>
</h:requestParameters>
<h:configurationParameters/>
<h:remoteUser/>
</h:request>

Converting XML to HTML

Adding a transformer with map:transform and changing the serializer to HTML allows us to generate HTML out of the XML of the previous example.

You can also view the output here: request.html

Sitemap excerpt

<map:match id="requestToHtml" pattern="request.html">
<map:generate type="request"/>
<map:transform src="xsl/request-to-html.xsl"/>
<map:serialize type="html"/>
</map:match>

XSL transformation

<xsl:template name="main" match="/">
<html>
<body>
<h1> Request to host
<xsl:value-of select="//h:header[@name='Host']"/>
</h1>
<h2> Request headers </h2>
<xsl:for-each select="//h:header">
<b>
<xsl:value-of select="@name"/>
</b>
:
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</body>
</html>
</xsl:template>

Typical output

<html>
<body>
<h1> Request to host </h1>
<h2> Request headers </h2>
<b> accept </b>
: */*
<br/>
<b> user-agent </b>
: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
<br/>
<b> accept-encoding </b>
: gzip, br, zstd, deflate
<br/>
<b> host </b>
: digitalhumanities.org:8081
<br/>
</body>
</html>

Adding a touch of style

You can chain several transformers in a pipeline. In this example we add some style to our HTML by adding an additional XSL transform.

View the output in your browser: styled/request.html

Sitemap excerpt

<map:match id="styledHtml" pattern="styled/request.html">
<map:generate type="request"/>
<map:transform src="xsl/request-to-html.xsl"/>
<map:transform src="xsl/html-styling.xsl"/>
<map:serialize type="html"/>
</map:match>

XSL transformation

<xsl:template name="main" match="/">
<html>
<head>
<link rel="stylesheet" href="css/tour.css" type="text/css"/>
<xsl:copy-of select="//head/node()"/>
</head>
<body>
<xsl:copy-of select="//body/node()"/>
<p class="footer"> This footer has been added by html-styling.xsl </p>
</body>
</html>
</xsl:template>

Typical output

<html>
<head>
<link type="text/css" href="css/tour.css" rel="stylesheet"/>
</head>
<body>
<h1> Request to host </h1>
<h2> Request headers </h2>
<b> accept </b>
: */*
<br/>
<b> user-agent </b>
: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
<br/>
<b> accept-encoding </b>
: gzip, br, zstd, deflate
<br/>
<b> host </b>
: digitalhumanities.org:8081
<br/>
<p class="footer"> This footer has been added by html-styling.xsl </p>
</body>
</html>