Package com.adobe.dp.xml.util

Examples of com.adobe.dp.xml.util.SMapImpl


      names = resourcesByName.keys();
      while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        Resource res = (Resource) resourcesByName.get(name);
        if (res instanceof FontResource) {
          SMapImpl attrs = new SMapImpl();
          ser.startElement(encns, "EncryptedData", null, true);
          ser.newLine();
          if (useIDPFFontMangling)
            attrs.put(null, "Algorithm", "http://www.idpf.org/2008/embedding");
          else
            attrs.put(null, "Algorithm", "http://ns.adobe.com/pdf/enc#RC");
          ser.startElement(encns, "EncryptionMethod", attrs, false);
          ser.endElement(encns, "EncryptionMethod");
          ser.newLine();
          ser.startElement(encns, "CipherData", null, false);
          ser.newLine();
          attrs = new SMapImpl();
          attrs.put(null, "URI", name);
          ser.startElement(encns, "CipherReference", attrs, false);
          ser.endElement(encns, "CipherReference");
          ser.newLine();
          ser.endElement(encns, "CipherData");
          ser.newLine();
          ser.endElement(encns, "EncryptedData");
          ser.newLine();
        }
      }
      ser.endElement(ocfns, "encryption");
      ser.newLine();
      ser.endDocument();
    }
    XMLSerializer ser = new XMLSerializer(container.getOutputStream("META-INF/container.xml"));
    ser.startDocument("1.0", "UTF-8");
    SMapImpl attrs = new SMapImpl();
    attrs.put(null, "version", "1.0");
    ser.startElement(ocfns, "container", attrs, true);
    ser.newLine();
    ser.startElement(ocfns, "rootfiles", null, false);
    ser.newLine();
    attrs = new SMapImpl();
    attrs.put(null, "full-path", opf.name);
    attrs.put(null, "media-type", opf.mediaType);
    ser.startElement(ocfns, "rootfile", attrs, true);
    ser.endElement(ocfns, "rootfile");
    ser.newLine();
    ser.endElement(ocfns, "rootfiles");
    ser.newLine();
View Full Code Here


        public void startDocument() throws SAXException {
        }

        public void startElement(String ns, String local, String qname, Attributes attrs) throws SAXException {
          SMapImpl smap = new SMapImpl(new SMapAttributesAdapter(attrs));
          styler.pushElement(ns, local, smap);
          BaseRule es = styler.getCascadeResult().getProperties().getPropertySet();
          smap.put(null, "style", (es.isEmpty() ? null : es.toString()));
          ser.startElement(ns, local, smap, qname.indexOf(':') < 0);
        }

        public void startPrefixMapping(String arg0, String arg1) throws SAXException {
        }
View Full Code Here

  }

  public void serialize(OutputStream out) throws IOException {
    XMLSerializer ser = new XMLSerializer(out);
    ser.startDocument("1.0", "UTF-8");
    SMapImpl nsmap = new SMapImpl();
    nsmap.put(null, "opf", opfns);
    nsmap.put(null, "dc", dcns);
    nsmap.put(null, "dcterms", dctermsns);
    nsmap.put(null, "xsi", xsins);
    ser.setPreferredPrefixMap(nsmap);
    SMapImpl attrs = new SMapImpl();
    attrs.put(null, "version", "2.0");
    attrs.put(null, "unique-identifier", "bookid");
    ser.startElement(opfns, "package", attrs, true);
    ser.newLine();
    ser.startElement(opfns, "metadata", null, false);
    ser.newLine();
    Iterator it = epub.metadata.iterator();
    int identifierCount = 0;
    while (it.hasNext()) {
      Publication.SimpleMetadata item = (Publication.SimpleMetadata) it.next();
      if (item.ns != null && item.ns.equals(dcns) && item.name.equals("identifier")) {
        //[LC] improved: added the possibility to control from the outside de UUID
        attrs =(SMapImpl) item.attribs;
        if(attrs==null){
          attrs = new SMapImpl();
         
        }
        if(attrs.get(opfns, "scheme")!=null&&attrs.get(opfns, "scheme").equals("UUID")){
          attrs.put(null, "id", (identifierCount == 0 ? "bookid" : "bookid" + identifierCount));
          identifierCount++;
        }
       
       
      } else {
        attrs = null;
      }
      String value = item.value;
      if (epub.isTranslit())
        value = Translit.translit(value);
      if (item.ns == null) {
        attrs = new SMapImpl();
        attrs.put(null, "name", item.name);
        attrs.put(null, "content", value);
        ser.startElement(opfns, "meta", attrs, false);
        ser.endElement(opfns, "meta");
        ser.newLine();
      } else {
        ser.startElement(item.ns, item.name, attrs, false);
        char[] arr = value.toCharArray();
        ser.text(arr, 0, arr.length);
        ser.endElement(item.ns, item.name);
        ser.newLine();
      }
    }
    ser.endElement(opfns, "metadata");
    ser.newLine();
    ser.startElement(opfns, "manifest", null, false);
    ser.newLine();
    it = epub.resources();
    while (it.hasNext()) {
      Resource r = (Resource) it.next();
      if (r != this) {
        attrs = new SMapImpl();
        attrs.put(null, "id", epub.assignId(r));
        attrs.put(null, "href", makeReference(r.getName(), null));
        attrs.put(null, "media-type", r.mediaType);
        ser.startElement(opfns, "item", attrs, false);
        ser.endElement(opfns, "item");
        ser.newLine();
      }
    }
    ser.endElement(opfns, "manifest");
    ser.newLine();
    attrs = new SMapImpl();
    if (epub.toc != null)
      attrs.put(null, "toc", epub.assignId(epub.toc));
    if (epub.pageMap != null)
      attrs.put(null, "page-map", epub.assignId(epub.pageMap));
    ser.startElement(opfns, "spine", attrs, false);
    ser.newLine();
    it = epub.spine();
    while (it.hasNext()) {
      Resource r = (Resource) it.next();
        //[LC] improved: added the possibility to control from the outside de UUID     
      attrs=r.getSerializationAttributes();
      if(attrs==null){
        attrs = new SMapImpl();
      }
      attrs.put(null, "idref", epub.assignId(r));
      ser.startElement(opfns, "itemref", attrs, false);
      ser.endElement(opfns, "itemref");
      ser.newLine();
    }
    ser.endElement(opfns, "spine");
View Full Code Here

  }

  public void serialize(OutputStream out) throws IOException {
    XMLSerializer ser = new XMLSerializer(out);
    ser.startDocument("1.0", "UTF-8");
    SMapImpl attrs = new SMapImpl();
    attrs.put(null, "version", "2005-1");
    String lang = epub.getDCMetadata("language");
    if (lang != null)
      attrs.put(null, "xml:lang", lang);
    ser.startElement(ncxns, "ncx", attrs, true);
    ser.newLine();
    ser.startElement(ncxns, "head", null, false);
    ser.newLine();
    attrs = new SMapImpl();
    attrs.put(null, "name", "dtb:uid");
    String uid = epub.getDCMetadata("identifier");
    if (uid == null)
      uid = "";
    attrs.put(null, "content", uid);
    ser.startElement(ncxns, "meta", attrs, false);
    ser.endElement(ncxns, "meta");
    ser.newLine();
    attrs = new SMapImpl();
    attrs.put(null, "name", "dtb:depth");
    int depth = calculateDepth(rootTOCEntry);
    attrs.put(null, "content", Integer.toString(depth));
    ser.startElement(ncxns, "meta", attrs, false);
    ser.endElement(ncxns, "meta");
    ser.newLine();
    attrs = new SMapImpl();
    attrs.put(null, "name", "dtb:totalPageNumber");
    attrs.put(null, "content", Integer.toString(pages.size()));
    ser.startElement(ncxns, "meta", attrs, false);
    ser.endElement(ncxns, "meta");
    ser.newLine();
    attrs = new SMapImpl();
    attrs.put(null, "name", "dtb:maxPageNumber");
    attrs.put(null, "content", Integer.toString(pages.size()));
    ser.startElement(ncxns, "meta", attrs, false);
    ser.endElement(ncxns, "meta");
    ser.newLine();
    ser.endElement(ncxns, "head");
    ser.newLine();
    ser.startElement(ncxns, "docTitle", null, false);
    ser.startElement(ncxns, "text", null, false);
    String title = epub.getDCMetadata("title");
    if (title == null)
      title = "";
    if (epub.isTranslit())
      title = Translit.translit(title);
    char[] arr = title.toCharArray();
    ser.text(arr, 0, arr.length);
    ser.endElement(ncxns, "text");
    ser.endElement(ncxns, "docTitle");
    ser.newLine();
    ser.startElement(ncxns, "navMap", null, false);
    ser.newLine();
    entryCount = 1;
    serializeChildEntries(rootTOCEntry, ser);
    ser.endElement(ncxns, "navMap");
    ser.newLine();
    if (pages.size() > 0) {
      ser.startElement(ncxns, "pageList", null, false);
      ser.startElement(ncxns, "navLabel", null, false);
      ser.startElement(ncxns, "text", null, false);
      ser.endElement(ncxns, "text");
      ser.endElement(ncxns, "navLabel");
      ser.newLine();
      Iterator pages = this.pages.iterator();
      int count = 1;
      while (pages.hasNext()) {
        Page page = (Page) pages.next();
        attrs = new SMapImpl();
        String countStr = Integer.toString(count++);
        attrs.put(null, "value", countStr);
        attrs.put(null, "type", "normal");
        attrs.put(null, "playOrder", Integer.toString(page.xref.getPlayOrder()));
        ser.startElement(ncxns, "pageTarget", attrs, false);
        ser.newLine();
        ser.startElement(ncxns, "navLabel", null, false);
        ser.startElement(ncxns, "text", null, false);
        char[] text = page.name.toCharArray();
        ser.text(text, 0, text.length);
        ser.endElement(ncxns, "text");
        ser.endElement(ncxns, "navLabel");
        ser.newLine();
        attrs = new SMapImpl();
        attrs.put(null, "src", page.xref.makeReference(this));
        ser.startElement(ncxns, "content", attrs, false);
        ser.endElement(ncxns, "content");
        ser.newLine();
        ser.endElement(ncxns, "pageTarget");
        ser.newLine();
View Full Code Here

  private void serializeChildEntries(TOCEntry entry, XMLSerializer ser) {
    Iterator it = entry.content();
    while (it.hasNext()) {
      TOCEntry child = (TOCEntry) it.next();
      SMapImpl attrs = new SMapImpl();
      attrs.put(null, "playOrder", Integer.toString(child.getXRef().getPlayOrder()));
      attrs.put(null, "id", "id" + entryCount);
      entryCount++;
      ser.startElement(ncxns, "navPoint", attrs, false);
      ser.newLine();
      ser.startElement(ncxns, "navLabel", null, false);
      ser.newLine();
      ser.startElement(ncxns, "text", null, false);
      String title = child.getTitle();
      if (title == null)
        title = "";
      if (epub.isTranslit())
        title = Translit.translit(title);
      char[] arr = title.toCharArray();
      ser.text(arr, 0, arr.length);
      ser.endElement(ncxns, "text");
      ser.newLine();
      ser.endElement(ncxns, "navLabel");
      ser.newLine();
      attrs = new SMapImpl();
      attrs.put(null, "src", child.getXRef().makeReference(this));
      ser.startElement(ncxns, "content", attrs, false);
      ser.endElement(ncxns, "content");
      ser.newLine();
      serializeChildEntries(child, ser);
      ser.endElement(ncxns, "navPoint");
View Full Code Here

    ser.startElement(pagemapns, "page-map", null, true);
    ser.newLine();
    Iterator pages = this.pages.iterator();
    while (pages.hasNext()) {
      Page page = (Page) pages.next();
      SMapImpl attrs = new SMapImpl();
      attrs.put(null, "name", page.name);
      attrs.put(null, "href", page.xref.makeReference(pageMap));
      ser.startElement(pagemapns, "page", attrs, false);
      ser.endElement(pagemapns, "page");
      ser.newLine();
    }
    ser.endElement(pagemapns, "page-map");
View Full Code Here

            throws XPathExpressionException {
        /**
         *
         */
        seeker.setNamespaceContext(OdtEPUBlisher.XPATH_ODT_NS_CTX);
        SMapImpl attrs = new SMapImpl();
        // AUTHOR
        MetaUserDefinedElement metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_AUTHOR_KEY + "']", odtMeta, XPathConstants.NODE);
        if (metaInfo == null) {
            metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='w2e_"
                    + JotexConstants.META_AUTHOR_KEY + "']", odtMeta, XPathConstants.NODE);
        }
        // opf:role="aut"

        if (metaInfo != null) {
            attrs.put(OPFResource.opfns, "role", "aut");
            epub.addDCMetadata("creator", metaInfo.getTextContent(), attrs);
        }

        // TITLE
        metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_TILTE_KEY + "']", odtMeta, XPathConstants.NODE);
        if (metaInfo == null) {
            metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='w2e_"
                    + JotexConstants.META_TILTE_KEY + "']", odtMeta, XPathConstants.NODE);
        }
        if (metaInfo != null) {
            epub.addDCMetadata("title", metaInfo.getTextContent(), null);
        }

        // LANGUAGE
        metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_LANGUAGE_KEY + "']", odtMeta, XPathConstants.NODE);
        if (metaInfo == null) {
            metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='w2e_"
                    + JotexConstants.META_LANGUAGE_KEY + "']", odtMeta, XPathConstants.NODE);
        }
        if (metaInfo != null) {
            epub.addDCMetadata("language", metaInfo.getTextContent(), null);
        }

        // PUBLISHER
        metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_PUBLISHER_KEY + "']", odtMeta, XPathConstants.NODE);
        if (metaInfo == null) {
            metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='w2e_"
                    + JotexConstants.META_PUBLISHER_KEY + "']", odtMeta, XPathConstants.NODE);
        }
        if (metaInfo != null) {
            epub.addDCMetadata("publisher", metaInfo.getTextContent(), null);
        }
        // PUBISHING DATE
        metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_PUBLISHING_DATE_KEY + "']", odtMeta, XPathConstants.NODE);
        if (metaInfo == null) {
            metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='w2e_"
                    + JotexConstants.META_PUBLISHING_DATE_KEY + "']", odtMeta, XPathConstants.NODE);
        }
        if (metaInfo != null) {
            attrs = new SMapImpl();
            attrs.put(OPFResource.opfns, "event", "publication");
            epub.addDCMetadata("date", metaInfo.getTextContent(), attrs);
        }
        // DESCRIPTION
        metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_DESCRITPION_KEY + "']", odtMeta, XPathConstants.NODE);
        if (metaInfo == null) {
            metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='w2e_"
                    + JotexConstants.META_DESCRITPION_KEY + "']", odtMeta, XPathConstants.NODE);
        }
        if (metaInfo != null) {
            epub.addDCMetadata("description", "<![CDATA[" + metaInfo.getTextContent() + "]]>", null);
        }
        // ISBN
        metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_ISBN_KEY + "']", odtMeta, XPathConstants.NODE);
        if (metaInfo == null) {
            metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='w2e_"
                    + JotexConstants.META_ISBN_KEY + "']", odtMeta, XPathConstants.NODE);
        }
        if (metaInfo != null) {
            attrs = new SMapImpl();
            attrs.put(OPFResource.opfns, "scheme", "ISBN");
            epub.addDCMetadata("identifier", metaInfo.getTextContent(), attrs);
        }
        // ORIGINAL TITLE
        metaInfo = (MetaUserDefinedElement) seeker.evaluate("//meta:user-defined[@meta:name='"
                + JotexConstants.META_ORIGINAL_TITLE_KEY + "']", odtMeta, XPathConstants.NODE);
View Full Code Here

TOP

Related Classes of com.adobe.dp.xml.util.SMapImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.