本文整理汇总了Java中org.w3c.dom.Document.setXmlVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Document.setXmlVersion方法的具体用法?Java Document.setXmlVersion怎么用?Java Document.setXmlVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Document
的用法示例。
在下文中一共展示了Document.setXmlVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveXMLDoctoFile
import org.w3c.dom.Document; //导入方法依赖的package包/类
public static void saveXMLDoctoFile(Document doc, DocumentType documentType, String path)
throws TransformerException {
// Save DOM XML doc to File
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
doc.setXmlVersion("1.0");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, documentType.getPublicId());
transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, documentType.getSystemId());
transformer.transform(new DOMSource(doc), new StreamResult(new File(path)));
}
示例2: buildDocument
import org.w3c.dom.Document; //导入方法依赖的package包/类
public Document buildDocument(){
Document doc=null;
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder=factory.newDocumentBuilder();
doc=builder.newDocument();
doc.setXmlVersion("1.0");
Element processDefinition=this.graphData.parseModel(doc);
for(AbstractNodeElement node:this.graphData.getNodes()){
processDefinition.appendChild(node.parseModel(doc));
}
doc.appendChild(processDefinition);
} catch (Exception e) {
e.printStackTrace();
}
return doc;
}
示例3: exportGrammar
import org.w3c.dom.Document; //导入方法依赖的package包/类
public static Document exportGrammar(RCG g, Map<String, TagTree> dict){
dictionary = dict;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder constructor = factory.newDocumentBuilder();
Document rcggrammar = constructor.newDocument();
rcggrammar.setXmlVersion("1.0");
rcggrammar.setXmlStandalone(true);
Element root = rcggrammar.createElement("rcg");
String label = "";
PredLabel p = g.getStartPredicateLabel();
if (p instanceof PredStringLabel) {
label = p.toString();
} else if (p instanceof PredComplexLabel) {
label = ((PredComplexLabel) p).getComplexLabel();
}
root.setAttribute("start", label);
List<Clause> clauses = g.getClauses();
for(int i = 0 ; i < clauses.size() ; i++) {
RCGDOMbuilder.exportClause(root, clauses.get(i), null, rcggrammar);
}
// finally we do not forget the root
rcggrammar.appendChild(root);
return rcggrammar;
} catch (ParserConfigurationException e) {
System.err.println(e);
//System.err.println(e.getStackTrace());
return null;
}
}