Exemple #1
0
        public virtual void testValidateExtensionschema()
        {
            JDFDoc       doc      = new JDFDoc("JDF");
            JDFValidator checkJDF = new JDFValidator();

            checkJDF.setPrint(false);
            checkJDF.bQuiet = true;
            checkJDF.level  = EnumValidationLevel.Incomplete;
            DirectoryInfo foo = new DirectoryInfo(sm_dirTestSchema);

            Assert.IsTrue(foo.Exists, "please mount the svn schema parallel to JDFLibNet");
            FileInfo jdfxsd = new FileInfo(sm_dirTestSchema + "JDF.xsd");

            checkJDF.setJDFSchemaLocation(jdfxsd);
            JDFNode n = doc.getJDFRoot();

            n.setType(EnumType.ConventionalPrinting);
            JDFMedia med = (JDFMedia)n.addResource("Media", null, EnumUsage.Input, null, null, null, null);

            checkJDF.setIgnorePrivate(false);
            doc.write2File(sm_dirTestDataTemp + "extension.jdf", 0, true);
            XMLDoc @out = checkJDF.processSingleFile(sm_dirTestDataTemp + "extension.jdf");

            Assert.AreEqual(@out.getRoot().getXPathAttribute("TestFile/SchemaValidationOutput/@ValidationResult", null), "Valid");

            checkJDF.schemaLocation += " http://www.extension.com " + sm_dirTestData + "extension.xsd";
            med.setAttribute("ext:ExtensionAtt", "a", "http://www.extension.com");
            KElement fooBar = med.appendElement("ext:FooBar", "http://www.extension.com");

            fooBar.setAttribute("ID", "f1");
            fooBar.setAttribute("Fnarf", "4");

            doc.write2File(sm_dirTestDataTemp + "extension.jdf", 0, true);
            @out = checkJDF.processSingleFile(sm_dirTestDataTemp + "extension.jdf");
            Assert.AreEqual(@out.getRoot().getXPathAttribute("TestFile[2]/SchemaValidationOutput/@ValidationResult", null), "Error");

            med.setAttribute("ext:ExtensionAtt", "3", "http://www.extension.com");
            doc.write2File(sm_dirTestDataTemp + "extension.jdf", 0, true);
            @out = checkJDF.processSingleFile(sm_dirTestDataTemp + "extension.jdf");
            Assert.AreEqual(@out.getRoot().getXPathAttribute("TestFile[3]/SchemaValidationOutput/@ValidationResult", null), "Valid");

            fooBar.setAttribute("Fnarf", "bad");
            doc.write2File(sm_dirTestDataTemp + "extension.jdf", 0, true);
            @out = checkJDF.processSingleFile(sm_dirTestDataTemp + "extension.jdf");
            Assert.AreEqual(@out.getRoot().getXPathAttribute("TestFile[4]/SchemaValidationOutput/@ValidationResult", null), "Error");
        }
Exemple #2
0
        protected internal static JDFDoc creatXMDoc()
        {
            JDFElement.setDefaultJDFVersion(EnumVersion.Version_1_3);
            JDFDoc  doc = new JDFDoc("JDF");
            JDFNode n   = doc.getJDFRoot();

            n.setJobPartID("P1");
            n.setJobID("J1");
            n.setType("ConventionalPrinting", true);
            n.appendElement("NS:Foobar", "www.foobar.com");

            n.appendMatchingResource("Layout", JDFNode.EnumProcessUsage.AnyInput, null);
            JDFComponent    comp = (JDFComponent)n.appendMatchingResource("Component", JDFNode.EnumProcessUsage.AnyOutput, null);
            JDFExposedMedia xm   = (JDFExposedMedia)n.appendMatchingResource("ExposedMedia", JDFNode.EnumProcessUsage.Plate, null);
            JDFNodeInfo     ni   = n.appendNodeInfo();
            JDFMedia        m    = xm.appendMedia();

            m.appendElement("NS:FoobarMedia", "www.foobar.com");

            Assert.AreEqual(EnumResourceClass.Consumable, m.getResourceClass(), "m Class");

            VString vs = new VString();

            vs.Add("SignatureName");
            vs.Add("SheetName");
            vs.Add("Side");

            JDFAttributeMap mPart1 = new JDFAttributeMap("SignatureName", "Sig1");

            mPart1.put("SheetName", "S1");
            mPart1.put("Side", "Front");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);

            mPart1.put("Side", "Back");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);

            mPart1.put("SheetName", "S2");
            mPart1.put("Side", "Front");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);

            mPart1.put("Side", "Back");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);

            mPart1.put("SignatureName", "Sig2");
            mPart1.put("SheetName", "S1");
            mPart1.put("Side", "Front");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);
            comp.appendElement("foo:bar", "www.foobar.com");

            mPart1.put("Side", "Back");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);

            mPart1.put("SheetName", "S2");
            mPart1.put("Side", "Front");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);

            mPart1.put("Side", "Back");
            xm.getCreatePartition(mPart1, vs);
            ni.getCreatePartition(mPart1, vs);
            comp.getCreatePartition(mPart1, vs);
            return(doc);
        }