Package org.w3c.dom

Examples of org.w3c.dom.DOMConfiguration


    config.setParameter("validate-if-schema", validateIfSchema);
    return parser.parse(input);
 

  public static void validate(Document d, String schema, DOMErrorHandler handler) {
    DOMConfiguration config = d.getDomConfig();
    config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema");
    config.setParameter("validate", true);
    config.setParameter("schema-location", schema);
    config.setParameter("resource-resolver", new ClasspathResourceResolver());
    config.setParameter("error-handler", handler);
    d.normalizeDocument();
  }
View Full Code Here


  public static String serialize(Document document) {
    DOMImplementationLS impl = getDOMImpl();
    LSSerializer serializer = impl.createLSSerializer();
    // document.normalizeDocument();
    DOMConfiguration config = serializer.getDomConfig();
    config.setParameter("xml-declaration", true);
    config.setParameter("format-pretty-print", true);
    LSOutput output = impl.createLSOutput();
    output.setEncoding("UTF-8");
    Writer writer = new StringWriter();
    output.setCharacterStream(writer);
    serializer.write(document, output);
View Full Code Here

            }
        });
       
       
        if (serializerParams != null) {
            DOMConfiguration serializerDOMConfig = serializer.getDomConfig();
            for (String key : serializerParams.keySet()) {
                serializerDOMConfig.setParameter(key, serializerParams.get(key));
            }
        }
       
        return serializer;
    }
View Full Code Here

    if (domImplementation.hasFeature("LS", "3.0")
        && domImplementation.hasFeature("Core", "2.0")) {
      DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation
          .getFeature("LS", "3.0");
      LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
      DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
      if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
        lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
        LSOutput lsOutput = domImplementationLS.createLSOutput();
        lsOutput.setEncoding("UTF-8");
        StringWriter stringWriter = new StringWriter();
        lsOutput.setCharacterStream(stringWriter);
View Full Code Here

        super(dbf);
    }

    protected void runTest() throws Throwable {
        Document document = dbf.newDocumentBuilder().newDocument();
        DOMConfiguration domConfig = document.getDomConfig();
        assertEquals(Boolean.FALSE, domConfig.getParameter("canonical-form"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("cdata-sections"));
        assertEquals(Boolean.FALSE, domConfig.getParameter("check-character-normalization"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("comments"));
        assertEquals(Boolean.FALSE, domConfig.getParameter("datatype-normalization"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("element-content-whitespace"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("entities"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("namespaces"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("namespace-declarations"));
        assertEquals(Boolean.FALSE, domConfig.getParameter("normalize-characters"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("split-cdata-sections"));
        assertEquals(Boolean.FALSE, domConfig.getParameter("validate"));
        assertEquals(Boolean.FALSE, domConfig.getParameter("validate-if-schema"));
        assertEquals(Boolean.TRUE, domConfig.getParameter("well-formed"));
    }
View Full Code Here

    protected void runTest() throws Throwable {
        Document document = dbf.newDocumentBuilder().newDocument();
        Element element = document.createElementNS("urn:ns", "root");
        document.appendChild(element);
        DOMConfiguration domConfig = document.getDomConfig();
        domConfig.setParameter("split-cdata-sections", Boolean.FALSE);
        domConfig.setParameter("well-formed", Boolean.FALSE);
        domConfig.setParameter("namespaces", Boolean.TRUE);
        document.normalizeDocument();
        NamedNodeMap attributes = element.getAttributes();
        assertEquals(1, attributes.getLength());
        Attr attr = (Attr)attributes.item(0);
        assertNull(attr.getPrefix());
View Full Code Here

    input.setByteStream(byteStream);

    // parse without comments and whitespace
    LSParser builder = impl.createLSParser(
        DOMImplementationLS.MODE_SYNCHRONOUS, null);
    DOMConfiguration config = builder.getDomConfig();
    config.setParameter("comments", false);
    config.setParameter("element-content-whitespace", false);

    // returns the document parsed from the input
    return builder.parse(input);
  }
View Full Code Here

      }
   }

   private static void setResourceResolver(XSLoader schemaLoader, final SchemaBindingResolver schemaResolver)
   {
      DOMConfiguration config = schemaLoader.getConfig();
      config.setParameter("resource-resolver", new LSResourceResolver()
      {
         public LSInput resolveResource(String type,
                                                       String namespaceURI,
                                                       String publicId,
                                                       String systemId,
View Full Code Here

      );
   }

   private static void setDOMErrorHandler(XSLoader schemaLoader)
   {
      DOMConfiguration config = schemaLoader.getConfig();
      config.setParameter("error-handler", XsdBinderTerminatingErrorHandler.newInstance());
   }
View Full Code Here

                // normalizations supported by DOM, this is generally not a heavy operation.
                // In particular, the Axiom implementation is not required to expand the object
                // model (including OMSourcedElements) because the Axiom builder is required to
                // perform namespace repairing, so that no modifications to unexpanded parts of
                // the message are required.
                DOMConfiguration domConfig = document.getDomConfig();
                domConfig.setParameter("split-cdata-sections", Boolean.FALSE);
                domConfig.setParameter("well-formed", Boolean.FALSE);
                domConfig.setParameter("namespaces", Boolean.TRUE);
                document.normalizeDocument();
                return document;
            }
           
            if (useDoom) {
View Full Code Here

TOP

Related Classes of org.w3c.dom.DOMConfiguration

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.