Search in sources :

Example 1 with DTD

use of javax.xml.stream.events.DTD in project uPortal by Jasig.

the class StaxEventLexicalContentHandler method startDTD.

/* (non-Javadoc)
     * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
     */
@Override
public void startDTD(String name, String publicId, String systemId) throws SAXException {
    // System identifier must be specified to print DOCTYPE.
    // This method is only called if the system identifier is specified.
    // Since the HTML5 DOCTYPE declaration does not include a system
    // identifier, this code allows the static string EMPTY to serve as
    // a temporary system id for doctypes which should not have one set.
    // If public identifier is specified print 'PUBLIC
    // <public> <system>', or if a non-'EMPTY' system identifier is
    // specified, print 'SYSTEM <system>'.
    final StringBuilder dtdBuilder = new StringBuilder("<!DOCTYPE ");
    dtdBuilder.append(name);
    if (publicId != null) {
        dtdBuilder.append(" PUBLIC \"").append(publicId).append("\" \"");
        dtdBuilder.append(systemId).append("\"");
    } else if (!EMPTY_SYSTEM_IDENTIFIER.equals(systemId)) {
        dtdBuilder.append(" SYSTEM \"");
        dtdBuilder.append(systemId).append("\"");
    }
    dtdBuilder.append(">");
    final DTD event = eventFactory.createDTD(dtdBuilder.toString());
    try {
        this.consumeEvent(event);
    } catch (XMLStreamException ex) {
        throw new SAXException("Could not create DTD: " + ex.getMessage(), ex);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) DTD(javax.xml.stream.events.DTD) SAXException(org.xml.sax.SAXException)

Aggregations

XMLStreamException (javax.xml.stream.XMLStreamException)1 DTD (javax.xml.stream.events.DTD)1 SAXException (org.xml.sax.SAXException)1