nw-xslt-001

Tests a simple XSLT transformation.

Test nw-xslt-001.xml is expected to pass.

It requires the following features: xslt-2.

The pipeline


<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="main" version="3.0">
  <p:output port="result"/>

  
  <p:xslt>
    <p:with-input port="source">
<document xmlns="">
<title>Some Title</title>
<para>Some paragraph.</para>
</document>
    </p:with-input>
    <p:with-input port="stylesheet">

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xs" version="2.0">

<xsl:output xmlns:xsl="http://www.w3.org/1999/XSL/Transform" method="xml" encoding="utf-8" omit-xml-declaration="yes"/>

<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" match="document">
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    <head xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <title xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:value-of xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="title"/></title>
    </head>
    <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:apply-templates xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
    </body>
  </html>
</xsl:template>

<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" match="document/title">
  <h1 xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    <xsl:apply-templates xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
  </h1>
</xsl:template>

<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" match="para">
  <p xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    <xsl:apply-templates xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
  </p>
</xsl:template>

<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" match="element()">
  <xsl:copy xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="@*,node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" match="attribute()|text()|comment()|processing-instruction()">
  <xsl:copy xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
</xsl:template>

</xsl:stylesheet>
    </p:with-input>
  </p:xslt>

</p:declare-step>
  
MorganaXProc passing XML Calabash passing

Schematron validation


    <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:ns prefix="h" uri="http://www.w3.org/1999/xhtml"/>
      <s:pattern>
        <s:rule context="/">
          <s:assert test="h:html">The pipeline root is not “html”.</s:assert>
        </s:rule>
        <s:rule context="h:html">
          <s:assert test="h:head">There’s no “head” element.</s:assert>
          <s:assert test="h:body">There’s no “body” element.</s:assert>
        </s:rule>
        <s:rule context="h:head">
          <s:assert test="h:title">There’s no “title” element.</s:assert>
          <s:assert test="h:title[. = 'Some Title']">The title is wrong.</s:assert>
        </s:rule>
        <s:rule context="h:body">
          <s:assert test="h:h1">There’s no “h1” element.</s:assert>
          <s:assert test="h:h1[. = 'Some Title']">The h1 is wrong.</s:assert>
          <s:assert test="h:p">There’s no “p” element.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  

Revision history

03 Aug 2019, Achim Berndzen

Added @features xslt-2

20 Jul 2019, Norman Walsh

Initial publication