コード例 #1
0
ファイル: JDFElementTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testIsValid()
        {
            DirectoryInfo testData = new DirectoryInfo(sm_dirTestData + "SampleFiles");

            Assert.IsTrue(testData.Exists, "testData dir");
            FileInfo[] fList = testData.GetFiles();
            JDFParser  p     = new JDFParser();
            JDFParser  p2    = new JDFParser();

            p2.m_SchemaLocation = sm_dirTestSchema + "JDF.xsd";

            for (int i = 0; i < fList.Length; i++)
            {
                FileInfo file = fList[i];
                // skip directories in CVS environments
                //if (file.isDirectory())
                //   continue;

                // skip schema files
                if (file.FullName.EndsWith(".xsd"))
                {
                    continue;
                }

                Console.WriteLine("Parsing: " + file.FullName);
                JDFDoc jdfDoc = p.parseFile(file.FullName);
                Assert.IsTrue(jdfDoc != null, "parse ok");

                KElement e = null;
                if (jdfDoc != null)
                {
                    e = jdfDoc.getRoot();
                    Assert.IsTrue(e.isValid(EnumValidationLevel.RecursiveComplete), "valid doc: " + file.FullName);
                }

                // now with schema validation
                jdfDoc = p2.parseFile(file.FullName);
                Assert.IsTrue(jdfDoc != null, "schema parse ok");

                // TODO fix handling of prerelease default attributes
                if (jdfDoc != null)
                {
                    e = jdfDoc.getRoot();
                    Assert.IsTrue(e.isValid(EnumValidationLevel.RecursiveComplete), "valid doc: " + file.FullName);
                }
            }
        }