HTML5规范中是否存在无法使用XML库(如JAXP)创建的元素?一个示例是名为HTML实体,未在XML中定义。还有其他不相容的领域吗?
答案 0 :(得分:0)
JAXP显然只适用于格式良好的XML。在将HTML转换为JAXP的标准解析器之前,您需要将HTML转换为XHTML。
// 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]