Java 类org.dom4j.DocumentType 实例源码

项目:alfresco-repository    文件:PermissionModel.java   
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());
}
项目:TJWmybatis    文件:MySQLSessionFactoryBean.java   
/**
 * 合并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;
}
项目:dls-repository-stack    文件:AbstractTestCase.java   
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() );
        }
    }
}
项目:dls-repository-stack    文件:AbstractTestCase.java   
public void assertNodesEqual( Node n1, Node n2 ) {
    int nodeType1 = n1.getNodeType();
    int nodeType2 = n2.getNodeType();
    assertTrue( "Nodes are of same type: ", nodeType1 == nodeType2 );

    switch (nodeType1) {
        case Node.ELEMENT_NODE:
            assertNodesEqual((Element) n1, (Element) n2);
            break;
        case Node.DOCUMENT_NODE:
            assertNodesEqual((Document) n1, (Document) n2);
            break;
        case Node.ATTRIBUTE_NODE:
            assertNodesEqual((Attribute) n1, (Attribute) n2);
            break;
        case Node.TEXT_NODE:
            assertNodesEqual((Text) n1, (Text) n2);
            break;
        case Node.CDATA_SECTION_NODE:
            assertNodesEqual((CDATA) n1, (CDATA) n2);
            break;
        case Node.ENTITY_REFERENCE_NODE:
            assertNodesEqual((Entity) n1, (Entity) n2);
            break;
        case Node.PROCESSING_INSTRUCTION_NODE:
            assertNodesEqual((ProcessingInstruction) n1, (ProcessingInstruction) n2);
            break;
        case Node.COMMENT_NODE:
            assertNodesEqual((Comment) n1, (Comment) n2);
            break;
        case Node.DOCUMENT_TYPE_NODE:
            assertNodesEqual((DocumentType) n1, (DocumentType) n2);
            break;
        case Node.NAMESPACE_NODE:
            assertNodesEqual((Namespace) n1, (Namespace) n2);
            break;
        default:
            assertTrue( "Invalid node types. node1: " + n1 + " and node2: " + n2, false );
    }
}
项目:olat    文件:QTIDocument.java   
/**
 * 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;
}
项目:olat    文件:QTIDocument.java   
/**
 * 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;
}
项目:community-edition-old    文件:PermissionModel.java   
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());
}
项目:gitplex-mit    文件:VersionedDocument.java   
public DocumentType getDocType() {
    return getWrapped().getDocType();
}
项目:gitplex-mit    文件:VersionedDocument.java   
public void setDocType(DocumentType docType) {
    getWrapped().setDocType(docType);
}
项目:Gargoyle    文件:XMLAttibuteFormatWriter.java   
protected void writeDocType(DocumentType docType) throws IOException {
    if (docType != null) {
        docType.write(writer);
        writePrintln();
    }
}
项目:Gargoyle    文件:XMLAttibuteFormatWriter.java   
/**
 * 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();
    }
}
项目:Gargoyle    文件:XMLAttibuteFormatWriter.java   
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);
    }
}