コード例 #1
0
ファイル: JDFEvaluation.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * fitsJDF - tests whether JDFNode 'jdf' can be accepted by the Device.
        ///	 * Tests if the value of resource attribute, decribed with this Evaluation,
        ///	 * fits Evaluation/@ValueList
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            jdf node to test </param>
        ///	 * <returns> boolean - true, if 'jdf' can be accepted by the Device </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            string xPath = getEvalXPath(jdf);

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement(LocalName);
            }

            bool b = false;

            if (xPath != null)
            {
                b = fitsPath(jdf, xPath, reportRootLocal);
            }

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
                reportRootLocal.setAttribute("CapXPath", getRefTargetNamePath());
                reportRootLocal.setAttribute("Name", getRefTargetName());
            }

            return(b);
        }
コード例 #2
0
        public virtual void testObjectTagsMetadata()
        {
            KElement tagMap = rl.appendElement(METADATA_MAP);

            tagMap.setXMLComment("This tagmap specifies The path for the NMTOKEN \"ObjectTag\"");
            tagMap.setAttribute("Name", "ObjectTags");
            tagMap.setAttribute(AttributeName.VALUEFORMAT, "%s");
            tagMap.setAttribute(AttributeName.CONTEXT, "Object");
            tagMap.setAttribute(AttributeName.DATATYPE, "NMTOKEN");
            tagMap.setAttribute(AttributeName.VALUETEMPLATE, "AnyName1");
            tagMap.addNameSpace("TIFFXMP", "http://ns.adobe.com/tiff/1.0");
            string[] ss = new string[] { "Acme", "Bcme", "Ccme" };
            for (int i = 0; i < ss.Length; i++)
            {
                string   s      = ss[i];
                KElement tagSet = tagMap.appendElement(EXPR);
                tagSet.setAttribute("Name", "AnyName1");
                tagSet.setAttribute("Value", s);

                JDFStringEvaluation eval = (JDFStringEvaluation)tagSet.appendElement(ElementName.STRINGEVALUATION);
                eval.setAttribute("Path", "TIFFXMP:Make");
                eval.setRegExp("(.*)" + s + "(.*)");
                eval.setXMLComment("Any acme camera is mapped to \"" + s + "\"");
            }
            JDFColorSpaceConversionParams csp = (JDFColorSpaceConversionParams)root.addResource(ElementName.COLORSPACECONVERSIONPARAMS, EnumUsage.Input);

            csp.setXMLComment("This ColorSpaceConversionParams treats Acme and Bcme cameras the same but differentiates for Ccme");
            JDFColorSpaceConversionOp op1 = csp.appendColorSpaceConversionOp();

            op1.setAttribute("ObjectTags", "Acme Bcme");
            JDFColorSpaceConversionOp op2 = csp.appendColorSpaceConversionOp();

            op2.setAttribute("ObjectTags", "Ccme");
            doc.write2File(sm_dirTestDataTemp + "objectTags.jdf", 2, false);
        }
コード例 #3
0
        ///
        ///	 <summary> * Inverts the boolean state of a Term child element (and, or, xor, not,
        ///	 * Evaluation, TestRef)
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode we test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate. Set to <code>null</code> if no report
        ///	 *            is requested. </param>
        ///	 * <returns> boolean - true, if boolean “not” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v   = getTermVector(null);
            int      siz = v.Count;
            bool     b   = false;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("not");
            }

            int count = 0;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                b = !t.fitsJDF(jdf, reportRootLocal);
                count++;
                if (reportRootLocal != null)
                {
                    reportRootLocal.setAttribute("Value", b, null);
                }
            }

            if (reportRootLocal != null && count != 1)
            {
                reportRootLocal.setAttribute("SyntaxWarning", "Warning: not element with more than one term, count=" + Convert.ToString(count));
            }

            return(b);
        }
コード例 #4
0
        ///
        ///	 <summary> * devCapReport - tests if the elements in vElem fit any (logical OR) DevCap
        ///	 * element that DevCaps consists of. Composes a detailed report in XML form
        ///	 * of the errors found. If XMLDoc is null there are no errors.<br>
        ///	 *
        ///	 * DevCaps will be checked if they are direct children of <code>this</code>
        ///	 * and referenced in DevCapPool.
        ///	 *  </summary>
        ///	 * <param name="vElem">
        ///	 *            vector of the elements to test </param>
        ///	 * <param name="testlists">
        ///	 *            testlists that are specified for the State elements
        ///	 *            (FitsValue_Allowed or FitsValue_Present)<br>
        ///	 *            Will be used in fitsValue method of the State element. </param>
        ///	 * <param name="level">
        ///	 *            validation level </param>
        ///	 * <returns> XMLDoc - XMLDoc output of the error messages.<br>
        ///	 *         If XMLDoc is null there are no errors, every element of vElem
        ///	 *         fits any DevCap element of <code>this</code>. </returns>
        ///	 * <exception cref="JDFException">
        ///	 *             if DevCaps/@DevCapRef refers to the DevCap elements in a
        ///	 *             non-existent DevCapPool </exception>
        ///	 * <exception cref="JDFException">
        ///	 *             if DevCaps/@DevCapRef refers to the non-existent DevCap </exception>
        ///
        public KElement devCapReport(KElement elem, EnumFitsValue testlists, EnumValidationLevel level, bool ignoreExtensions, KElement parentReport)
        {
            if (elem == null)
            {
                return(null);
            }
            VElement dcV = getDevCapVector();

            if (dcV == null || dcV.Count == 0)
            {
                throw new JDFException("JDFDevCaps.devCapReport: Invalid DeviceCap: DevCaps/@DevCapRef refers to the non-existent DevCap: " + getDevCapRef());
            }

            KElement r = parentReport.appendElement("Invalid" + getContext().getName());

            for (int i = 0; i < dcV.Count; i++)
            {
                JDFDevCap dc = (JDFDevCap)dcV[i];
                KElement  stateTestResult = dc.stateReport(elem, testlists, level, ignoreExtensions, true, r);
                if (stateTestResult == null)
                {
                    r.deleteNode();
                    return(null); // first DevCap that fits found -> erase all error
                    // messages
                }
                r.setAttribute("XPath", elem.buildXPath(null, 1));
                r.setAttribute("Name", getContextName());
                r.setAttribute("CapXPath", dc.getName());
            }

            correction_Static(r);
            return(r);
        }
コード例 #5
0
        public static KElement appendRefAnchor(JDFMarkObject mark0, string anchor, string anchorType, string rRef)
        {
            KElement refAnchor = mark0.getCreateElement("RefAnchor", null, 0);

            refAnchor.setAttribute("Anchor", anchor);
            refAnchor.setAttribute("AnchorType", anchorType);
            refAnchor.setAttribute("rRef", rRef);
            return(refAnchor);
        }
コード例 #6
0
ファイル: StrippingTest.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 * <param name="sm2_2"> </param>
        ///	 * <param name="idAnchor"> </param>
        ///
        private static void setNextAnchor(KElement sm2_2, string idAnchor, string anchor, string absolutePosition, string xmlComment, string anchorType)
        {
            KElement nextAnchor = sm2_2.appendElement("RefAnchor");

            nextAnchor.setAttribute("Anchor", anchor);
            sm2_2.setAttribute("Offset", absolutePosition);
            nextAnchor.setAttribute("rRef", idAnchor);
            nextAnchor.setAttribute("AnchorType", anchorType);
            nextAnchor.setXMLComment(xmlComment);
        }
コード例 #7
0
                ///
                ///			 <summary> * very simple check for the string "snafu" </summary>
                ///
                public virtual bool validate(KElement toCheck, KElement report)
                {
                    bool b = toCheck.ToString().ToUpper().IndexOf("SNAFU") >= 0;

                    if (b)
                    {
                        report.setAttribute("IsValid", false, null);
                        report.setAttribute("ErrorType", "PrivateValidation", null);
                        report.setAttribute("Message", "MyValid: Element contains snafu!!!", null);
                        Console.WriteLine("MyValid: Element contains snafu!!! " + toCheck.Name);
                    }
                    return(!b);
                }
コード例 #8
0
ファイル: JDFPageListTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testContentData()
        {
            d = new JDFDoc("JDF");
            n = d.getJDFRoot();
            n.setType(EnumType.Approval);
            JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, EnumUsage.Input);

            pl = rl.appendPageList();
            pl.makeRootResource("PageList", null, true);

            cl = pl.appendContentList();
            cl.makeRootResource("ContentList", null, true);
            JDFContentData cd0 = cl.appendContentData();

            cd0.setAttribute(AttributeName.CONTENTLISTINDEX, "1 2 3");
            KElement book = cd0.appendElement("ContentMetaData");

            book.setAttribute("ISBN", "0123456789");
            JDFComment abstrakt = (JDFComment)book.appendElement("Comment");

            abstrakt.setName("Abstract");
            abstrakt.setText("Abstract of the book\nin english");
            JDFEmployee editor = (JDFEmployee)book.appendElement(ElementName.EMPLOYEE);

            editor.appendPerson().setFamilyName("authorName");
            editor.setRoles(new VString("Editor", null));
            book.setAttribute("Title", "book thing");
            int p = 1;

            for (int i = 1; i < 4; i++)
            {
                JDFContentData cd = cl.appendContentData();
                cd.setAttribute("ID", "CD_" + i);
                KElement chap = cd.appendElement("ContentMetaData");
                chap.setAttribute("Title", "Chapter " + i);
                JDFEmployee author = (JDFEmployee)chap.appendElement(ElementName.EMPLOYEE);
                author.appendPerson().setFamilyName("authorName" + i);
                author.setRoles(new VString("Author", null));

                JDFPageData         pd = pl.appendPageData();
                JDFIntegerRangeList integerRangeList = new JDFIntegerRangeList();
                integerRangeList.Append(p, p + i);
                p += i + 1;
                pd.setAttribute("PageIndex", integerRangeList.ToString());
                JDFPageElement pe = pd.appendPageElement();
                pe.setAttribute("ContentDataRefs", cd.getID());
            }
            pl.setXMLComment("Note that multiple page elements may but need not be specified\nit is also possible to reference only on pageEleemnt that spans the entire book");

            d.write2File(sm_dirTestDataTemp + "ContentMetaData.jdf", 2, false);
        }
コード例 #9
0
        ///
        ///	 <summary> * For KElement 'elem' takes information from parent and children about
        ///	 * original and corrected CapXPaths, compare them and set CapXPath as a
        ///	 * complete path to this element.<br>
        ///	 * Checks CapXPath's for every InvalidResource element of the given XMLDoc
        ///	 * and all children (of arbitrary depth). Appends right ancestors if
        ///	 * CapXPath is not complete.<br>
        ///	 *  </summary>
        ///	 * <param name="elem">
        ///	 *            "pool" element like "InvalidElements" or "InvalidAttributes".<br>
        ///	 *            From this element we have access to its parent and children
        ///	 *            and can compare their CapXPath's </param>
        ///	 * <param name="originalPath">
        ///	 *            parent CapXPath before correction. </param>
        ///
        private static void capXPathCorrection_Static(KElement elem, string originalPath)
        {
            string parentPath = elem.getParentNode_KElement().getAttribute("CapXPath");

            VElement vEl = elem.getChildElementVector(null, null, null, true, 0, false);

            for (int i = 0; i < vEl.Count; i++)
            {
                KElement child     = (KElement)vEl[i];
                string   childPath = child.getAttribute("CapXPath");

                if (!parentPath.Equals(JDFConstants.EMPTYSTRING) && !childPath.Equals(JDFConstants.EMPTYSTRING))
                {
                    string childPathPart = childPath;
                    if (childPath.StartsWith(originalPath))
                    {
                        childPathPart = childPath.Substring(originalPath.Length + 1); // +1 removes
                        // "/"
                    }
                    child.setAttribute("CapXPath", parentPath + "/" + childPathPart);

                    // recursion to set everywhere the right CapXPath
                    VElement vSubEl = child.getChildElementVector(null, null, null, true, 0, false);
                    for (int j = 0; j < vSubEl.Count; j++)
                    {
                        capXPathCorrection_Static(vSubEl[j], childPath);
                    }
                }
            }
            return;
        }
コード例 #10
0
ファイル: UrlUtilTest.cs プロジェクト: cip4/JDFLibNet
 public virtual void testNonAsciiFileURL()
 {
     for (int i = 0; i < 2; i++) // loop over escape and non-escape
     {
         FileInfo f  = new FileInfo("4€5%äö.txt");
         FileInfo f2 = FileUtil.getFileInDirectory(new DirectoryInfo(sm_dirTestDataTemp), f);
         f2.Delete();
         SupportClass.FileSupport.CreateNewFile(f2);
         f2.Refresh();
         Assert.IsTrue(f2.Exists);
         string   url  = UrlUtil.fileToUrl(f2, i == 0);
         XMLDoc   doc  = new XMLDoc("URL", null);
         KElement root = doc.getRoot();
         root.setAttribute("url", url);
         doc.write2File(sm_dirTestDataTemp + "url.xml", 2, false);
         JDFParser p = new JDFParser();
         p.bKElementOnly = true;
         JDFDoc   d        = p.parseFile(sm_dirTestDataTemp + "url.xml");
         KElement root2    = d.getRoot();
         string   urlParse = root2.getAttribute("url");
         Assert.AreEqual(url, urlParse);
         FileInfo f3 = UrlUtil.urlToFile(urlParse);
         Assert.AreEqual(f2.FullName, f3.FullName);
         Assert.IsTrue(f3.Exists);
     }
 }
コード例 #11
0
ファイル: JDFor.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates two or more Term elements (and, or, xor, not, Evaluation,
        ///	 * TestRef) to determine if, as a set, they evaluate to “true” when combined
        ///	 * in a boolean “or” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode we test iot know if the Device can accept it </param>
        ///	 * <returns> boolean - true, if boolean “or” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v   = getTermVector(null);
            int      siz = v.Count;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("or");
            }

            bool b = false;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t  = (JDFTerm)v[i];
                bool    b2 = t.fitsJDF(jdf, reportRootLocal);
                if (b2 && reportRootLocal == null)
                {
                    return(true); // don't need complete report and it is true; ciao
                }
                b = b || b2;
            }

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
コード例 #12
0
ファイル: JDFTest.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates the boolean expression (child Term element) if it fits the
        ///	 * JDFNode 'jdf' a value of true corresponds to a failed test, i.e. the test
        ///	 * describes INVALID states for the jdf
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode to test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate. Set to <code>null</code> if no report
        ///	 *            is requested. </param>
        ///	 * <returns> boolean - true, if boolean expression (child Term element)
        ///	 *         evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("TestReport");
            }
            JDFTerm t = getTerm();

            if (t == null)
            {
                return(true); // no term --> assume it is a non test; i.e. ok
            }
            bool checkContext = true;

            if (hasAttribute(AttributeName.CONTEXT))
            {
                checkContext = !jdf.matchesPath(getContext(), true);
            }
            if (checkContext && !t.fitsContext(jdf))
            {
                return(true);
            }
            bool b = t.fitsJDF(jdf, reportRootLocal);

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }
            return(b);
        }
コード例 #13
0
ファイル: WebTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testWebGrowthCompensation()
        {
            JDFElement.setLongID(false);
            doc = new JDFDoc("JDF");
            JDFNode         n    = doc.getJDFRoot();
            JDFResourcePool rp   = n.getCreateResourcePool();
            JDFResource     lo   = n.addResource("Layout", EnumResourceClass.Parameter, EnumUsage.Input, null, null, null, null);
            JDFLayout       losh = (JDFLayout)lo.addPartition(EnumPartIDKey.SheetName, "Sheet1");
            JDFLayout       lofr = (JDFLayout)losh.addPartition(EnumPartIDKey.Side, EnumSide.Front.getName());

            rp.appendXMLComment("LayoutShift SHOULD be partitioned: at least Side and Separation will make sense", null);

            JDFResource los = n.addResource("LayoutShift", EnumResourceClass.Parameter, EnumUsage.Input, null, null, null, null);

            los.appendXMLComment("Note that the interpolation algorithm between positions is implementation dependent", null);
            los = los.addPartition(EnumPartIDKey.Side, "Front");
            VString vSep = new VString("Cyan Magenta Yellow Black", " ");

            for (int i = 0; i < 16; i++)
            {
                int x               = 720 * (i % 4);
                int y               = 1000 * (i / 4);
                int ord             = i % 8;
                JDFContentObject co = lofr.appendContentObject();
                co.setOrd(ord);
                co.setOrdID(i);
                co.setCTM(new JDFMatrix(1, 0, 0, 1, x, y));
                JDFMarkObject mo = lofr.appendMarkObject();
                mo.setOrd(ord);
                mo.setOrdID(i + 100);
                mo.setCTM(new JDFMatrix(1, 0, 0, 1, x + 700, y + 900));
            }
            for (int j = 0; j < vSep.Count; j++)
            {
                KElement sepShift = los.addPartition(EnumPartIDKey.Separation, vSep.stringAt(j));
                for (int i = 0; i < 16; i += 2)
                {
                    int      x           = 720 * (i % 4);
                    int      y           = 1000 * (i / 4);
                    KElement shiftObject = sepShift.appendElement("ShiftPoint");

                    shiftObject.setAttribute("Position", new JDFXYPair(x + 360, y + 500).ToString());
                    shiftObject.setAttribute("CTM", new JDFMatrix(1, 0, 0, 1, j + i / 4, j + i % 4).ToString());
                }
            }
            doc.write2File(sm_dirTestDataTemp + "WebgrowthPartition.jdf", 2, false);
        }
コード例 #14
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");
        }
コード例 #15
0
        ///
        ///	 * <param name="sm2_2"> </param>
        ///	 * <param name="idAnchor"> </param>
        ///	 * <exception cref="FormatException"> </exception>
        ///
        private static void setNextAnchor(KElement sm2_2, string idAnchor, string anchor, string absolutePosition, string xmlComment, string anchorType, double rotation)
        {
            KElement nextAnchor = sm2_2.appendElement("RefAnchor");

            nextAnchor.setAttribute("Anchor", anchor);
            JDFMatrix m  = new JDFMatrix("1 0 0 1 0 0");
            JDFXYPair xy = absolutePosition == null ? null : new JDFXYPair(absolutePosition);

            m.shift(xy);
            m.rotate(rotation);
            if (xy != null || rotation != 0)
            {
                sm2_2.setAttribute("CTM", m.ToString());
            }
            nextAnchor.setAttribute("rRef", idAnchor);
            nextAnchor.setAttribute("AnchorType", anchorType);
            nextAnchor.setXMLComment(xmlComment);
        }
コード例 #16
0
        public virtual void testTagMapTiff()
        {
            KElement tagMap = rl.appendElement(METADATA_MAP);

            tagMap.setAttribute("BoundaryKey", "EndOfDocument");
            KElement tagSet = tagMap.appendElement(EXPR);

            tagSet.setAttribute("Path", "/x3141");
            tagMap.setXMLComment("This tagmap specifies which document structure corresponds to a Document\n" + " thus incrementing DocIndex or forcing an implicit RunList/@EndofDocument=true\n D100 is the tiff tag 0x3141");

            rl.setFileURL("bigVariable.tiff");
            rl.setXMLComment("this runlist points to a tiff file with arbitrary structural tagging defined in the tiff tags");
        }
コード例 #17
0
ファイル: JDFxor.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates two or more Term elements (and, or, xor, not, Evaluation,
        ///	 * TestRef) to determine if, as a set, they evaluate to “true” when combined
        ///	 * in a boolean “xor” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode to test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate; set to <code>null</code> if no report
        ///	 *            is requested </param>
        ///	 * <returns> boolean - true, if boolean “xor” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v = getTermVector(null);

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("xor");
            }

            int siz = v.Count;

            int count = 0;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                if (t.fitsJDF(jdf, reportRootLocal))
                {
                    count++;
                }

                if (count > 1 && reportRootLocal == null)
                {
                    break;
                }
            }

            bool b = (count == 1);

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
コード例 #18
0
ファイル: JDFand.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates two or more term elements (
        ///	 * <code>and, or, xor, not, Evaluation, TestRef</code>) to determine if, as
        ///	 * a set, they evaluate to “true” when combined in a boolean “and” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            the JDFNode to be checked iot find out if the device can
        ///	 *            accept it </param>
        ///	 * <returns> boolean - true, if boolean “and” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot) // const JDFNode
        {
            KElement reportRootLocal = reportRoot;

            VElement v = getTermVector(null);

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("and");
            }

            int  siz = v.Count;
            bool b   = true;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t  = (JDFTerm)v[i];
                bool    b2 = t.fitsJDF(jdf, reportRootLocal);
                if (!b2)
                {
                    if (reportRootLocal == null)
                    {
                        return(false);
                    }
                }

                b = b && b2;
            }

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
コード例 #19
0
ファイル: CheckJDF.cs プロジェクト: cip4/JDFLibNet
        private string parseArgs(string[] commandLineArgs)
        {
            MyArgs args = new MyArgs(commandLineArgs, "?cmqPQvVntwU", "dlfLuhpTxX", null);

            if (args.boolParameter('?', false))
            {
                sysOut.println("JDFValidator:\n" + version + '\n' + usage);
                Application.Exit();
            }
            bWarning         = args.boolParameter('w', false);
            bTiming          = args.boolParameter('t', false);
            bQuiet           = args.boolParameter('q', false);
            bWarnDanglingURL = args.boolParameter('U', false);

            this.setPrint(!args.boolParameter('Q', false));
            xmlOutputName = args.parameterString('x');
            xslStyleSheet = args.parameterString('X');
            getTranslation(args);
            pOut = new XMLDoc("CheckOutput", null);
            KElement xmlRoot = pOut.getRoot();

            xmlRoot.setAttribute("Language", "EN");

            bool bVersion = !bQuiet || args.boolParameter('V', false);

            if (bVersion)
            {
                sysOut.println('\n' + version + '\n');
                sysOut.println(args.ToString());
                xmlRoot.setAttribute("Arguments", StringUtil.setvString(commandLineArgs, " ", null, null));
            }

            bPrintNameSpace = args.boolParameter('n', false);
            bMultiID        = args.boolParameter('m', false);

            if (args.hasParameter('h'))
            {
                proxyHost = args.parameterString('h');
                proxyPort = args.parameterString('p');
            }

            if (args.hasParameter('c'))
            {
                if (args.boolParameter('c', false))
                {
                    level = EnumValidationLevel.Complete;
                }
                else
                {
                    level = EnumValidationLevel.Incomplete;
                }
            }

            string parameterString = args.parameterString('L');

            if (parameterString != null)
            {
                setJDFSchemaLocation(new FileInfo(parameterString));
            }

            string schemaLocation0 = args.parameterString('l');

            // convert "," to blank
            if (schemaLocation0 != null)
            {
                VString vs = new VString(schemaLocation0, JDFConstants.COMMA);
                if (vs.Count % 2 != 0)
                {
                    sysOut.println("error in schema location: format is \"NameSpaceURI1,Location1,NameSpaceURI2,Location2\"\n - bailing out!" + usage);
                    Application.Exit();
                }
                schemaLocation0 = StringUtil.setvString(vs, JDFConstants.BLANK, JDFConstants.EMPTYSTRING, JDFConstants.EMPTYSTRING);
                schemaLocation += schemaLocation0;
            }

            if (args.hasParameter('d'))
            {
                devCapFile = args.parameterString('d');
                FileInfo fDC = UrlUtil.urlToFile(devCapFile);
                if (fDC == null || !fDC.Exists)
                {
                    sysOut.println("Error reading devcap file: " + devCapFile + "\n - bailing out!\n" + usage);
                    Application.Exit();
                }
            }

            bValidate = (args.boolParameter('v', false)) || (schemaLocation != null);
            string jdfVersion = args.parameterString('f');

            if (jdfVersion != null)
            {
                EnumVersion v = EnumVersion.getEnum(jdfVersion);
                JDFElement.setDefaultJDFVersion(v);
                JDFVersions.ForceVersion = true;
            }

            if (args.nargs() == 0)
            {
                sysOut.println(args.usage(usage));
                Application.Exit();
            }

            testlists = EnumFitsValue.Allowed;
            if (args.boolParameter('P', false))
            {
                testlists = EnumFitsValue.Present;
            }

            string url = args.parameterString('u');

            setAllFiles(args);
            return(url);
        }
コード例 #20
0
ファイル: DigiPrintTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testVariableManifests()
        {
            ruli.setXMLComment("the set / doc / ... structure is transferred from the pre-impositioning pdl");

            JDFPageList pl = (JDFPageList)n.addResource(ElementName.PAGELIST, null);

            pl.setResStatus(EnumResStatus.Available, false);

            JDFContentList cl = (JDFContentList)pl.appendContentList().makeRootResource(null, null, true);

            cl.setResStatus(EnumResStatus.Available, false);
            cl.setXMLComment("Should we allow for content-data cross references to forther contentdata fields?");
            ruli.refPageList(pl);
            comp.refPageList(pl);
            int pageCount = 0;

            digiParams.setSides(EnumSides.TwoSidedFlipY);
            digiParams.setXMLComment("the sides attribute may be overridden by explicitly or implicitly missing runlist input elements");

            VString vRun = new VString("Letter BrochureMale BrochureFemale", null);

            JDFStitchingParams sp = (JDFStitchingParams)n.addResource(ElementName.STITCHINGPARAMS, EnumUsage.Input);

            med.setXMLComment("Media Partitioning is convenience only- the actual media selection is done by the digitalprintingparams MediaRef");
            for (int i = 0; i < vRun.Count; i++)
            {
                string   part      = vRun[i];
                JDFMedia partMedia = (JDFMedia)med.addPartition(EnumPartIDKey.Run, part);
                partMedia.setProductID(part + "Media");

                JDFDigitalPrintingParams digiPart = (JDFDigitalPrintingParams)digiParams.addPartition(EnumPartIDKey.Run, part);
                digiPart.refMedia(partMedia);

                sp.setXMLComment("how are multiple runs stitched together e.g. cover + body?");
                JDFStitchingParams spPart = (JDFStitchingParams)sp.addPartition(EnumPartIDKey.Run, part);
                if (i == 0)
                {
                    spPart.setNoOp(true);
                    spPart.setDescriptiveName("The letter is a loose leaf collection");
                }
                else
                {
                    spPart.setNumberOfStitches(3);
                    spPart.setStitchType(EnumStitchType.Saddle);
                }
            }

            // loop over records
            for (int i = 0; i < 10; i++)
            {
                JDFContentData letter = cl.appendContentData();
                letter.setContentType("Letter");
                JDFContentData brochure = cl.appendContentData();
                brochure.setContentType("Brochure");
                KElement lMeta = letter.appendElement("ContentMetadata");
                // TODO apply new example
                lMeta.setAttribute("Record", "" + i);
                string gender = i % 2 == 0 ? "Male" : "Female";
                lMeta.setAttribute("Gender", gender);
                lMeta.setXMLComment("Note that the final format of the metadata element is open");
                KElement bMeta = brochure.appendElement("Metadata");
                bMeta.setAttribute("Record", "" + i);
                bMeta.setAttribute("Gender", gender);

                JDFRunList runSet = (JDFRunList)ruli.addPartition(EnumPartIDKey.RunSet, "Record" + i);
                JDFRunList run    = runSet.addRun("file://server/tifs/testLetter" + i + ".tif", 0, -1);
                run.setRun("Letter");
                JDFComponent compSet = (JDFComponent)comp.addPartition(EnumPartIDKey.RunSet, runSet.getRunSet());
                JDFComponent co      = (JDFComponent)compSet.addPartition(EnumPartIDKey.Run, run.getRun());
                int          page    = (3 * i) % 7 + 1;
                run.setPageListIndex(new JDFIntegerRangeList(new JDFIntegerRange(pageCount, pageCount + page - 1)));
                co.setPageListIndex(new JDFIntegerRangeList(new JDFIntegerRange(pageCount, pageCount + page - 1)));
                co.setSurfaceCount(2 * ((page + 1) / 2));
                run.setPages(new JDFIntegerRangeList("0~" + (page - 1)));
                run.setXMLComment("Cover Letter - record " + i);
                run.setEndOfDocument(true);
                JDFPageData pd = pl.appendPageData();
                pd.refContentData(letter);
                pd.setAttribute("PageIndex", pageCount + " ~ " + (pageCount + page - 1));
                pageCount += page;

                run = runSet.addRun("file://server/tifs/testBrochure" + i + ".tif", 0, -1);
                run.setRun("Brochure" + gender);

                co   = (JDFComponent)compSet.addPartition(EnumPartIDKey.Run, run.getRun());
                page = 2 * ((7 * i) % 13) + 2;
                run.setPageListIndex(new JDFIntegerRangeList(new JDFIntegerRange(pageCount, pageCount + page - 1)));
                co.setPageListIndex(new JDFIntegerRangeList(new JDFIntegerRange(pageCount, pageCount + page - 1)));
                co.setSurfaceCount(2 * ((page + 1 + 1) / 2)); // the 2nd +1 is for
                // the blank inside
                // cover
                run.setPages(new JDFIntegerRangeList("0~" + (page - 1)));
                run.setXMLComment("Brochure - record " + i);
                run.setEndOfDocument(true);
                runSet.setEndOfSet(true);
                run.setAttribute("SkipBlankOrds", "1");
                run.setNPage(page + 1);
                run.setXMLComment("SkipBlankOrds specifies the relative position of pages to skip\n1 specifies that the first back sheet is skipped\nNPage MUST be incremented by the # of skipped pages.");
                pd = pl.appendPageData();
                pd.refContentData(brochure);
                pd.setAttribute("PageIndex", pageCount + " ~ " + (pageCount + page - 1));
                pageCount += page;
            }
            doc.write2File(sm_dirTestDataTemp + "RunlistManifest.jdf", 2, false);
        }
コード例 #21
0
        public virtual void testTagMap()
        {
            JDFLayout lo   = (JDFLayout)root.addResource(ElementName.LAYOUT, null, EnumUsage.Input, null, null, null, null);
            JDFMedia  med  = (JDFMedia)root.addResource(ElementName.MEDIA, null, EnumUsage.Input, null, null, null, null);
            JDFMedia  medM = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "MaleCover");
            JDFMedia  medF = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "FemaleCover");
            JDFMedia  medB = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "MaleBigBody MaleSmallBody FemaleBigBody FemaleSmallBody");

            JDFLayout loM = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleCover");

            loM.refElement(medM);
            JDFLayout loF = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "FemaleCover");

            loF.refElement(medF);
            JDFLayout loBB = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleBigBody FemaleBigBody");

            loBB.refElement(medB);
            JDFLayout loSB = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleSmallBody FemaleSmallBody");

            loSB.refElement(medB);
            lo.setXMLComment("Layout for versioned product");

            KElement metaMap = rl.appendElement(METADATA_MAP);

            metaMap.setXMLComment("The MetadataMap element maps arbitrary tags in the document to a structural RunTag partition key\n" + "Note that any partition key may be mapped.\n" + "Note also that although an XPath syntax is used, this may be mapped to any hierarchical structure including but not limited to XML.\n");

            metaMap.setAttribute("Name", "RunTags");
            metaMap.setAttribute(AttributeName.DATATYPE, "PartIDKey");
            metaMap.setAttribute(AttributeName.VALUEFORMAT, "%s%s");
            metaMap.setAttribute(AttributeName.VALUETEMPLATE, "sex,section");

            KElement expr = metaMap.appendElement(EXPR);

            expr.setXMLComment("This expression maps the value of /Dokument/Rezipient/@Sex to a variable \"sex\"\n" + "The Mapping is unconditional, therefore no Term is required");
            expr.setAttribute("Name", "sex");
            expr.setAttribute("Path", "/Dokument/Rezipient/@Sex");

            expr = metaMap.appendElement(EXPR);
            expr.setXMLComment("Maps all elements with /Dokument/Sektion=Einband to Cover");
            expr.setAttribute("Name", "section");
            expr.setAttribute("Value", "Cover");
            JDFNameEvaluation nev = (JDFNameEvaluation)expr.appendElement(ElementName.NAMEEVALUATION);

            nev.setAttribute("Path", "/Dokument/Sektion");
            nev.setRegExp("Einband");

            expr = metaMap.appendElement(EXPR);
            expr.setXMLComment("Maps all elements with /Dokument/Sektion=HauptTeil and >50 pages to BigBody");
            expr.setAttribute("Name", "section");
            expr.setAttribute("Value", "BigBody");

            JDFand and = (JDFand)expr.appendElement("and");

            nev = (JDFNameEvaluation)and.appendElement(ElementName.NAMEEVALUATION);
            nev.setAttribute("Path", "/Dokument/Sektion");
            nev.setRegExp("HauptTeil");
            JDFIntegerEvaluation iev = (JDFIntegerEvaluation)and.appendTerm(EnumTerm.IntegerEvaluation);

            iev.setAttribute("Path", "count(PAGE)");
            iev.setValueList(new JDFIntegerRangeList("51~INF"));

            expr = metaMap.appendElement(EXPR);
            expr.setXMLComment("Maps all elements with /Dokument/Sektion=HauptTeil and <=50 pages to SmallBody");
            expr.setAttribute("Name", "section");
            expr.setAttribute("Value", "SmallBody");

            and = (JDFand)expr.appendElement("and");
            nev = (JDFNameEvaluation)and.appendElement(ElementName.NAMEEVALUATION);
            nev.setAttribute("Path", "/Dokument/Sektion");
            nev.setRegExp("HauptTeil");
            iev = (JDFIntegerEvaluation)and.appendTerm(EnumTerm.IntegerEvaluation);
            iev.setAttribute("Path", "count(PAGE)");
            iev.setValueList(new JDFIntegerRangeList("0~INF"));

            rl.setFileURL("bigVariable.ppml");
            rl.setXMLComment("this runlist points to a ppml with arbitrary structural tagging");

            JDFResourceLink rll = root.getLink(rl, null);

            rll.appendPart().setDocIndex(new JDFIntegerRangeList("10 ~ 20"));
            rll.setXMLComment("this link selects the 11-20 document");

            doc.write2File(sm_dirTestDataTemp + "metadataMap.jdf", 2, false);
        }
コード例 #22
0
ファイル: JDFEvaluation.cs プロジェクト: cip4/JDFLibNet
        private bool fitsPath(KElement e, string xPath, KElement reportRoot)
        {
            bool     b       = false;
            KElement attr    = null;
            string   newPath = null;

            int posAt  = xPath.LastIndexOf("@");
            int posAtI = posAt > 0 ? xPath.LastIndexOf("[@") : -1;

            if (posAt < 0 || posAt == posAtI + 1) // element
            {
                KElement pathElement = e.getXPathElement(xPath);
                b = fitsValue(pathElement);
                if (b)
                {
                    if (reportRoot != null)
                    {
                        if (pathElement != null)
                        {
                            newPath = pathElement.buildXPath(null, 1);
                        }
                        attr = reportRoot.appendElement("TestedElement");
                        attr.setAttribute("Name", StringUtil.token(xPath, -1, "/"));
                    }
                }
            }
            else
            // attribute
            {
                string attrVal = e.getXPathAttribute(xPath, null);
                b = fitsValue(attrVal);
                string   attName     = xPath.Substring(posAt + 1);
                KElement pathElement = e.getXPathElement(xPath.Substring(0, posAt));

                if (pathElement is JDFResource)
                {
                    JDFResource r    = (JDFResource)pathElement;
                    JDFResource root = r.getResourceRoot();
                    while (r != root)
                    {
                        if (!r.hasAttribute_KElement(attName, null, false))
                        {
                            r = (JDFResource)r.getParentNode_KElement();
                        }
                        else
                        {
                            break;
                        }
                    }
                    pathElement = r;
                    newPath     = pathElement.buildXPath(null, 1) + "/@" + attName;
                }
                if (newPath != null)
                {
                    attrVal = e.getXPathAttribute(newPath, null);
                }
                b = fitsValue(attrVal);
                if (reportRoot != null)
                {
                    attr = reportRoot.appendElement("TestedAttribute");
                    attr.setAttribute("Name", attName);
                    attr.setAttribute("Value", attrVal);
                }
            }

            if (attr != null)
            {
                attr.setAttribute("XPath", newPath);
            }
            return(b);
        }
コード例 #23
0
        public virtual void testLayoutElementPositioning()
        {
            // TBD: Fuzzy, Sizes, literal text via comments
            JDFElement.setLongID(false);
            JDFDoc d = new JDFDoc("JDF");

            n = d.getJDFRoot();
            n.setType(EnumType.LayoutElementProduction);

            JDFRunList outRun = (JDFRunList)n.appendMatchingResource(ElementName.RUNLIST, EnumProcessUsage.AnyOutput, null);

            outRun.setFileURL("output.pdf");

            JDFLayoutElementProductionParams lep = (JDFLayoutElementProductionParams)n.appendMatchingResource(ElementName.LAYOUTELEMENTPRODUCTIONPARAMS, EnumProcessUsage.AnyInput, null);

            lep.appendXMLComment("This is a \"well placed\" CTM defined mark\nThe anchor defines the 0,0 point to be transformed\nThe element to be placed is referenced by LayoutElement/FileSpec/URL", null);

            JDFContentList cl = (JDFContentList)lep.appendElement(ElementName.CONTENTLIST);

            cl = (JDFContentList)cl.makeRootResource(null, null, true);
            cl.setXMLComment("this is an optional metadatapool for the content");

            JDFLayoutElementPart lePart      = addLayoutElementPart(lep, cl);
            KElement             positionObj = lePart.appendElement("PositionObject");

            positionObj.setAttribute("PageRange", "0");
            setNextAnchor(positionObj, null, "LowLeft", "0 0", null, "Parent", 0);
            positionObj.setAttribute("Anchor", "LowLeft");
            positionObj.setAttribute("PositionPolicy", "Exact");
            JDFLayoutElement bkg = (JDFLayoutElement)lePart.appendElement("LayoutElement");

            bkg.setMimeURL("bkg.pdf");

            lep.appendXMLComment("This is a \"roughly placed\" reservation in the middle of the page", null);
            lePart      = addLayoutElementPart(lep, cl);
            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("PageRange", "0");
            // TODO discuss individual positions
            setNextAnchor(positionObj, null, "Center", null, null, "Parent", 0);
            positionObj.setAttribute("Anchor", "Center");
            positionObj.setAttribute("PositionPolicy", "Free");
            string id = lePart.appendAnchor(null);

            JDFLayoutElement image = (JDFLayoutElement)lePart.appendElement("LayoutElement");

            image.setElementType(EnumElementType.Image);
            image.appendComment().setText("Please add an image of a palm tree on a beach here!");

            lep.appendXMLComment("This is a \"roughly placed\" reservation 36 points below the previous image;\n NextPosition points from Anchor on this to NextAnchor on next,\n i.e. a positive vector specifies that next is shifted in the positive direction in the parent (in this case page) coordinate system", null);
            lePart      = addLayoutElementPart(lep, cl);
            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("PageRange", "0");
            positionObj.setAttribute("Anchor", "TopCenter");
            positionObj.setAttribute("PositionPolicy", "Free");
            setNextAnchor(positionObj, id, "BottomCenter", "0 36", null, "Sibling", 0);

            image = (JDFLayoutElement)lePart.appendElement("LayoutElement");
            image.setElementType(EnumElementType.Image);
            image.appendComment().setText("Please add an image of a beach ball below the palm tree!");

            lep.appendXMLComment("This is a \"well placed\" CTM defined mark\nThe anchor defines the 0,0 point to be transformed", null);
            lePart      = addLayoutElementPart(lep, cl);
            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("PageRange", "0");
            setNextAnchor(positionObj, null, "BottomLeft", "2 3", null, "Parent", 0);
            positionObj.setAttribute("Anchor", "LowLeft");
            positionObj.setAttribute("PositionPolicy", "Exact");
            lePart.appendBarcodeProductionParams().appendXMLComment("barcode details here", null);

            lePart      = addLayoutElementPart(lep, cl);
            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("PageRange", "0");
            setNextAnchor(positionObj, null, "TopRight", null, null, "Parent", 0);
            positionObj.setAttribute("Anchor", "TopRight");
            positionObj.appendXMLComment("This is a \"roughly placed\"  mark\nThe anchor at top right is placed at the right (=1.0) top(=1.0) position of the page.\nNo rotation is specified", null);
            positionObj.setAttribute("PositionPolicy", "Exact");
            lePart.appendBarcodeProductionParams().appendXMLComment("barcode details here", null);
            lep.appendXMLComment("This is a \"roughly placed\"  container for marks\nThe anchor at top left is defined in the !Unrotated! orientation.\n It is placed at the left (=0.0) bottom(=0.0) position of the page.\nThe text flows bottom to top (=Rotate 90 = counterclockwise)\n do we need margins?", null);

            lePart = addLayoutElementPart(lep, cl);
            string idParent = lePart.appendAnchor(null);

            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("PageRange", "1");
            positionObj.setAttribute("Anchor", "TopLeft");
            positionObj.setAttribute("PositionPolicy", "Free");
            setNextAnchor(positionObj, null, "BottomCenter", "0 0", null, "Parent", 90);
            lep.appendXMLComment("This is a  barcode inside the previous container\nThe anchor at bottom left is defined in the !Unrotated! orientation.\n It is placed at the left (=0.0) bottom(=0.0) position of the container.", null);

            lePart      = addLayoutElementPart(lep, cl);
            id          = lePart.appendAnchor(null);
            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("Anchor", "BottomLeft");
            setNextAnchor(positionObj, idParent, "BottomLeft", "0 0", null, "Parent", 0);
            lePart.appendBarcodeProductionParams().appendXMLComment("barcode details here", null);
            lep.appendXMLComment("This is a disclaimer text inside the previous container\nThe anchor at top left is defined in the !Unrotated! orientation.\n The barcode and text are justified with their top margins and spaced by 72 points\n which corresponds to the left of the page because the container is rotated 90°\n" + "AbsoluteSize specifies the size of the object in points", null);

            lePart      = addLayoutElementPart(lep, cl);
            positionObj = lePart.appendElement("PositionObject");
            setNextAnchor(positionObj, id, "TopRight", "-72 0", null, "Sibling", 0);

            positionObj.setAttribute("Anchor", "TopLeft");
            // positionObj.setAttribute("ParentRef", idParent);
            positionObj.setAttribute("AbsoluteSize", "300 200");
            JDFLayoutElement text = (JDFLayoutElement)lePart.appendElement("LayoutElement");

            text.setElementType(EnumElementType.Text);
            text.setMimeURL("file://myServer/disclaimers/de/aspirin.txt");
            lep.appendXMLComment("This is a \"VERY roughly placed\" piece of text somewhere on pages 2-3\n" + "RelativeSize specifies the size of the object as a ratio of the size of the container", null);

            lePart      = addLayoutElementPart(lep, cl);
            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("PageRange", "1 ~ 2");
            positionObj.setAttribute("RelativeSize", "0.8 0.5");
            text = (JDFLayoutElement)lePart.appendElement("LayoutElement");
            text.setElementType(EnumElementType.Text);
            JDFComment instructionComment = text.appendComment();

            instructionComment.setName("Instructions");
            instructionComment.setText("Please add some text about the image of a palm tree on a beach here!");
            lep.appendXMLComment("This is another \"VERY roughly placed\" piece of text somewhere on pages 2-3; the text source is the JDF", null);

            lePart      = addLayoutElementPart(lep, cl);
            positionObj = lePart.appendElement("PositionObject");
            positionObj.setAttribute("PageRange", "1 ~ 2");
            text = (JDFLayoutElement)lePart.appendElement("LayoutElement");
            text.setElementType(EnumElementType.Text);

            JDFComment textSrc = text.appendComment();

            textSrc.setName("TextInput");
            textSrc.setText("Laurum Ipsum Blah blah blah!\n btw. this is unformatted plain text and nothing else!");

            d.write2File(sm_dirTestDataTemp + "LayoutPositionObj.jdf", 2, false);
        }
コード例 #24
0
        ///
        ///	 * <param name="testRoot"> </param>
        ///	 * <param name="testlists"> </param>
        ///	 * <param name="level"> </param>
        ///	 * <param name="mrp"> </param>
        ///	 * <param name="irp"> </param>
        ///	 * <param name="resLinkPool"> </param>
        ///	 * <param name="goodElems"> </param>
        ///	 * <param name="badElems"> </param>
        ///	 * <param name="devCaps">
        ///	 * @return </param>
        ///
        public virtual void analyzeDevCaps(KElement testRoot, EnumFitsValue testlists, EnumValidationLevel level, KElement mrp, KElement irp, SupportClass.HashSetSupport goodElems, Hashtable badElems, bool ignoreExtensions)
        {
            EnumAvailability av             = getModuleAvailability();
            KElement         xpathRoot      = testRoot;
            VElement         vElemResources = null;

            if (testRoot is JDFNode)
            {
                JDFNode jdfNode = (JDFNode)testRoot;
                vElemResources = getMatchingElementsFromNode(jdfNode);
                xpathRoot      = jdfNode.getResourceLinkPool();
                if (xpathRoot == null)
                {
                    xpathRoot = testRoot;
                }
            }
            else
            {
                vElemResources = getMatchingElementsFromJMF((JDFMessage)testRoot);
            }

            int svElemResources = vElemResources == null ? 0 : vElemResources.Count;

            EnumContext context = getContext();
            KElement    r       = null;

            if (EnumValidationLevel.isRequired(level) && svElemResources < getMinOccurs() && EnumAvailability.Installed.Equals(av))
            {
                if (EnumContext.Element.Equals(context) || EnumContext.JMF.Equals(context))
                {
                    r = mrp.appendElement("MissingElement");
                    r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName());
                }
                else
                {
                    EnumUsage linkUsage = getLinkUsage();
                    string    procUsage = getProcessUsage();
                    r = mrp.appendElement("MissingResourceLink");
                    if (linkUsage != null)
                    {
                        r.setAttribute("Usage", linkUsage.getName());
                    }
                    if (procUsage != null && procUsage.Length > 0)
                    {
                        r.setAttribute("ProcessUsage", procUsage);
                    }
                    r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName());
                }
                r.setAttribute("Name", getName());
                r.setAttribute("CapXPath", getName());
                r.setAttribute("Occurrences", svElemResources, null);
                r.setAttribute("MinOccurs", getMinOccurs(), null);
            }
            else if (svElemResources > getMaxOccurs() || !EnumAvailability.Installed.Equals(av))
            {
                if (context.Equals(EnumContext.Element) || context.Equals(EnumContext.JMF))
                {
                    r = irp.appendElement("ManyElement");
                    r.setAttribute("XPath", testRoot.buildXPath(null, 1) + "/" + getName());
                }
                else
                {
                    EnumUsage linkUsage = getLinkUsage();
                    string    procUsage = getProcessUsage();
                    r = irp.appendElement("ManyResourceLink");
                    if (linkUsage != null)
                    {
                        r.setAttribute("Usage", linkUsage.getName());
                    }

                    if (procUsage != null && procUsage.Length > 0)
                    {
                        r.setAttribute("ProcessUsage", procUsage);
                    }

                    r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName());
                }

                r.setAttribute("Name", getName());
                r.setAttribute("CapXPath", getName());
                r.setAttribute("Occurrences", svElemResources, null);
                r.setAttribute("MaxOccurs", getMaxOccurs(), null);
                r.setAttribute("Availability", av == null ? "None" : av.getName());
            }

            if (vElemResources != null)
            {
                for (int j = 0; j < svElemResources; j++)
                {
                    KElement elem = vElemResources.item(j);
                    if (!goodElems.Contains(elem))
                    {
                        KElement report = devCapReport(elem, testlists, level, ignoreExtensions, irp); // InvalidResources
                        if (report == null)
                        {
                            goodElems.Add(elem);
                            KElement badReport = (KElement)badElems[elem];
                            if (badReport != null)
                            {
                                badReport.deleteNode();
                            }
                        }
                        else
                        {
                            badElems.Add(elem, report);
                        }
                    }
                }
            }
        }
コード例 #25
0
ファイル: JDFAbstractState.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * set the default values specified in this in element
        ///	 *  </summary>
        ///	 * <param name="element">
        ///	 *            the element to set the defaults on </param>
        ///	 * <returns> true if successful </returns>
        ///
        public virtual bool setDefaultsFromCaps(KElement element, bool bAll)
        {
            string def = getAttribute(AttributeName.DEFAULTVALUE, null, null);

            if (!bAll && def == null)
            {
                return(false);
            }
            if (def == null)
            {
                def = getAttribute(AttributeName.CURRENTVALUE, null, null);
            }

            if (def == null)
            {
                def = getAttribute(AttributeName.ALLOWEDVALUELIST, null, null);
                if (def != null && (def.IndexOf("~") >= 0 || def.IndexOf(" ") >= 0)) // allowedvaluelist
                // is
                // a
                // list
                // or
                // range
                {
                    string lt = getListType().getName();
                    if (!lt.EndsWith("List") && def.IndexOf(" ") >= 0)
                    {
                        def = StringUtil.token(def, 0, " ");
                    }
                    else if (lt.IndexOf("Range") < 0 && def.IndexOf("~") >= 0)
                    {
                        def = null;
                    }
                }
                if (def == null)
                {
                    def = getXPathAttribute("Value/@AllowedValue", null);
                }
            }
            if (def == null)
            {
                if ((this is JDFIntegerState) || (this is JDFNumberState))
                {
                    def = "1";
                }
                else if (this is JDFXYPairState)
                {
                    def = "1 1";
                }
                else if (this is JDFBooleanState)
                {
                    def = "true";
                }
                else if (this is JDFMatrixState)
                {
                    def = JDFMatrix.unitMatrix.ToString();
                }
                else if (this is JDFShapeState)
                {
                    def = "1 2 3";
                }
                else if (this is JDFDateTimeState)
                {
                    def = new JDFDate().DateTimeISO;
                }
                else if (this is JDFDurationState)
                {
                    def = new JDFDuration(42).getDurationISO();
                }
                else
                {
                    def = "some_value"; // TODO add better type dependent value
                    // generator
                }
            }
            object theValue = getMatchingObjectInNode(element);

            if (theValue != null)
            {
                return(false);
            }

            string nam   = getName();
            string nsURI = getDevNS();

            if (nsURI.Equals(JDFElement.getSchemaURL()))
            {
                nsURI = null;
            }
            if (nsURI != null)
            {
                string prefix = KElement.xmlnsPrefix(nam);
                if (prefix == null)
                {
                    nam = StringUtil.token(nsURI, -1, "/") + ":" + nam;
                }
            }

            if (getListType().Equals(EnumListType.Span))
            {
                JDFIntentResource ir   = (JDFIntentResource)element;
                JDFSpanBase       span = ir.appendSpan(nam, null);
                span.setAttribute(AttributeName.PREFERRED, def);
            }
            else
            // some attribute...
            {
                element.setAttribute(nam, def, nsURI);
            }
            return(true);
        }