本文整理汇总了Java中com.sun.xml.internal.fastinfoset.Decoder类的典型用法代码示例。如果您正苦于以下问题:Java Decoder类的具体用法?Java Decoder怎么用?Java Decoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Decoder类属于com.sun.xml.internal.fastinfoset包,在下文中一共展示了Decoder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parse
import com.sun.xml.internal.fastinfoset.Decoder; //导入依赖的package包/类
public void parse(InputStream document, OutputStream events, String workingDirectory) throws Exception {
if (!document.markSupported()) {
document = new BufferedInputStream(document);
}
document.mark(4);
boolean isFastInfosetDocument = Decoder.isFastInfosetDocument(document);
document.reset();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
DOMResult dr = new DOMResult();
if (isFastInfosetDocument) {
t.transform(new FastInfosetSource(document), dr);
} else if (workingDirectory != null) {
SAXParser parser = getParser();
XMLReader reader = parser.getXMLReader();
reader.setEntityResolver(createRelativePathResolver(workingDirectory));
SAXSource source = new SAXSource(reader, new InputSource(document));
t.transform(source, dr);
} else {
t.transform(new StreamSource(document), dr);
}
SAXEventSerializer ses = new SAXEventSerializer(events);
t.transform(new DOMSource(dr.getNode()), new SAXResult(ses));
}
开发者ID:campolake,项目名称:openjdk9,代码行数:30,代码来源:FI_SAX_Or_XML_SAX_DOM_SAX_SAXEvent.java
示例2: parse
import com.sun.xml.internal.fastinfoset.Decoder; //导入依赖的package包/类
public void parse(InputStream document, OutputStream events, String workingDirectory) throws Exception {
if (!document.markSupported()) {
document = new BufferedInputStream(document);
}
document.mark(4);
boolean isFastInfosetDocument = Decoder.isFastInfosetDocument(document);
document.reset();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document d;
if (isFastInfosetDocument) {
d = db.newDocument();
DOMDocumentParser ddp = new DOMDocumentParser();
ddp.parse(d, document);
} else {
if (workingDirectory != null) {
db.setEntityResolver(createRelativePathResolver(workingDirectory));
}
d = db.parse(document);
}
SAXEventSerializer ses = new SAXEventSerializer(events);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.transform(new DOMSource(d), new SAXResult(ses));
}
开发者ID:campolake,项目名称:openjdk9,代码行数:32,代码来源:FI_DOM_Or_XML_DOM_SAX_SAXEvent.java
注:本文中的com.sun.xml.internal.fastinfoset.Decoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论