本文整理汇总了Java中org.dom4j.DocumentType.setSystemID方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentType.setSystemID方法的具体用法?Java DocumentType.setSystemID怎么用?Java DocumentType.setSystemID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.DocumentType
的用法示例。
在下文中一共展示了DocumentType.setSystemID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processModelDocType
import org.dom4j.DocumentType; //导入方法依赖的package包/类
private InputStream processModelDocType(InputStream is, String dtdSchemaUrl) throws DocumentException, IOException
{
SAXReader reader = new SAXReader();
// read document without validation
Document doc = reader.read(is);
DocumentType docType = doc.getDocType();
if (docType != null)
{
// replace DOCTYPE setting the full path to the xsd
docType.setSystemID(dtdSchemaUrl);
}
else
{
// add the DOCTYPE
docType = new DefaultDocumentType(doc.getRootElement().getName(), dtdSchemaUrl);
doc.setDocType(docType);
}
ByteArrayOutputStream fos = new ByteArrayOutputStream();
try
{
OutputFormat format = OutputFormat.createPrettyPrint(); // uses UTF-8
XMLWriter writer = new XMLWriter(fos, format);
writer.write(doc);
writer.flush();
}
finally
{
fos.close();
}
return new ByteArrayInputStream(fos.toByteArray());
}
示例2: getDocument
import org.dom4j.DocumentType; //导入方法依赖的package包/类
/**
* Get the structure as an XML Document.
*
* @return XML Document.
*/
public Document getDocument() {
final Document tmp = DocumentHelper.createDocument();
final DocumentType type = new DOMDocumentType();
type.setElementName(DOCUMENT_ROOT);
type.setSystemID(DOCUMENT_DTD);
tmp.setDocType(type);
final Element questestinterop = tmp.addElement(DOCUMENT_ROOT);
this.assessment.addToElement(questestinterop);
return tmp;
}