Search in sources :

Example 11 with DOMImplementationRegistry

use of org.w3c.dom.bootstrap.DOMImplementationRegistry in project wildfly by wildfly.

the class DOMImplementationRegistryTestCase method testDOMImplementationRegistry.

@Test
@Ignore("[WFLY-4416] Cannot obtain DOMImplementationRegistry instance")
public void testDOMImplementationRegistry() throws Exception {
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementation domImpl = registry.getDOMImplementation("LS 3.0");
    Assert.assertNotNull("DOMImplementation not null", domImpl);
}
Also used : DOMImplementationRegistry(org.w3c.dom.bootstrap.DOMImplementationRegistry) DOMImplementation(org.w3c.dom.DOMImplementation) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with DOMImplementationRegistry

use of org.w3c.dom.bootstrap.DOMImplementationRegistry in project ACS by ACS-Community.

the class HibernateWDALImpl method initializeParser.

private void initializeParser() throws RuntimeException {
    try {
        System.setProperty(DOMImplementationRegistry.PROPERTY, "org.apache.xerces.dom.DOMImplementationSourceImpl");
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        domImplementationLS = (DOMImplementationLS) registry.getDOMImplementation("LS");
        parser = domImplementationLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, "http://www.w3.org/2001/XMLSchema");
        //parser.getDomConfig().setParameter("http://apache.org/xml/features/xinclude", Boolean.TRUE);
        schemaResourceResolverLoader = new SchemaResourceResolverLoader(null, domImplementationLS, m_logger);
        parser.getDomConfig().setParameter("resource-resolver", schemaResourceResolverLoader);
        parser.getDomConfig().setParameter("http://apache.org/xml/features/validation/schema", Boolean.TRUE);
        parser.getDomConfig().setParameter("error-handler", new DOMErrorHandler() {

            public boolean handleError(DOMError error) {
                //((Exception) error.getRelatedException()).printStackTrace();
                throw new LSException(LSException.PARSE_ERR, error.getMessage());
            }
        });
        input = domImplementationLS.createLSInput();
        output = domImplementationLS.createLSOutput();
        // SAX parser (non-validating)
        SAXParserFactory factory = SAXParserFactory.newInstance();
        saxParser = factory.newSAXParser();
    } catch (Throwable th) {
        throw new RuntimeException("Failed to initialize parser.", th);
    }
}
Also used : DOMErrorHandler(org.w3c.dom.DOMErrorHandler) DOMError(org.w3c.dom.DOMError) DOMImplementationRegistry(org.w3c.dom.bootstrap.DOMImplementationRegistry) LSException(org.w3c.dom.ls.LSException) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 13 with DOMImplementationRegistry

use of org.w3c.dom.bootstrap.DOMImplementationRegistry in project jdk8u_jdk by JetBrains.

the class MergeStdCommentTest method main.

public static void main(String[] args) throws Exception {
    String format = "javax_imageio_1.0";
    BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
    ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
    IIOMetadata meta = iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
    DOMImplementationRegistry registry;
    registry = DOMImplementationRegistry.newInstance();
    DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
    Document doc = impl.createDocument(null, format, null);
    Element root, text, entry;
    root = doc.getDocumentElement();
    root.appendChild(text = doc.createElement("Text"));
    text.appendChild(entry = doc.createElement("TextEntry"));
    // keyword isn't #REQUIRED by the standard metadata format.
    // However, it is required by the PNG format, so we include it here.
    entry.setAttribute("keyword", "Comment");
    entry.setAttribute("value", "Some demo comment");
    meta.mergeTree(format, root);
}
Also used : IIOMetadata(javax.imageio.metadata.IIOMetadata) Element(org.w3c.dom.Element) ImageWriter(javax.imageio.ImageWriter) DOMImplementationRegistry(org.w3c.dom.bootstrap.DOMImplementationRegistry) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document) BufferedImage(java.awt.image.BufferedImage) ImageTypeSpecifier(javax.imageio.ImageTypeSpecifier)

Aggregations

DOMImplementationRegistry (org.w3c.dom.bootstrap.DOMImplementationRegistry)13 DOMImplementationLS (org.w3c.dom.ls.DOMImplementationLS)7 DOMImplementation (org.w3c.dom.DOMImplementation)6 Document (org.w3c.dom.Document)5 LSSerializer (org.w3c.dom.ls.LSSerializer)5 LSOutput (org.w3c.dom.ls.LSOutput)4 DOMError (org.w3c.dom.DOMError)3 DOMErrorHandler (org.w3c.dom.DOMErrorHandler)3 Element (org.w3c.dom.Element)3 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ImageTypeSpecifier (javax.imageio.ImageTypeSpecifier)2 ImageWriter (javax.imageio.ImageWriter)2 IIOMetadata (javax.imageio.metadata.IIOMetadata)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 DOMConfiguration (org.w3c.dom.DOMConfiguration)2 Node (org.w3c.dom.Node)2 LSInput (org.w3c.dom.ls.LSInput)2