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