Skip to content

Commit

Permalink
New test suite dependencies to better handle HTML versions (support a…
Browse files Browse the repository at this point in the history
…nd default) for serialized output; + new tests for serialization edge cases
  • Loading branch information
Debbie Lockett authored and Debbie Lockett committed Nov 29, 2019
1 parent b21c1d3 commit 82a0f7a
Show file tree
Hide file tree
Showing 11 changed files with 391 additions and 8 deletions.
24 changes: 24 additions & 0 deletions admin/catalog-schema.xsd
Expand Up @@ -881,6 +881,8 @@
<xs:enumeration value="disabling_output_escaping"/>
<xs:enumeration value="dynamic_evaluation"/>
<xs:enumeration value="higher_order_functions"/>
<xs:enumeration value="HTML4"/>
<xs:enumeration value="HTML5"/>
<xs:enumeration value="namespace_axis"/>
<xs:enumeration value="schema_aware"/>
<xs:enumeration value="built_in_derived_types"/>
Expand Down Expand Up @@ -1281,6 +1283,28 @@
</xs:complexType>
</xs:element>

<xs:element name="default_html_version" substitutionGroup="dependency">
<xs:annotation>
<xs:documentation>
<p>Identifies the default HTML version for serialized output.</p>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:restriction base="dependencyType">
<xs:attribute name="value">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="4"/>
<xs:enumeration value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>

<xs:element name="detect_accumulator_cycles" substitutionGroup="dependency" type="dependencyTypeTrue">
<xs:annotation>
<xs:documentation>
Expand Down
26 changes: 22 additions & 4 deletions tests/decl/character-map/_character-map-test-set.xml
Expand Up @@ -511,6 +511,7 @@
<description>Test that characters produced by a character map are immune to Unicode normalization</description>
<keywords>single-character-map xml-output-method</keywords>
<created by="Michael Kay" on="2016-02-18"/>
<modified by="Debbie Lockett" on="2019-11-29" change="Use numeric character references in regex"/>
<environment ref="charmap001"/>
<dependencies>
<spec value="XSLT20+"/>
Expand All @@ -520,11 +521,11 @@
<output serialize="yes"/>
</test>
<result>
<all-of>
<any-of>
<!-- The first c-cedilla is in composed form as codepoint (231); the second is in decomposed form as (99, 807) -->
<!-- The "." in the regex matches codepoint 807, but I'm having difficulty expressing this -->
<serialization-matches>&lt;out>ab#&#231;#&#99;.de&lt;/out></serialization-matches>
</all-of>
<serialization-matches>&lt;out>ab#&#231;#&#99;&#807;de&lt;/out></serialization-matches>
<serialization-matches>&lt;out>ab#&#231;#&#99;&#x327;de&lt;/out></serialization-matches>
</any-of>
</result>
</test-case>

Expand Down Expand Up @@ -563,4 +564,21 @@
<error code="XTSE0010"/>
</result>
</test-case>

<test-case name="character-map-028">
<description>Test that characters produced by a character map are immune to Unicode normalization</description>
<keywords>single-character-map xml-output-method</keywords>
<created by="Debbie Lockett" on="2019-11-29"/>
<environment ref="charmap001"/>
<dependencies>
<spec value="XSLT20+"/>
</dependencies>
<test>
<stylesheet file="character-map-028.xsl"/>
<output serialize="yes"/>
</test>
<result>
<serialization-matches>&lt;out att=['"]ab#&#231;#&#99;&#807;de['"]>ab#&#231;#&#99;&#807;de&lt;/out></serialization-matches>
</result>
</test-case>
</test-set>
16 changes: 16 additions & 0 deletions tests/decl/character-map/character-map-028.xsl
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<!-- test that characters produced by a character map are immune to Unicode normalization -->

<xsl:character-map name="map01">
<xsl:output-character character="c" string="#ç#"/>
</xsl:character-map>

<xsl:output method="xml" use-character-maps="map01" normalization-form="NFD"/>

<xsl:template match="/">
<out att="abcçde">abcçde</out>
</xsl:template>

</xsl:stylesheet>
173 changes: 170 additions & 3 deletions tests/decl/output/_output-test-set.xml
Expand Up @@ -198,6 +198,7 @@
@escape-uri-attributes=yes.</description>
<created by="Michael Kay" on="2012-10-30"/>
<modified by="John Lumley" on="2014-09-02" change="Declared serialization requirement"/>
<modified by="Debbie Lockett" on="2019-11-29" change="Add variant with decimal numeric character references"/>
<environment ref="output-0102"/>
<dependencies>
<spec value="XSLT20+"/>
Expand All @@ -207,7 +208,10 @@
<output serialize="yes"/>
</test>
<result>
<serialization-matches><![CDATA[accesskey="&#x96;"]]></serialization-matches>
<any-of>
<serialization-matches><![CDATA[accesskey="&#x96;"]]></serialization-matches>
<serialization-matches><![CDATA[accesskey="&#150;"]]></serialization-matches>
</any-of>
</result>
</test-case>

Expand Down Expand Up @@ -256,6 +260,7 @@
@escape-uri-attributes=no.</description>
<created by="Michael Kay" on="2012-10-30"/>
<modified by="John Lumley" on="2014-09-02" change="Declared serialization requirement"/>
<modified by="Debbie Lockett" on="2019-11-29" change="Add variant with decimal numeric character references"/>
<environment ref="output-0103"/>
<dependencies>
<spec value="XSLT20+"/>
Expand All @@ -265,7 +270,10 @@
<output serialize="yes"/>
</test>
<result>
<serialization-matches><![CDATA[href="&#x96;"]]></serialization-matches>
<any-of>
<serialization-matches><![CDATA[href="&#x96;"]]></serialization-matches>
<serialization-matches><![CDATA[href="&#150;"]]></serialization-matches>
</any-of>
</result>
</test-case>

Expand All @@ -276,6 +284,7 @@
<modified by="Tim Mills" on="2013-01-29"
change="added variant with hex encoding of character references"/>
<modified by="John Lumley" on="2014-09-02" change="Declared serialization requirement"/>
<modified by="Debbie Lockett" on="2019-11-29" change="Add variant with decimal numeric character references"/>
<environment ref="output-0103"/>
<dependencies>
<spec value="XSLT20+"/>
Expand All @@ -288,6 +297,7 @@
<any-of>
<serialization-matches><![CDATA[href="% %C2%96 &#x96; a &#34; ¡ &lt; &gt; &amp; end"]]></serialization-matches>
<serialization-matches><![CDATA[href="% %C2%96 &#x96; a &#x22; ¡ &lt; &gt; &amp; end"]]></serialization-matches>
<serialization-matches><![CDATA[href="% %C2%96 &#150; a &#34; ¡ &lt; &gt; &amp; end"]]></serialization-matches>
</any-of>
</result>
</test-case>
Expand Down Expand Up @@ -315,6 +325,7 @@
@escape-uri-attributes=no.</description>
<created by="Michael Kay" on="2012-10-30"/>
<modified by="John Lumley" on="2014-09-02" change="Declared serialization requirement"/>
<modified by="Debbie Lockett" on="2019-11-29" change="Add variant with decimal numeric character references"/>
<environment ref="output-0103"/>
<dependencies>
<spec value="XSLT20+"/>
Expand All @@ -324,7 +335,10 @@
<output serialize="yes"/>
</test>
<result>
<serialization-matches><![CDATA[accesskey="&#x96;"]]></serialization-matches>
<any-of>
<serialization-matches><![CDATA[accesskey="&#x96;"]]></serialization-matches>
<serialization-matches><![CDATA[accesskey="&#150;"]]></serialization-matches>
</any-of>
</result>
</test-case>

Expand Down Expand Up @@ -680,6 +694,113 @@
</all-of>
</result>
</test-case>

<test-case name="output-0115b">
<description>Test XHTML output with cdata-section-elements that have (non-ASCII) characters
not representable in the character encoding being used for output (US-ASCII)</description>
<created by="Debbie Lockett" on="2019-11-29"/>
<environment ref="output-01"/>
<dependencies>
<spec value="XSLT20+"/>
</dependencies>
<test>
<stylesheet file="output-0115b.xsl"/>
<output serialize="yes"/>
</test>
<result>
<all-of>
<serialization-matches><![CDATA[<\?xml]]></serialization-matches>
<serialization-matches><![CDATA[<html xmlns="http://www.w3.org/1999/xhtml"><out><example>]]></serialization-matches>
<serialization-matches>&lt;!\[CDATA\[foo \]\]&gt;</serialization-matches>
<serialization-matches>&lt;!\[CDATA\[ bar\]\]&gt;</serialization-matches>
<any-of>
<serialization-matches><![CDATA[>&#xaa;<]]></serialization-matches>
<serialization-matches><![CDATA[>&#170;<]]></serialization-matches>
</any-of>
</all-of>
</result>
</test-case>

<test-case name="output-0115c">
<description>Test XHTML output with cdata-section-elements that have (non-ASCII) characters
not representable in the character encoding being used for output (US-ASCII);
not affected by character maps</description>
<created by="Debbie Lockett" on="2019-11-29"/>
<environment ref="output-01"/>
<dependencies>
<spec value="XSLT20+"/>
</dependencies>
<test>
<stylesheet file="output-0115c.xsl"/>
<output serialize="yes"/>
</test>
<result>
<all-of>
<serialization-matches><![CDATA[<\?xml]]></serialization-matches>
<serialization-matches><![CDATA[<html xmlns="http://www.w3.org/1999/xhtml"><out><example>]]></serialization-matches>
<serialization-matches>&lt;!\[CDATA\[foo \]\]&gt;</serialization-matches>
<serialization-matches>&lt;!\[CDATA\[ bar\]\]&gt;</serialization-matches>
<any-of>
<serialization-matches><![CDATA[>&#xaa;<]]></serialization-matches>
<serialization-matches><![CDATA[>&#170;<]]></serialization-matches>
</any-of>
</all-of>
</result>
</test-case>

<test-case name="output-0115d">
<description>Test XHTML output with cdata-section-elements that have (non-ASCII) characters
not representable in the character encoding being used for output (US-ASCII);
but unicode normalized (NFD) </description>
<created by="Debbie Lockett" on="2019-11-29"/>
<environment ref="output-01"/>
<dependencies>
<spec value="XSLT20+"/>
</dependencies>
<test>
<stylesheet file="output-0115d.xsl"/>
<output serialize="yes"/>
</test>
<result>
<all-of>
<serialization-matches><![CDATA[<\?xml]]></serialization-matches>
<serialization-matches><![CDATA[<html xmlns="http://www.w3.org/1999/xhtml"><out><example>]]></serialization-matches>
<serialization-matches>&lt;!\[CDATA\[foo c\]\]&gt;</serialization-matches>
<serialization-matches>&lt;!\[CDATA\[ bar\]\]&gt;</serialization-matches>
<any-of>
<serialization-matches><![CDATA[>&#807;<]]></serialization-matches>
<serialization-matches><![CDATA[>&#x327;<]]></serialization-matches>
</any-of>
</all-of>
</result>
</test-case>

<test-case name="output-0115e">
<description>Test XHTML output with cdata-section-elements that have (non-ASCII) characters
not representable in the character encoding being used for output (US-ASCII);
but unicode normalized (NFC) </description>
<created by="Debbie Lockett" on="2019-11-29"/>
<environment ref="output-01"/>
<dependencies>
<spec value="XSLT20+"/>
</dependencies>
<test>
<stylesheet file="output-0115e.xsl"/>
<output serialize="yes"/>
</test>
<result>
<all-of>
<serialization-matches><![CDATA[<\?xml]]></serialization-matches>
<serialization-matches><![CDATA[<html xmlns="http://www.w3.org/1999/xhtml"><out><example>]]></serialization-matches>
<serialization-matches>&lt;!\[CDATA\[foo \]\]&gt;</serialization-matches>
<serialization-matches>&lt;!\[CDATA\[ bar\]\]&gt;</serialization-matches>
<any-of>
<serialization-matches><![CDATA[>&#xe7;<]]></serialization-matches>
<serialization-matches><![CDATA[>&#231;<]]></serialization-matches>
</any-of>
</all-of>
</result>
</test-case>

<test-case name="output-0116">
<description>Test empty elements with empty content model in XHTML output and
Expand Down Expand Up @@ -2672,9 +2793,12 @@
<created by="Michael Kay" on="2012-10-30"/>
<modified by="Tim Mills" on="2013-01-29" change="error to assert-serialization-error"/>
<modified by="John Lumley" on="2014-09-02" change="Declared serialization requirement"/>
<modified by="Debbie Lockett" on="2019-11-29" change="Declared requirement for HTML serialization version less than 5.0"/>
<environment ref="output-01"/>
<dependencies>
<spec value="XSLT20+"/>
<feature value="HTML4"/>
<default_html_version value="4"/>
</dependencies>
<test>
<stylesheet file="output-0195.xsl"/>
Expand All @@ -2684,6 +2808,49 @@
<assert-serialization-error code="SERE0014"/>
</result>
</test-case>

<test-case name="output-0195a">
<description>Test that no error is raised if the output method is HTML, with default version 5.0, and the result tree
contains characters in the #x7F-#x9F range.</description>
<created by="Debbie Lockett" on="2019-11-29"/>
<environment ref="output-01"/>
<dependencies>
<spec value="XSLT30+"/>
<feature value="HTML5"/>
<default_html_version value="5"/>
</dependencies>
<test>
<stylesheet file="output-0195.xsl"/>
<output serialize="yes"/>
</test>
<result>
<any-of>
<serialization-matches><![CDATA[<doc>&#x9f;</doc>]]></serialization-matches>
<serialization-matches><![CDATA[<doc>&#159;</doc>]]></serialization-matches>
</any-of>
</result>
</test-case>

<test-case name="output-0195b">
<description>Test that no error is raised if the output method is HTML, version 5.0, and the result tree
contains characters in the #x7F-#x9F range.</description>
<created by="Debbie Lockett" on="2019-11-29"/>
<environment ref="output-01"/>
<dependencies>
<spec value="XSLT30+"/>
<feature value="HTML5"/>
</dependencies>
<test>
<stylesheet file="output-0195b.xsl"/>
<output serialize="yes"/>
</test>
<result>
<any-of>
<serialization-matches><![CDATA[<doc>&#x9f;</doc>]]></serialization-matches>
<serialization-matches><![CDATA[<doc>&#159;</doc>]]></serialization-matches>
</any-of>
</result>
</test-case>

<test-case name="output-0196">
<description>Test that an error is raised if the output method is HTML and &gt; appears within
Expand Down
19 changes: 19 additions & 0 deletions tests/decl/output/output-0115b.xsl
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:transform xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://www.w3.org/1999/XSL/Transform"
version="2.0">

<t:output method="xhtml"
cdata-section-elements="example"
indent="no"
encoding="US-ASCII"/>
<!-- Purpose: Test XHTML output with cdata-section-elements that have non-ASCII character -->

<t:template match="/">
<html>
<out>
<example>foo &#xaa; bar</example>
</out>
</html>
</t:template>
</t:transform>
24 changes: 24 additions & 0 deletions tests/decl/output/output-0115c.xsl
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:transform xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://www.w3.org/1999/XSL/Transform"
version="2.0">

<t:output method="xhtml"
cdata-section-elements="example"
indent="no"
encoding="US-ASCII"
use-character-maps="format1" />
<!-- Purpose: Test XHTML output with cdata-section-elements that have non-ASCII character -->

<t:character-map name="format1">
<t:output-character character="&#170;" string="A"/>
</t:character-map>

<t:template match="/">
<html>
<out>
<example>foo &#xaa; bar</example>
</out>
</html>
</t:template>
</t:transform>

0 comments on commit 82a0f7a

Please sign in to comment.