Beispiel #1
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);
        }