2
我想問一下,如何打印XML模式。我在運行時創建我的xsd模式並進行測試,我希望看到生成的xml模式。目前我與org.apache.ws.commons.schema.XmlSchema
工作,我找不到任何東西可以打印XML模式。如何打印XML模式
有沒有人知道如何打印出我的XmlSchema
我想問一下,如何打印XML模式。我在運行時創建我的xsd模式並進行測試,我希望看到生成的xml模式。目前我與org.apache.ws.commons.schema.XmlSchema
工作,我找不到任何東西可以打印XML模式。如何打印XML模式
有沒有人知道如何打印出我的XmlSchema
嘗試:
XMLOutputter outputter = new XMLOutputter();
try {
String outputString = outputter.outputString(loXMLDoc);
}
loXMLDoc是大教堂的XML模式
如果你如果你正在使用的XmlSchema 1.x的
XmlSchema schema = ...
...
schema.write(System.out, null)
使用的XmlSchema 2.0
XmlSchema schema = ...
...
schema.write(System.out)
另外,如果你要寫入字符串
StringWriter schemaWriter = new StringWriter();
schema.write(schemaWriter);
String schemaString = schemaWriter.toString();
可能會使用一個漂亮的格式: 的XMLOutputter輸出器=新的XMLOutputter(Format.getPrettyFormat()); –
我不知道我怎麼樣,我沒有看到org.apache.ws.commons.schema.XmlSchema中的方法寫(OutputStream)。這種方法正是我需要的。 ** xmlSchema.write(System.out); ** – moohkooh