Example usage for org.dom4j.dtd ExternalEntityDecl getName

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

Introduction

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

Prototype

public String getName() 

Source Link

Document

Getter for property name.

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);
    }//from   w w w. jav a  2  s  . c  om

    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());
}