DI Management Home > SC14N > Testcanon Examples README

Testcanon Examples README


The folder TestFiles\testcanon is included in the SC14N distribution. This is the associated README file, plus some extra information on the tests. SC14N can be downloaded from here.

Testcanon Examples

Contains example XML files derived from [XML-C14N] examples, including required DTD and TXT files, together with the "correct" results.

The Windows batch file testcanon.bat uses SC14N.exe to compute the SHA-1 digest of the C14N transformed data, then computes the digest value directly of the "OK" file. These values should be the same.

sc14n -d <XML-file>
digestvalue <OK-file>

Requires the utility digestvalue.exe (included).

Two exceptions:

Expected result

Open a command-line console in the directory C:\Program Files (x86)\Sc14n\TestFiles\testcanon and run the testcanon.bat batch file. Or use Start > All Programs > Sc14n > Sc14n Reference Files then Ctrl-right-click on the TestFiles folder and select "Open command window here".

C:\Program Files (x86)\Sc14n>cd TestFiles\testcanon
C:\Program Files (x86)\Sc14n\TestFiles\testcanon>testcanon

testcanon1.xml
R8S/QfGgzSmfIg0qpQthdjJQGuk=
R8S/QfGgzSmfIg0qpQthdjJQGuk=
testcanon2.xml
tEt2bMl/u+uTyPWQTBtI24eXVGE=
tEt2bMl/u+uTyPWQTBtI24eXVGE=
testcanon3.xml
QW9fG5yWDn/iTWUVciixUn7cwRo=
QW9fG5yWDn/iTWUVciixUn7cwRo=
testcanon4.xml
oXv0p+UBJ1RTI8JpA1wElJ+zKiA=
oXv0p+UBJ1RTI8JpA1wElJ+zKiA=
testcanon5.xml
j8qKxUkEAp7CxOYVzaV/XZvo5YM=
j8qKxUkEAp7CxOYVzaV/XZvo5YM=
testcanon6.xml
YdFUlxBqm1OaTMh6VV2H4clo2Co=
YdFUlxBqm1OaTMh6VV2H4clo2Co=
testcanon7.xml
iCAqgq/WXbQgvvizBdlG+fL0PLY=
iCAqgq/WXbQgvvizBdlG+fL0PLY=

Testcanon files: input and C14N output

Source: [XML-C14N] section 3 Examples of XML Canonicalization. HTML highlighting generated by highlight 3.35, http://www.andre-simon.de/.

sc14n testcanonN.xml for N = 1 to 7.

NInputC14N output
1
<?xml version="1.0"?>

<?xml-stylesheet   href="doc.xsl"
   type="text/xsl"   ?>

<!DOCTYPE doc SYSTEM "doc.dtd">

<doc>Hello, world!<!-- Comment 1 --></doc>

<?pi-without-data     ?>

<!-- Comment 2 -->

<!-- Comment 3 -->
<?xml-stylesheet href="doc.xsl"
   type="text/xsl"   ?>
<doc>Hello, world!</doc>
<?pi-without-data?>
2
<doc>
   <clean>   </clean>
   <dirty>   A   B   </dirty>
   <mixed>
      A
      <clean>   </clean>
      B
      <dirty>   A   B   </dirty>
      C
   </mixed>
</doc> 
<doc>
   <clean>   </clean>
   <dirty>   A   B   </dirty>
   <mixed>
      A
      <clean>   </clean>
      B
      <dirty>   A   B   </dirty>
      C
   </mixed>
</doc>
3
<!DOCTYPE doc [<!ATTLIST e9 attr CDATA "default">]>   
<doc>
   <e1   />
   <e2   ></e2>
   <e3   name = "elem3"   id="elem3"   />
   <e4   name="elem4"   id="elem4"   ></e4>
   <e5 a:attr="out" b:attr="sorted" attr2="all" attr="I'm"
      xmlns:b="http://www.ietf.org"
      xmlns:a="http://www.w3.org"
      xmlns="http://example.org"/>
   <e6 xmlns="" xmlns:a="http://www.w3.org">
      <e7 xmlns="http://www.ietf.org">
         <e8 xmlns="" xmlns:a="http://www.w3.org">
            <e9 xmlns="" xmlns:a="http://www.ietf.org"/>
         </e8>
      </e7>
   </e6>
</doc> 
<doc>
   <e1></e1>
   <e2></e2>
   <e3 id="elem3" name="elem3"></e3>
   <e4 id="elem4" name="elem4"></e4>
   <e5 xmlns="http://example.org" xmlns:a="http://www.w3.org" xmlns:b="http://www.ietf.org" attr="I'm" attr2="all" b:attr="sorted" a:attr="out"></e5>
   <e6 xmlns:a="http://www.w3.org">
      <e7 xmlns="http://www.ietf.org">
         <e8 xmlns="">
            <e9 xmlns:a="http://www.ietf.org" attr="default"></e9>
         </e8>
      </e7>
   </e6>
</doc>
4
<?xml version="1.0"?>
<!DOCTYPE doc [
<!ATTLIST normId id ID #IMPLIED>
<!ATTLIST normNames attr NMTOKENS #IMPLIED>
]><!-- normNames and normID elements removed -->
<doc>
   <text>First line&#x0d;&#10;Second line</text>
   <value>&#x32;</value>
   <compute><![CDATA[value>"0" && value<"10" ?"valid":"error"]]></compute>
   <compute expr='value>"0" &amp;&amp; value&lt;"10" ?"valid":"error"'>valid</compute>
   <norm attr=' &apos;   &#x20;&#13;&#xa;&#9;   &apos; '/>
</doc>
<doc>
   <text>First line&#xD;
Second line</text>
   <value>2</value>
   <compute>value&gt;"0" &amp;&amp; value&lt;"10" ?"valid":"error"</compute>
   <compute expr="value>&quot;0&quot; &amp;&amp; value&lt;&quot;10&quot; ?&quot;valid&quot;:&quot;error&quot;">valid</compute>
   <norm attr=" '    &#xD;&#xA;&#x9;   ' "></norm>
</doc>
5
<!DOCTYPE doc [
<!ATTLIST doc attrExtEnt ENTITY #IMPLIED>
<!ENTITY ent1 "Hello">
<!ENTITY ent2 SYSTEM "world.txt">
<!ENTITY entExt SYSTEM "earth.gif" NDATA gif>
<!NOTATION gif SYSTEM "viewgif.exe">
]>
<doc attrExtEnt="entExt">
   &ent1;, &ent2;!
</doc>

<!-- Let world.txt contain "world" (excluding the quotes) --> 
<doc attrExtEnt="entExt">
   Hello, world!
</doc>
6
<?xml version="1.0" encoding="ISO-8859-1"?>
   <doc>&#169;</doc>
<doc>©</doc>
7
<!DOCTYPE doc [
<!ATTLIST e2 xml:space (default|preserve) 'preserve'>
<!ATTLIST e3 id ID #IMPLIED>
]>
<doc xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
   <e1>
      <e2 xmlns="">
         <e3 id="E3"/>
      </e2>
   </e1>
</doc> 
<doc xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
   <e1>
      <e2 xmlns="" xml:space="preserve">
         <e3 id="E3"></e3>
      </e2>
   </e1>
</doc>

References

Contact

To comment on this page, please send us a message.

This page last updated 22 July 2017.