本文整理匯總了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;
}
}