XProc/XSLT Pipe

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Motivation[edit | edit source]

You want to run a XSLT transform on a file and the source and XSLT transform are in different files.

XProc[edit | edit source]

<p:pipeline xmlns:p="http://www.w3.org/ns/xproc">
    <p:xslt>
        <!-- Simple XML Source -->
        <p:input port="source">
            <p:document href="source.xml"/>
        </p:input>
        
        <!-- XSLT Transform -->
        <p:input port="stylesheet">
            <p:document href="stylesheet.xsl"/>
        </p:input>
    </p:xslt>
</p:pipeline>


Source[edit | edit source]

<xml>This is an example input xml document</xml>

XSLT Transform[edit | edit source]

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0">
    <xsl:output method="xml" indent="yes" encoding="UTF-8" />
    <!--
        <xsl:output method="xhtml"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-
        transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//
        EN" indent="yes" />
    -->
    <xsl:template match="/xml">
        <html>
            <head>
                <title>XSLT to XHTML via XProc</title>
            </head>
            <body>
                <h1>
                    <xsl:value-of select="." />
                </h1>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

Source Code Link[edit | edit source]

Link to source code: [1]