org.w3c.dom.DocumentType#getInternalSubset ( )源码实例Demo

下面列出了org.w3c.dom.DocumentType#getInternalSubset ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mapper-generator-javafx   文件: DomWriter.java
protected void write(DocumentType node) {
    printWriter.print("<!DOCTYPE ");
    printWriter.print(node.getName());
    String publicId = node.getPublicId();
    String systemId = node.getSystemId();
    if (publicId != null) {
        printWriter.print(" PUBLIC \"");
        printWriter.print(publicId);
        printWriter.print("\" \"");
        printWriter.print(systemId);
        printWriter.print('\"');
    } else if (systemId != null) {
        printWriter.print(" SYSTEM \"");
        printWriter.print(systemId);
        printWriter.print('"');
    }

    String internalSubset = node.getInternalSubset();
    if (internalSubset != null) {
        printWriter.println(" [");
        printWriter.print(internalSubset);
        printWriter.print(']');
    }
    printWriter.println('>');
}
 
源代码2 项目: MikuMikuStudio   文件: DOMSerializer.java
private void writeDocumentType(DocumentType docType, Writer writer, int depth) throws IOException {
    String publicId = docType.getPublicId();
    String internalSubset = docType.getInternalSubset();

    for (int i = 0; i < depth; ++i) { writer.append(' '); }
    writer.append("<!DOCTYPE ").append(docType.getName());
    if (publicId != null) {
        writer.append(" PUBLIC '").append(publicId).append("' ");
    } else {
        writer.write(" SYSTEM ");
    }
    writer.append("'").append(docType.getSystemId()).append("'");
    if (internalSubset != null) {
        writer.append(" [").append(internalSubset).append("]");
    }
    writer.append('>').append(lineSeparator);
}
 
源代码3 项目: mybatis-generator-core-fix   文件: DomWriter.java
/**
 * Write.
 *
 * @param node
 *            the node
 * @throws ShellException
 *             the shell exception
 */
protected void write(DocumentType node) throws ShellException {
    printWriter.print("<!DOCTYPE "); //$NON-NLS-1$
    printWriter.print(node.getName());
    String publicId = node.getPublicId();
    String systemId = node.getSystemId();
    if (publicId != null) {
        printWriter.print(" PUBLIC \""); //$NON-NLS-1$
        printWriter.print(publicId);
        printWriter.print("\" \""); //$NON-NLS-1$
        printWriter.print(systemId);
        printWriter.print('\"');
    } else if (systemId != null) {
        printWriter.print(" SYSTEM \""); //$NON-NLS-1$
        printWriter.print(systemId);
        printWriter.print('"');
    }

    String internalSubset = node.getInternalSubset();
    if (internalSubset != null) {
        printWriter.println(" ["); //$NON-NLS-1$
        printWriter.print(internalSubset);
        printWriter.print(']');
    }
    printWriter.println('>');
}
 
源代码4 项目: mybatis-generator-plus   文件: DomWriter.java
protected void write(DocumentType node) throws ShellException {
    printWriter.print("<!DOCTYPE "); //$NON-NLS-1$
    printWriter.print(node.getName());
    String publicId = node.getPublicId();
    String systemId = node.getSystemId();
    if (publicId != null) {
        printWriter.print(" PUBLIC \""); //$NON-NLS-1$
        printWriter.print(publicId);
        printWriter.print("\" \""); //$NON-NLS-1$
        printWriter.print(systemId);
        printWriter.print('\"');
    } else if (systemId != null) {
        printWriter.print(" SYSTEM \""); //$NON-NLS-1$
        printWriter.print(systemId);
        printWriter.print('"');
    }

    String internalSubset = node.getInternalSubset();
    if (internalSubset != null) {
        printWriter.println(" ["); //$NON-NLS-1$
        printWriter.print(internalSubset);
        printWriter.print(']');
    }
    printWriter.println('>');
}
 
源代码5 项目: jdk1.8-source-analysis   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码6 项目: TencentKona-8   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码7 项目: jdk8u60   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码8 项目: JDKSourceCode1.8   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码9 项目: openjdk-jdk8u   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码11 项目: Bytecoder   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码12 项目: openjdk-jdk9   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码13 项目: hottub   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码14 项目: openjdk-8-source   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码15 项目: openjdk-8   文件: DOMResultBuilder.java
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
源代码16 项目: Bytecoder   文件: DOM3TreeWalker.java
/**
 * Serializes a Document Type Node.
 *
 * @param node The Docuemnt Type Node to serialize
 * @param bStart Invoked at the start or end of node.  Default true.
 */
protected void serializeDocType(DocumentType node, boolean bStart)
    throws SAXException {
    // The DocType and internalSubset can not be modified in DOM and is
    // considered to be well-formed as the outcome of successful parsing.
    String docTypeName = node.getNodeName();
    String publicId = node.getPublicId();
    String systemId = node.getSystemId();
    String internalSubset = node.getInternalSubset();

    //DocumentType nodes are never passed to the filter

    if (internalSubset != null && !"".equals(internalSubset)) {

        if (bStart) {
            try {
                // The Serializer does not provide a way to write out the
                // DOCTYPE internal subset via an event call, so we write it
                // out here.
                Writer writer = fSerializer.getWriter();
                StringBuffer dtd = new StringBuffer();

                dtd.append("<!DOCTYPE ");
                dtd.append(docTypeName);
                if (null != publicId) {
                    dtd.append(" PUBLIC \"");
                    dtd.append(publicId);
                    dtd.append('\"');
                }

                if (null != systemId) {
                    if (null == publicId) {
                        dtd.append(" SYSTEM \"");
                    } else {
                        dtd.append(" \"");
                    }
                    dtd.append(systemId);
                    dtd.append('\"');
                }

                dtd.append(" [ ");

                dtd.append(fNewLine);
                dtd.append(internalSubset);
                dtd.append("]>");
                dtd.append(fNewLine);

                writer.write(dtd.toString());
                writer.flush();

            } catch (IOException e) {
                throw new SAXException(Utils.messages.createMessage(
                        MsgKey.ER_WRITING_INTERNAL_SUBSET, null), e);
            }
        } // else if !bStart do nothing

    } else {

        if (bStart) {
            if (fLexicalHandler != null) {
                fLexicalHandler.startDTD(docTypeName, publicId, systemId);
            }
        } else {
            if (fLexicalHandler != null) {
                fLexicalHandler.endDTD();
            }
        }
    }
}
 
源代码17 项目: openjdk-jdk9   文件: DOM3TreeWalker.java
/**
 * Serializes a Document Type Node.
 *
 * @param node The Docuemnt Type Node to serialize
 * @param bStart Invoked at the start or end of node.  Default true.
 */
protected void serializeDocType(DocumentType node, boolean bStart)
    throws SAXException {
    // The DocType and internalSubset can not be modified in DOM and is
    // considered to be well-formed as the outcome of successful parsing.
    String docTypeName = node.getNodeName();
    String publicId = node.getPublicId();
    String systemId = node.getSystemId();
    String internalSubset = node.getInternalSubset();

    //DocumentType nodes are never passed to the filter

    if (internalSubset != null && !"".equals(internalSubset)) {

        if (bStart) {
            try {
                // The Serializer does not provide a way to write out the
                // DOCTYPE internal subset via an event call, so we write it
                // out here.
                Writer writer = fSerializer.getWriter();
                StringBuffer dtd = new StringBuffer();

                dtd.append("<!DOCTYPE ");
                dtd.append(docTypeName);
                if (null != publicId) {
                    dtd.append(" PUBLIC \"");
                    dtd.append(publicId);
                    dtd.append('\"');
                }

                if (null != systemId) {
                    if (null == publicId) {
                        dtd.append(" SYSTEM \"");
                    } else {
                        dtd.append(" \"");
                    }
                    dtd.append(systemId);
                    dtd.append('\"');
                }

                dtd.append(" [ ");

                dtd.append(fNewLine);
                dtd.append(internalSubset);
                dtd.append("]>");
                dtd.append(fNewLine);

                writer.write(dtd.toString());
                writer.flush();

            } catch (IOException e) {
                throw new SAXException(Utils.messages.createMessage(
                        MsgKey.ER_WRITING_INTERNAL_SUBSET, null), e);
            }
        } // else if !bStart do nothing

    } else {

        if (bStart) {
            if (fLexicalHandler != null) {
                fLexicalHandler.startDTD(docTypeName, publicId, systemId);
            }
        } else {
            if (fLexicalHandler != null) {
                fLexicalHandler.endDTD();
            }
        }
    }
}
 
源代码18 项目: JVoiceXML   文件: AbstractXmlDocumentType.java
/**
 * {@inheritDoc}
 */
public final String getInternalSubset() {
    final DocumentType  type = getDocumentType();
    return type.getInternalSubset();
}
 
源代码19 项目: exificient   文件: DOMWriter.java
protected void encodeChildNodes(NodeList children) throws EXIException,
		IOException {
	for (int i = 0; i < children.getLength(); i++) {
		Node n = children.item(i);
		switch (n.getNodeType()) {
		case Node.ELEMENT_NODE:
			encodeNode(n);
			break;
		case Node.ATTRIBUTE_NODE:
			break;
		case Node.TEXT_NODE:
			exiBody.encodeCharacters(new StringValue(n.getNodeValue()));
			break;
		case Node.COMMENT_NODE:
			if (preserveComments) {
				String c = n.getNodeValue();
				exiBody.encodeComment(c.toCharArray(), 0, c.length());
			}
			break;
		case Node.DOCUMENT_TYPE_NODE:
			DocumentType dt = (DocumentType) n;
			String publicID = dt.getPublicId() == null ? "" : dt
					.getPublicId();
			String systemID = dt.getSystemId() == null ? "" : dt
					.getSystemId();
			String text = dt.getInternalSubset() == null ? "" : dt
					.getInternalSubset();
			exiBody.encodeDocType(dt.getName(), publicID, systemID, text);
			break;
		case Node.ENTITY_REFERENCE_NODE:
			// checkPendingChars();
			// TODO ER
			break;
		case Node.CDATA_SECTION_NODE:
			// String cdata = n.getNodeValue();
			// exiBody.encodeCharacters(new
			// StringValue(Constants.CDATA_START
			// + cdata + Constants.CDATA_END));
			exiBody.encodeCharacters(new StringValue(n.getNodeValue()));
			break;
		case Node.PROCESSING_INSTRUCTION_NODE:
			if (preservePIs) {
				ProcessingInstruction pi = (ProcessingInstruction) n;
				exiBody.encodeProcessingInstruction(pi.getTarget(),
						pi.getData());
			}
			break;
		default:
			System.err.println("[WARNING] Unhandled DOM NodeType: "
					+ n.getNodeType());
			// throw new EXIException("Unknown NodeType? " +
			// n.getNodeType());
		}
	}
}
 
源代码20 项目: j2objc   文件: DOM3TreeWalker.java
/**
 * Serializes a Document Type Node.
 * 
 * @param node The Docuemnt Type Node to serialize
 * @param bStart Invoked at the start or end of node.  Default true. 
 */
protected void serializeDocType(DocumentType node, boolean bStart)
    throws SAXException {
    // The DocType and internalSubset can not be modified in DOM and is
    // considered to be well-formed as the outcome of successful parsing.
    String docTypeName = node.getNodeName();
    String publicId = node.getPublicId();
    String systemId = node.getSystemId();
    String internalSubset = node.getInternalSubset();

    //DocumentType nodes are never passed to the filter
    
    if (internalSubset != null && !"".equals(internalSubset)) {

        if (bStart) {
            try {
                // The Serializer does not provide a way to write out the
                // DOCTYPE internal subset via an event call, so we write it
                // out here.
                Writer writer = fSerializer.getWriter();
                StringBuffer dtd = new StringBuffer();

                dtd.append("<!DOCTYPE ");
                dtd.append(docTypeName);
                if (null != publicId) {
                    dtd.append(" PUBLIC \"");
                    dtd.append(publicId);
                    dtd.append('\"');
                }

                if (null != systemId) {
                    if (null == publicId) {
                        dtd.append(" SYSTEM \"");
                    } else {
                        dtd.append(" \"");
                    }    
                    dtd.append(systemId);
                    dtd.append('\"');
                }
                
                dtd.append(" [ ");
                
                dtd.append(fNewLine);
                dtd.append(internalSubset);
                dtd.append("]>");
                dtd.append(new String(fNewLine));
                
                writer.write(dtd.toString());
                writer.flush();
                
            } catch (IOException e) {
                throw new SAXException(Utils.messages.createMessage(
                        MsgKey.ER_WRITING_INTERNAL_SUBSET, null), e);
            }
        } // else if !bStart do nothing
        
    } else {
        
        if (bStart) {
            if (fLexicalHandler != null) {
                fLexicalHandler.startDTD(docTypeName, publicId, systemId);
            }
        } else {
            if (fLexicalHandler != null) {
                fLexicalHandler.endDTD();
            }
        }
    }
}