コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #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
ファイル: 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);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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);
        }
コード例 #9
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");
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #14
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);
                        }
                    }
                }
            }
        }
コード例 #15
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);
        }
コード例 #16
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);
        }