Package org.dom4j

Examples of org.dom4j.QName


    return el.getStringValue();
  }

  private String loadVersion(Document xmlDoc) {
    Element el = xmlDoc.getRootElement().element(
        new QName(KEYWORD_VERSION, namespaceCP));
    if (el == null) {
      return null;
    }
    return el.getStringValue();
  }
View Full Code Here


            .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

    // Building xml
    Document xmlOutDoc = DocumentHelper.createDocument();
    // make something like <Relationships
    // xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    Namespace dfNs = Namespace.get("", PackageNamespaces.RELATIONSHIPS);
    Element root = xmlOutDoc.addElement(new QName(
        PackageRelationship.RELATIONSHIPS_TAG_NAME, dfNs));

    // <Relationship
    // TargetMode="External"
    // Id="rIdx"
View Full Code Here

            "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");

    Document doc = DocumentHelper.createDocument();
    Namespace nsWordprocessinML = new Namespace("w",
        "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
    Element elDocument = doc.addElement(new QName("document",
        nsWordprocessinML));
    Element elBody = elDocument.addElement(new QName("body",
        nsWordprocessinML));
    Element elParagraph = elBody.addElement(new QName("p",
        nsWordprocessinML));
    Element elRun = elParagraph
        .addElement(new QName("r", nsWordprocessinML));
    Element elText = elRun.addElement(new QName("t", nsWordprocessinML));
    elText.setText("Hello Open XML !");

    StreamHelper.saveXmlInStream(doc, corePart.getOutputStream());
    pkg.close();
View Full Code Here

    // Create a content
    Document doc = DocumentHelper.createDocument();
    Namespace nsWordprocessinML = new Namespace("w",
        "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
    Element elDocument = doc.addElement(new QName("document",
        nsWordprocessinML));
    Element elBody = elDocument.addElement(new QName("body",
        nsWordprocessinML));
    Element elParagraph = elBody.addElement(new QName("p",
        nsWordprocessinML));
    Element elRun = elParagraph
        .addElement(new QName("r", nsWordprocessinML));
    Element elText = elRun.addElement(new QName("t", nsWordprocessinML));
    elText.setText("Hello Open XML !");

    StreamHelper.saveXmlInStream(doc, corePart.getOutputStream());

    // Save and close
View Full Code Here

                        element.getDocument().getRootElement().add( XSD_NAMESPACE );
                        element.getDocument().getRootElement().add( XSI_NAMESPACE );

                        Element valueElement = controlElement.addElement( "controlValue" ).addText(
                            ParserUtils.base64Encode( value ) );
                        valueElement.addAttribute( new QName( "type", XSI_NAMESPACE ), ParserUtils.XSD + ":"
                            + ParserUtils.BASE64BINARY );
                    }
                    else
                    {
                        controlElement.addElement( "controlValue" ).setText( Arrays.toString( value ) );
View Full Code Here

                        element.getDocument().getRootElement().add( xsiNamespace );

                        Element valueElement = newElement.addElement( "value" ).addText(
                            ParserUtils.base64Encode( value ) );
                        valueElement
                            .addAttribute( new QName( "type", xsiNamespace ), "xsd:" + ParserUtils.BASE64BINARY );
                    }
                    else
                    {
                        newElement.addElement( "value" ).setText( value.getString() );
                    }
                }
            }
        }

        // PRESENT FILTER
        else if ( filter instanceof PresentFilter )
        {
            Element newElement = element.addElement( "present" );

            newElement.addAttribute( "name", ( ( PresentFilter ) filter ).getAttributeDescription() );
        }

        // EXTENSIBLEMATCH
        else if ( filter instanceof ExtensibleMatchFilter )
        {
            Element newElement = element.addElement( "extensibleMatch" );

            ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;

            Value<?> value = extensibleMatchFilter.getMatchValue();
            if ( value != null )
            {
                if ( ParserUtils.needsBase64Encoding( value ) )
                {
                    Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI );
                    Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI );
                    element.getDocument().getRootElement().add( xsdNamespace );
                    element.getDocument().getRootElement().add( xsiNamespace );

                    Element valueElement = newElement.addElement( "value" ).addText( ParserUtils.base64Encode( value ) );
                    valueElement.addAttribute( new QName( "type", xsiNamespace ), "xsd:" + ParserUtils.BASE64BINARY );
                }
                else
                {
                    newElement.addElement( "value" ).setText( value.getString() );
                }
View Full Code Here

    {
        // Creating the document
        Document document = DocumentHelper.createDocument();

        // Creating the root element with its namespaces definitions
        Element root = document.addElement( new QName( ServerXmlIOV155.ELEMENT_BEANS, NAMESPACE_XBEAN_SPRING ) );
        root.add( NAMESPACE_SPRINGFRAMEWORK );
        root.add( NAMESPACE_APACHEDS );

        // DefaultDirectoryService Bean
        createDefaultDirectoryServiceBean( root, ( ServerConfigurationV155 ) serverConfiguration );
View Full Code Here

        Element saslRealmsElement = ldapServerElement.addElement( ServerXmlIOV155.ELEMENT_SASL_REALMS );

        // Adding each SaslRealm item
        for ( String saslRealm : serverConfiguration.getSaslRealms() )
        {
            saslRealmsElement.addElement( new QName( ServerXmlIOV155.ELEMENT_VALUE, NAMESPACE_SPRINGFRAMEWORK ) )
                .setText( saslRealm );
        }

        // Adding 'ExtendedOperations' element
        Element extendedOperationsElement = ldapServerElement
View Full Code Here

                        element.getDocument().getRootElement().add( XSD_NAMESPACE );
                        element.getDocument().getRootElement().add( XSI_NAMESPACE );

                        Element valueElement = controlElement.addElement( "controlValue" ).addText(
                            ParserUtils.base64Encode( value ) );
                        valueElement.addAttribute( new QName( "type", XSI_NAMESPACE ), ParserUtils.XSD + ":"
                            + ParserUtils.BASE64BINARY );
                    }
                    else
                    {
                        controlElement.addElement( "controlValue" ).setText( Arrays.toString( value ) );
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.