Package org.w3c.dom.bootstrap

Examples of org.w3c.dom.bootstrap.DOMImplementationRegistry


        else {
            input = new LSInputImpl(schemaText);
        }

        // Uses Xerxes internal classes
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        registry.addSource(new DOMXSImplementationSourceImpl());
        Object xsImplementation = registry.getDOMImplementation("XS-Loader");
        if (xsImplementation == null) {
            throw new ConfigurationException("Failed to retrieve XS-Loader implementation from registry obtained via DOMImplementationRegistry.newInstance, please check that registry.getDOMImplementation(\"XS-Loader\") returns an instance");
        }
        if (!JavaClassHelper.isImplementsInterface(xsImplementation.getClass(), XSImplementation.class)) {
            String message = "The XS-Loader instance returned by the DOM registry class '" + xsImplementation.getClass().getName() + "' does not implement the interface '" + XSImplementation.class.getName() + "'; If you have a another Xerces distribution in your classpath please ensure the classpath order loads the JRE Xerces distribution or set the DOMImplementationRegistry.PROPERTY system property";
View Full Code Here


  private VanillaCajaHtmlParser parser;
  private VanillaCajaHtmlSerializer serializer;

  @Before
  public void setUp() throws Exception {
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    // Require the traversal API
    DOMImplementation domImpl = registry.getDOMImplementation("XML 1.0 Traversal 2.0");
    parser = new VanillaCajaHtmlParser(domImpl, true);
    serializer = new VanillaCajaHtmlSerializer();
  }
View Full Code Here

  private VanillaCajaHtmlParser parser;
  private VanillaCajaHtmlSerializer serializer;

  @Before
  public void setUp() throws Exception {
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    // Require the traversal API
    DOMImplementation domImpl = registry.getDOMImplementation("XML 1.0 Traversal 2.0");
    parser = new VanillaCajaHtmlParser(domImpl, true);
    serializer = new VanillaCajaHtmlSerializer();
  }
View Full Code Here

        }
    }

    private void generateSchema(List<XSDefinition> definitions, XSDFactory factory, List<Type> types, String ns) {
        String schema = xsdHelper.generate(types);
        DOMImplementationRegistry registry = null;
        try {
            registry = DOMImplementationRegistry.newInstance();
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
        DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
        DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
        LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
        LSInput input = ls.createLSInput();
        input.setCharacterStream(new StringReader(schema));
        Document document = parser.parse(input);
View Full Code Here

    protected String normalizeXML(String xml) throws Exception {
        // Remove all white space adjoining tags ("trim all elements")
        xml = xml.replaceAll("\\s*<", "<");
        xml = xml.replaceAll(">\\s*", ">");

        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS domLS = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSParser lsParser = domLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

        LSInput input = domLS.createLSInput();
        input.setStringData(xml);
        Document document = lsParser.parse(input);
View Full Code Here

                    schemaNode.appendChild(copyElement);
                }
            }
        }

        DOMImplementationRegistry registry;
        try {
            registry = DOMImplementationRegistry.newInstance();
        } catch (ClassCastException e) {
            String msg = e.getMessage();
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        } catch (ClassNotFoundException e) {
            String msg = e.getMessage();
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        } catch (InstantiationException e) {
            String msg = e.getMessage();
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        } catch (IllegalAccessException e) {
            String msg = e.getMessage();
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DOMImplementationLS lsImpl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer lsSerializer = lsImpl.createLSSerializer();
        LSOutput lsOutput = lsImpl.createLSOutput();
        lsOutput.setEncoding("UTF-8");
        lsOutput.setByteStream(baos);
        lsSerializer.write(document, lsOutput);
View Full Code Here

   * @return A {@link DOMImplementation} object that can be cast to
   *         {@link DOMImplementationLS}.
   */
  public static DOMImplementation getDOMImplementation() {
    try {
      DOMImplementationRegistry registry = DOMImplementationRegistry
          .newInstance();
      return registry.getDOMImplementation("Core 3.0 XML 3.0 LS");
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

  private VanillaCajaHtmlParser parser;
  private VanillaCajaHtmlSerializer serializer;

  @Before
  public void setUp() throws Exception {
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    // Require the traversal API
    DOMImplementation domImpl = registry.getDOMImplementation("XML 1.0 Traversal 2.0");
    parser = new VanillaCajaHtmlParser(domImpl, true);
    serializer = new VanillaCajaHtmlSerializer();
  }
View Full Code Here

            inputs.add(input);
        }

        System.setProperty(DOMImplementationRegistry.PROPERTY,
                           "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();

        XSImplementation impl = (XSImplementation)registry.getDOMImplementation("XS-Loader");

        XSLoader schemaLoader = impl.createXSLoader(null);
        schemaLoader.getConfig().setParameter("validate", Boolean.TRUE);
        schemaLoader.getConfig().setParameter("error-handler", new DOMErrorHandler() {
View Full Code Here

    byte[] getNodeBytes(Node node)
        throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException {

        //This is also a hack, the JDK should already have this set, but it doesn't
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        if (registry == null) {
            System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
            registry = DOMImplementationRegistry.newInstance();
        }
        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        if (impl == null) {
            System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
            registry = DOMImplementationRegistry.newInstance();
            impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        }
        LSOutput output = impl.createLSOutput();
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        output.setByteStream(bout);
        LSSerializer writer = impl.createLSSerializer();
View Full Code Here

TOP

Related Classes of org.w3c.dom.bootstrap.DOMImplementationRegistry

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.