Package org.w3c.dom

Examples of org.w3c.dom.DOMConfiguration


    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


      return buf;
   }

   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, String baseURI)
         {
            if (Constants.NS_XML_SCHEMA.equals(type))
            {
View Full Code Here

      );
   }

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

    }

    private static Document parse(LSInput input, boolean validateIfSchema) {
        DOMImplementationLS impl = getDOMImpl();
        LSParser parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
        DOMConfiguration config = parser.getDomConfig();
        config.setParameter("element-content-whitespace", false);
        config.setParameter("namespaces", true);
        config.setParameter("validate-if-schema", validateIfSchema);
        return parser.parse(input);
    }
View Full Code Here

        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

/* 455 */     return buf;
/*     */   }
/*     */
/*     */   private static void setResourceResolver(XSLoader schemaLoader, SchemaBindingResolver schemaResolver)
/*     */   {
/* 460 */     DOMConfiguration config = schemaLoader.getConfig();
/* 461 */     config.setParameter("resource-resolver", new LSResourceResolver(schemaResolver)
/*     */     {
/*     */       public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI)
/*     */       {
/* 465 */         if ("http://www.w3.org/2001/XMLSchema".equals(type))
/*     */         {
View Full Code Here

/*     */     });
/*     */   }
/*     */
/*     */   private static void setDOMErrorHandler(XSLoader schemaLoader)
/*     */   {
/* 478 */     DOMConfiguration config = schemaLoader.getConfig();
/* 479 */     DOMErrorHandler errorHandler = (DOMErrorHandler)config.getParameter("error-handler");
/* 480 */     if (errorHandler == null)
/*     */     {
/* 482 */       config.setParameter("error-handler", XsdBinderTerminatingErrorHandler.newInstance());
/*     */     }
/*     */   }
View Full Code Here

                (DOMImplementationLS)registry.getDOMImplementation("LS");

            // create DOMBuilder
            builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
           
            DOMConfiguration config = builder.getDomConfig();

            // create Error Handler
            DOMErrorHandler errorHandler = new DOM3();
           
            // create filter
            LSParserFilter filter = new DOM3();
           
            builder.setFilter(filter);

            // set error handler
            config.setParameter("error-handler", errorHandler);


            // set validation feature
            //config.setParameter("validate", Boolean.FALSE);
            config.setParameter("validate",Boolean.TRUE);
           
            // set schema language
            config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema");
            //config.setParameter("psvi",Boolean.TRUE);
            //config.setParameter("schema-type","http://www.w3.org/TR/REC-xml");
           
            // set schema location
            config.setParameter("schema-location","personal.xsd");
           
            // parse document
            System.out.println("Parsing "+argv[0]+"...");
            Document doc = builder.parseURI(argv[0]);

            // set error handler on the Document
            config = doc.getDomConfig();
           
            config.setParameter("error-handler", errorHandler);

            // set validation feature
            config.setParameter("validate", Boolean.TRUE);
            config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema");
            //config.setParameter("schema-type","http://www.w3.org/TR/REC-xml");
            config.setParameter("schema-location","data/personal.xsd");
           
            // remove comments from the document
            config.setParameter("comments", Boolean.FALSE);

            System.out.println("Normalizing document... ");
            doc.normalizeDocument();


            // create DOMWriter
            LSSerializer domWriter = impl.createLSSerializer();
           
            System.out.println("Serializing document... ");
            config = domWriter.getDomConfig();
            config.setParameter("xml-declaration", Boolean.FALSE);
            //config.setParameter("validate",errorHandler);

            // serialize document to standard output
            //domWriter.writeNode(System.out, doc);
            LSOutput dOut = impl.createLSOutput();
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

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.