2 using System.Collections;
12 public static void Main ()
14 // output22,77: not-supported encoding, but MS passes...?
15 // output72.xsl: should not pass
16 ArrayList expectedExceptions = new ArrayList
17 (new string [] {"lre12.xsl", "namespace40.xsl", "namespace42.xsl", "namespace43.xsl",
18 "namespace48.xsl", "namespace60.xsl", "namespace73.xsl", "namespace106.xsl",
19 "output22.xsl", "output72.xsl", "output77.xsl"});
21 XmlDocument whole = new XmlDocument ();
22 whole.Load (@"testsuite/TESTS/Xalan_Conformance_Tests/catalog.xml");
23 Console.WriteLine ("Started: " + DateTime.Now.ToString ("yyyyMMdd-HHmmss.fff"));
24 foreach (XmlElement testCase in whole.SelectNodes ("test-suite/test-catalog/test-case")) {
25 string stylesheetBase = null;
27 string filePath = testCase.SelectSingleNode ("file-path").InnerText;
28 string path = @"testsuite/TESTS/Xalan_Conformance_Tests/" + filePath + "/";
29 foreach (XmlElement scenario in testCase.SelectNodes ("scenario")) {
30 XslTransform trans = new XslTransform ();
31 stylesheetBase = scenario.SelectSingleNode ("input-file[@role='principal-stylesheet']").InnerText;
32 string stylesheet = path + stylesheetBase;
33 string srcxml = path + scenario.SelectSingleNode ("input-file[@role='principal-data']").InnerText;
34 //if (srcxml.IndexOf ("attribset") < 0)
36 if (expectedExceptions.Contains (stylesheetBase))
38 XmlTextReader stylextr = new XmlTextReader (stylesheet);
39 XmlValidatingReader stylexvr = new XmlValidatingReader (stylextr);
40 XmlDocument styledoc = new XmlDocument ();
41 styledoc.Load (stylesheet);
42 trans.Load (stylesheet);
43 // trans.Load (styledoc);
44 XmlTextReader xtr = new XmlTextReader (srcxml);
45 XmlValidatingReader xvr = new XmlValidatingReader (xtr);
46 xvr.ValidationType = ValidationType.None;
47 XmlDocument input = new XmlDocument ();
50 // XPathDocument input = new XPathDocument (xtr);
51 StringWriter sw = new StringWriter ();
52 trans.Transform (input, null, sw);
53 string outfile = path + scenario.SelectSingleNode ("output-file[@role='principal']").InnerText;
54 if (!File.Exists (outfile)) {
55 // Console.WriteLine ("Reference output file does not exist.");
58 StreamReader sr = new StreamReader (outfile);
59 string reference_out = sr.ReadToEnd ();
60 string actual_out = sw.ToString ();
61 if (reference_out != actual_out)
63 Console.WriteLine ("Different: " + testCase.GetAttribute ("id"));
65 Console.WriteLine ("Different: " +
66 testCase.GetAttribute ("id") +
68 actual_out + "\n-------------------\n" + reference_out + "\n");
71 // } catch (NotSupportedException ex) {
72 } catch (Exception ex) {
73 if (expectedExceptions.Contains (stylesheetBase))
75 Console.WriteLine ("Exception: " + testCase.GetAttribute ("id") + ": " + ex.Message);
78 Console.WriteLine ("Finished: " + DateTime.Now.ToString ("yyyyMMdd-HHmmss.fff"));