Viewport 004

Test that the match attribute can be an AVT with a static variable reference. (Yes, I know, using the prefix this way is utterly absurd. It’s a unit test.)

Test nw-viewport-004.xml is expected to pass.

The pipeline


    <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
      <p:variable name="gi" static="true" select="xs:QName('ex:p')"/>
      <p:output port="result"/>
      <p:input port="source"/>

      <p:viewport match="*[node-name(.) = $gi]">
        <p:add-attribute attribute-name="v" attribute-value="true" match="/*"/>
      </p:viewport>
    </p:declare-step>
  
MorganaXProc failing XML Calabash passing

Inputs

port = source

<doc xmlns="http://example.com/sample">
  <title>Some Title</title>
  <p>A paragraph.</p>
  <note xml:id="note">
    <p>A paragraph in note.</p>
  </note>
</doc>

Schematron validation


    <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:ns prefix="ex" uri="http://example.com/sample"/>
      <s:pattern>
        <s:rule context="/">
          <s:assert test="ex:doc">The pipeline root is not “doc”.</s:assert>
          <s:assert test="count(ex:doc//ex:p)=2">The pipeline root does not have two descendants "ex:p".</s:assert>
        </s:rule>
        <s:rule context="ex:p">
          <s:assert test=".[@v='true']">The ‘p’ elements don’t have the correct ‘v’ attributes.</s:assert>
        </s:rule>
        <s:rule context="*[not(self::ex:p)]">
          <s:assert test=".[not(@v)]">The ‘v’ attribute appears on the wrong element(s).</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  

Revision history

07 Sep 2019, Achim Berndzen

Fix test so it fails if there is no ex:p.

08 Jul 2019, Norman Walsh

Initial publication