Package org.dom4j

Examples of org.dom4j.QName


            .equals(KEYWORD_MODIFIED)))
      throw new InvalidFormatException(
          "OPC Compliance error [M4.3]: Producers shall not create a document element that contains refinements to the Dublin Core elements, except for the two specified in the schema: <dcterms:created> and <dcterms:modified> Consumers shall consider a document element that violates this constraint to be an error.");

    // Rule M4.4
    if (el.attribute(new QName("lang", namespaceXML)) != null)
      throw new InvalidFormatException(
          "OPC Compliance error [M4.4]: Producers shall not create a document element that contains the xml:lang attribute. Consumers shall consider a document element that violates this constraint to be an error.");

    // Rule M4.5
    if (el.getNamespace().getURI().equals(
        PackageProperties.NAMESPACE_DCTERMS)) {
      // DCTerms namespace only use with 'created' and 'modified' elements
      String elName = el.getName();
      if (!(elName.equals(KEYWORD_CREATED) || elName
          .equals(KEYWORD_MODIFIED)))
        throw new InvalidFormatException("Namespace error : " + elName
            + " shouldn't have the following naemspace -> "
            + PackageProperties.NAMESPACE_DCTERMS);

      // Check for the 'xsi:type' attribute
      Attribute typeAtt = el.attribute(new QName("type", namespaceXSI));
      if (typeAtt == null)
        throw new InvalidFormatException("The element '" + elName
            + "' must have the '" + namespaceXSI.getPrefix()
            + ":type' attribute present !");
View Full Code Here


          "'part' must be a PackagePropertiesPart instance.");
    propsPart = (PackagePropertiesPart) part;

    // Configure the document
    xmlDoc = DocumentHelper.createDocument();
    Element rootElem = xmlDoc.addElement(new QName("coreProperties",
        namespaceCoreProperties));
    rootElem.addNamespace("cp", PackagePropertiesPart.NAMESPACE_CP_URI);
    rootElem.addNamespace("dc", PackagePropertiesPart.NAMESPACE_DC_URI);
    rootElem.addNamespace("dcterms",
        PackagePropertiesPart.NAMESPACE_DCTERMS_URI);
View Full Code Here

  private void addCategory() {
    if (!propsPart.getCategoryProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_CATEGORY, namespaceCoreProperties));
    if (elem == null) {
      // Missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_CATEGORY, namespaceCoreProperties));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getCategoryProperty().getValue());
  }
View Full Code Here

  private void addContentStatus() {
    if (!propsPart.getContentStatusProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_CONTENT_STATUS, namespaceCoreProperties));
    if (elem == null) {
      // Missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_CONTENT_STATUS, namespaceCoreProperties));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getContentStatusProperty().getValue());
  }
View Full Code Here

  private void addContentType() {
    if (!propsPart.getContentTypeProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_CONTENT_TYPE, namespaceCoreProperties));
    if (elem == null) {
      // Missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_CONTENT_TYPE, namespaceCoreProperties));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getContentTypeProperty().getValue());
  }
View Full Code Here

  private void addCreated() {
    if (!propsPart.getCreatedProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_CREATED, namespaceDcTerms));
    if (elem == null) {
      // missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_CREATED, namespaceDcTerms));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addAttribute(new QName("type", namespaceXSI), "dcterms:W3CDTF");
    elem.addText(propsPart.getCreatedPropertyString());
  }
View Full Code Here

  private void addCreator() {
    if (!propsPart.getCreatorProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_CREATOR, namespaceDC));
    if (elem == null) {
      // missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_CREATOR, namespaceDC));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getCreatorProperty().getValue());
  }
View Full Code Here

  private void addDescription() {
    if (!propsPart.getDescriptionProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_DESCRIPTION, namespaceDC));
    if (elem == null) {
      // missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_DESCRIPTION, namespaceDC));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getDescriptionProperty().getValue());
  }
View Full Code Here

  private void addIdentifier() {
    if (!propsPart.getIdentifierProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_IDENTIFIER, namespaceDC));
    if (elem == null) {
      // missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_IDENTIFIER, namespaceDC));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getIdentifierProperty().getValue());
  }
View Full Code Here

  private void addKeywords() {
    if (!propsPart.getKeywordsProperty().hasValue())
      return;

    Element elem = xmlDoc.getRootElement().element(
        new QName(KEYWORD_KEYWORDS, namespaceCoreProperties));
    if (elem == null) {
      // missing, we add it
      elem = xmlDoc.getRootElement().addElement(
          new QName(KEYWORD_KEYWORDS, namespaceCoreProperties));
    } else {
      elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getKeywordsProperty().getValue());
  }
View Full Code Here

TOP

Related Classes of org.dom4j.QName

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.