我想问一下,如何打印xml模式。我在运行时创建了我的xsd模式,为了进行测试,我希望看到生成的xml模式。目前,我正在使用org.apache.ws.commons.schema.XmlSchema,但是我没有找到任何可以打印xml的方法。
有人知道如何打印(System.out)我的XmlSchema吗??
发布于 2011-08-09 15:51:42
尝试:
XMLOutputter outputter = new XMLOutputter();
try {
String outputString = outputter.outputString(loXMLDoc);
} loXMLDoc是用于XML schema的Dom
发布于 2012-02-06 19:53:06
如果您使用的是XmlSchema 2.0
XmlSchema schema = ...
...
schema.write(System.out)如果您使用的是XmlSchema 1.x
XmlSchema schema = ...
...
schema.write(System.out, null)另外,如果您想要写入字符串
StringWriter schemaWriter = new StringWriter();
schema.write(schemaWriter);
String schemaString = schemaWriter.toString();https://stackoverflow.com/questions/6992974
复制相似问题