Exemplo n.º 1
0
 /* 483:    */
 /* 484:    */ protected AttributesImpl startPrefixMapping(
     Element element, NamespaceStack namespaceStack)
     /* 485:    */ throws SAXException
       /* 486:    */ {
   /* 487:754 */ AttributesImpl namespaceAttributes = null;
   /* 488:    */
   /* 489:    */
   /* 490:757 */ Namespace elementNamespace = element.getNamespace();
   /* 491:759 */ if ((elementNamespace != null)
       && (!isIgnoreableNamespace(elementNamespace, namespaceStack)))
   /* 492:    */ {
     /* 493:761 */ namespaceStack.push(elementNamespace);
     /* 494:762 */ this.contentHandler.startPrefixMapping(
         elementNamespace.getPrefix(), elementNamespace.getURI());
     /* 495:    */
     /* 496:764 */ namespaceAttributes =
         addNamespaceAttribute(namespaceAttributes, elementNamespace);
     /* 497:    */ }
   /* 498:768 */ List declaredNamespaces = element.declaredNamespaces();
   /* 499:    */
   /* 500:770 */ int i = 0;
   /* 501:770 */ for (int size = declaredNamespaces.size(); i < size; i++)
   /* 502:    */ {
     /* 503:771 */ Namespace namespace = (Namespace) declaredNamespaces.get(i);
     /* 504:773 */ if (!isIgnoreableNamespace(namespace, namespaceStack))
     /* 505:    */ {
       /* 506:774 */ namespaceStack.push(namespace);
       /* 507:775 */ this.contentHandler.startPrefixMapping(
           namespace.getPrefix(), namespace.getURI());
       /* 508:    */
       /* 509:777 */ namespaceAttributes = addNamespaceAttribute(namespaceAttributes, namespace);
       /* 510:    */ }
     /* 511:    */ }
   /* 512:782 */ return namespaceAttributes;
   /* 513:    */ }
Exemplo n.º 2
0
 private static Map<String, String> initPrefixUriMap(Map<String, Namespace> prefixNamespaceMap) {
   Map<String, String> prefixUriMap = new HashMap<String, String>();
   for (Namespace ns : prefixNamespaceMap.values()) {
     prefixUriMap.put(ns.getPrefix(), ns.getURI());
   }
   return Collections.unmodifiableMap(prefixUriMap);
 }
Exemplo n.º 3
0
 /* 514:    */
 /* 515:    */ protected void endPrefixMapping(NamespaceStack stack, int stackSize)
     /* 516:    */ throws SAXException
       /* 517:    */ {
   /* 518:799 */ while (stack.size() > stackSize)
   /* 519:    */ {
     /* 520:800 */ Namespace namespace = stack.pop();
     /* 521:802 */ if (namespace != null) {
       /* 522:803 */ this.contentHandler.endPrefixMapping(namespace.getPrefix());
       /* 523:    */ }
     /* 524:    */ }
   /* 525:    */ }
Exemplo n.º 4
0
  /**
   * Writes the attributes of the given element
   *
   * @param element DOCUMENT ME!
   * @throws IOException DOCUMENT ME!
   */
  protected void writeAttributes(Element element) throws IOException {
    // I do not yet handle the case where the same prefix maps to
    // two different URIs. For attributes on the same element
    // this is illegal; but as yet we don't throw an exception
    // if someone tries to do this
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
      Attribute attribute = element.attribute(i);
      Namespace ns = attribute.getNamespace();

      if ((ns != null) && (ns != Namespace.NO_NAMESPACE) && (ns != Namespace.XML_NAMESPACE)) {
        String prefix = ns.getPrefix();
        String uri = namespaceStack.getURI(prefix);

        if (!ns.getURI().equals(uri)) {
          writeNamespace(ns);
          namespaceStack.push(ns);
        }
      }

      // If the attribute is a namespace declaration, check if we have
      // already written that declaration elsewhere (if that's the case,
      // it must be in the namespace stack
      String attName = attribute.getName();

      if (attName.startsWith("xmlns:")) {
        String prefix = attName.substring(6);

        if (namespaceStack.getNamespaceForPrefix(prefix) == null) {
          String uri = attribute.getValue();
          namespaceStack.push(prefix, uri);
          writeNamespace(prefix, uri);
        }
      } else if (attName.equals("xmlns")) {
        if (namespaceStack.getDefaultNamespace() == null) {
          String uri = attribute.getValue();
          namespaceStack.push(null, uri);
          writeNamespace(null, uri);
        }
      } else {
        char quote = format.getAttributeQuoteCharacter();
        writer.write(" ");
        writer.write(attribute.getQualifiedName());
        writer.write("=");
        writer.write(quote);
        writeEscapeAttributeEntities(attribute.getValue());
        writer.write(quote);
      }
    }
  }
  /**
   * Creates a document for the preservation action plan.
   *
   * @return the document
   */
  private Document createPapDoc() {
    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement(new QName("preservationActionPlan", platoNS));

    root.add(xsi);
    root.add(platoNS);
    root.addAttribute(
        xsi.getPrefix() + ":schemaLocation",
        PlanXMLConstants.PLATO_NS + " " + PlanXMLConstants.PAP_SCHEMA);

    // Set version of corresponding schema
    root.addAttribute("version", "1.0");

    return doc;
  }
Exemplo n.º 6
0
 /* 553:    */
 /* 554:    */ protected AttributesImpl addNamespaceAttribute(
     AttributesImpl attrs, Namespace namespace)
       /* 555:    */ {
   /* 556:852 */ if (this.declareNamespaceAttributes)
   /* 557:    */ {
     /* 558:853 */ if (attrs == null) {
       /* 559:854 */ attrs = new AttributesImpl();
       /* 560:    */ }
     /* 561:857 */ String prefix = namespace.getPrefix();
     /* 562:858 */ String qualifiedName = "xmlns";
     /* 563:860 */ if ((prefix != null) && (prefix.length() > 0)) {
       /* 564:861 */ qualifiedName = "xmlns:" + prefix;
       /* 565:    */ }
     /* 566:864 */ String uri = "";
     /* 567:865 */ String localName = prefix;
     /* 568:866 */ String type = "CDATA";
     /* 569:867 */ String value = namespace.getURI();
     /* 570:    */
     /* 571:869 */ attrs.addAttribute(uri, localName, qualifiedName, type, value);
     /* 572:    */ }
   /* 573:872 */ return attrs;
   /* 574:    */ }
Exemplo n.º 7
0
 String getTargetNamespacePrefix() {
   return targetNamespace.getPrefix();
 }
Exemplo n.º 8
0
  static {
    prefixNamespaceMap.put(foxml.getPrefix(), foxml);
    prefixNamespaceMap.put(fedora.getPrefix(), fedora);
    prefixNamespaceMap.put(fedora_model.getPrefix(), fedora_model);
    prefixNamespaceMap.put(kramerius.getPrefix(), kramerius);
    prefixNamespaceMap.put(mods.getPrefix(), mods);
    prefixNamespaceMap.put(xsi.getPrefix(), xsi);
    prefixNamespaceMap.put(rdf.getPrefix(), rdf);
    prefixNamespaceMap.put(dc.getPrefix(), dc);
    prefixNamespaceMap.put(oai_dc.getPrefix(), oai_dc);
    prefixNamespaceMap.put(tei.getPrefix(), tei);
    prefixNamespaceMap.put(oai.getPrefix(), oai);
    prefixNamespaceMap.put(adm.getPrefix(), adm);

    unmodifiablePrefixUriMap = initPrefixUriMap(prefixNamespaceMap);
  }
Exemplo n.º 9
0
 protected void writeNamespace(Namespace namespace) throws IOException {
   if (namespace != null) {
     writeNamespace(namespace.getPrefix(), namespace.getURI());
   }
 }