in batik-transcoder/src/main/java/org/apache/batik/transcoder/svg2svg/PrettyPrinter.java [1374:1533]
protected void printEntityDeclaration()
throws TranscoderException,
XMLException,
IOException {
writer.write("<!ENTITY");
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
writer.write(getCurrentValue());
type = scanner.next();
boolean pe = false;
switch (type) {
default:
throw fatalError("xml", null);
case LexicalUnits.NAME:
writer.write(getCurrentValue());
type = scanner.next();
break;
case LexicalUnits.PERCENT:
pe = true;
writer.write('%');
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
writer.write(getCurrentValue());
type = scanner.next();
if (type != LexicalUnits.NAME) {
throw fatalError("name", null);
}
writer.write(getCurrentValue());
type = scanner.next();
}
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
writer.write(getCurrentValue());
type = scanner.next();
switch (type) {
case LexicalUnits.STRING:
case LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT:
char sd = scanner.getStringDelimiter();
writer.write(sd);
loop: for (;;) {
switch (type) {
case LexicalUnits.STRING:
case LexicalUnits.ATTRIBUTE_FRAGMENT:
case LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT:
case LexicalUnits.LAST_ATTRIBUTE_FRAGMENT:
writer.write(getCurrentValue());
break;
case LexicalUnits.ENTITY_REFERENCE:
writer.write('&');
writer.write(getCurrentValue());
writer.write(';');
break;
case LexicalUnits.PARAMETER_ENTITY_REFERENCE:
writer.write('&');
writer.write(getCurrentValue());
writer.write(';');
break;
default:
break loop;
}
type = scanner.next();
}
writer.write(sd);
if (type == LexicalUnits.S) {
writer.write(getCurrentValue());
type = scanner.next();
}
if (type != LexicalUnits.END_CHAR) {
throw fatalError("end", null);
}
writer.write(">");
type = scanner.next();
return;
case LexicalUnits.PUBLIC_IDENTIFIER:
writer.write("PUBLIC");
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
type = scanner.next();
if (type != LexicalUnits.STRING) {
throw fatalError("string", null);
}
writer.write(" \"");
writer.write(getCurrentValue());
writer.write("\" \"");
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
type = scanner.next();
if (type != LexicalUnits.STRING) {
throw fatalError("string", null);
}
writer.write(getCurrentValue());
writer.write('"');
break;
case LexicalUnits.SYSTEM_IDENTIFIER:
writer.write("SYSTEM");
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
type = scanner.next();
if (type != LexicalUnits.STRING) {
throw fatalError("string", null);
}
writer.write(" \"");
writer.write(getCurrentValue());
writer.write('"');
}
type = scanner.next();
if (type == LexicalUnits.S) {
writer.write(getCurrentValue());
type = scanner.next();
if (!pe && type == LexicalUnits.NDATA_IDENTIFIER) {
writer.write("NDATA");
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
writer.write(getCurrentValue());
type = scanner.next();
if (type != LexicalUnits.NAME) {
throw fatalError("name", null);
}
writer.write(getCurrentValue());
type = scanner.next();
}
if (type == LexicalUnits.S) {
writer.write(getCurrentValue());
type = scanner.next();
}
}
if (type != LexicalUnits.END_CHAR) {
throw fatalError("end", null);
}
writer.write('>');
type = scanner.next();
}