本文整理汇总了Java中org.dom4j.DocumentType类的典型用法代码示例。如果您正苦于以下问题:Java DocumentType类的具体用法?Java DocumentType怎么用?Java DocumentType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentType类属于org.dom4j包,在下文中一共展示了DocumentType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SQLConfigMap
import org.dom4j.DocumentType; //导入依赖的package包/类
/**
* 合并mybatis配置文件
*/
public Document SQLConfigMap() {
Document doc = DocumentHelper.createDocument();
doc.setXMLEncoding("UTF-8");
DocumentFactory documentFactory = new DocumentFactory();
DocumentType docType = documentFactory.createDocType("configuration",
"-//mybatis.org//DTD Config 3.0//EN",
"http://mybatis.org/dtd/mybatis-3-config.dtd");
doc.setDocType(docType);
Element rootElement = doc.addElement("configuration");
rootElement.addElement("typeAliases");
rootElement.addElement("mappers");
return doc;
}
示例3: assertNodesEqual
import org.dom4j.DocumentType; //导入依赖的package包/类
public void assertNodesEqual( DocumentType o1, DocumentType o2 ) {
if ( o1 != o2 ) {
if ( o1 == null ) {
assertTrue( "Missing DocType: " + o2, false );
}
else if ( o2 == null ) {
assertTrue( "Missing DocType: " + o1, false );
}
else {
assertEquals( "DocType name equal", o1.getName(), o2.getName() );
assertEquals( "DocType publicID equal", o1.getPublicID(), o2.getPublicID() );
assertEquals( "DocType systemID equal", o1.getSystemID(), o2.getSystemID() );
}
}
}
示例4: 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;
}
示例5: getDocType
import org.dom4j.DocumentType; //导入依赖的package包/类
public DocumentType getDocType() {
return getWrapped().getDocType();
}
示例6: setDocType
import org.dom4j.DocumentType; //导入依赖的package包/类
public void setDocType(DocumentType docType) {
getWrapped().setDocType(docType);
}
示例7: writeDocType
import org.dom4j.DocumentType; //导入依赖的package包/类
protected void writeDocType(DocumentType docType) throws IOException {
if (docType != null) {
docType.write(writer);
writePrintln();
}
}
示例8: write
import org.dom4j.DocumentType; //导入依赖的package包/类
/**
* Writes the given {@link DocumentType}.
*
* @param docType
* <code>DocumentType</code> to output.
*
* @throws IOException
* DOCUMENT ME!
*/
public void write(DocumentType docType) throws IOException {
writeDocType(docType);
if (autoFlush) {
flush();
}
}
示例9: writeNode
import org.dom4j.DocumentType; //导入依赖的package包/类
protected void writeNode(Node node) throws IOException {
int nodeType = node.getNodeType();
switch (nodeType) {
case Node.ELEMENT_NODE:
writeElement((Element) node);
break;
case Node.ATTRIBUTE_NODE:
writeAttribute((Attribute) node);
break;
case Node.TEXT_NODE:
writeNodeText(node);
// write((Text) node);
break;
case Node.CDATA_SECTION_NODE:
writeCDATA(node.getText());
break;
case Node.ENTITY_REFERENCE_NODE:
writeEntity((Entity) node);
break;
case Node.PROCESSING_INSTRUCTION_NODE:
writeProcessingInstruction((ProcessingInstruction) node);
break;
case Node.COMMENT_NODE:
writeComment(node.getText());
break;
case Node.DOCUMENT_NODE:
write((Document) node);
break;
case Node.DOCUMENT_TYPE_NODE:
writeDocType((DocumentType) node);
break;
case Node.NAMESPACE_NODE:
// Will be output with attributes
// write((Namespace) node);
break;
default:
throw new IOException("Invalid node type: " + node);
}
}