Can I use JAXP to create HTML5 documents?

Are there HTML5 specification elements that cannot be created using an XML library such as JAXP? One example is the names of HTML objects that are not defined in XML. Are there other areas that are incompatible?

+4
source share
1 answer

JAXP apparently only works with well-formed XML. You will need to convert the HTML to XHTML before exposing it to standard JAXP parsers.

    // Create Transformer
    TransformerFactory tf = TransformerFactory.newInstance();
    StreamSource xslt = new StreamSource(
            "src/blog/jaxbsource/xslt/stylesheet.xsl");
    Transformer transformer = tf.newTransformer(xslt);

    // Source
    JAXBContext jc = JAXBContext.newInstance(Library.class);
    JAXBSource source = new JAXBSource(jc, catalog);

    // Result
    StreamResult result = new StreamResult(System.out);

    // Transform
    transformer.transform(source, result);

URL: [ https://dzone.com/articles/using-jaxb-xslt-produce-html†[1]

0
source

All Articles