Example usage for org.dom4j.dtd ExternalEntityDecl getPublicID

List of usage examples for org.dom4j.dtd ExternalEntityDecl getPublicID

Introduction

In this page you can find the example usage for org.dom4j.dtd ExternalEntityDecl getPublicID.

Prototype

public String getPublicID() 

Source Link

Document

Getter for property publicID.

Usage

From source file:com.cladonia.xml.XDocumentType.java

License:Open Source License

private void write(Writer writer, ExternalEntityDecl decl) throws IOException {
    String name = decl.getName();
    String publicID = decl.getPublicID();
    String systemID = decl.getSystemID();

    if (name.startsWith("%")) {
        name = "% " + name.substring(1);
    }// www.j a  va  2s  .c o m

    StringBuffer buffer = new StringBuffer("<!ENTITY ");
    buffer.append(name);
    if (publicID != null) {
        buffer.append(" PUBLIC \"");
        buffer.append(publicID);
        buffer.append("\" ");

        if (systemID != null) {
            buffer.append(" \"");
            buffer.append(systemID);
            buffer.append("\" ");
        }
    } else if (systemID != null) {
        buffer.append(" SYSTEM \"");
        buffer.append(systemID);
        buffer.append("\" ");
    }
    buffer.append(">");
    writer.write(buffer.toString());
}