in batik-transcoder/src/main/java/org/apache/batik/transcoder/svg2svg/PrettyPrinter.java [1122:1369]
protected void printAttlist()
throws TranscoderException,
XMLException,
IOException {
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
char[] space = getCurrentValue();
type = scanner.next();
if (type != LexicalUnits.NAME) {
throw fatalError("name", null);
}
char[] name = getCurrentValue();
type = scanner.next();
output.printAttlistStart(space, name);
while (type == LexicalUnits.S) {
space = getCurrentValue();
type = scanner.next();
if (type != LexicalUnits.NAME) {
break;
}
name = getCurrentValue();
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
char[] space2 = getCurrentValue();
type = scanner.next();
output.printAttName(space, name, space2);
switch (type) {
case LexicalUnits.CDATA_IDENTIFIER:
case LexicalUnits.ID_IDENTIFIER:
case LexicalUnits.IDREF_IDENTIFIER:
case LexicalUnits.IDREFS_IDENTIFIER:
case LexicalUnits.ENTITY_IDENTIFIER:
case LexicalUnits.ENTITIES_IDENTIFIER:
case LexicalUnits.NMTOKEN_IDENTIFIER:
case LexicalUnits.NMTOKENS_IDENTIFIER:
output.printCharacters(getCurrentValue());
type = scanner.next();
break;
case LexicalUnits.NOTATION_IDENTIFIER:
output.printCharacters(getCurrentValue());
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
output.printSpaces(getCurrentValue(), false);
type = scanner.next();
if (type != LexicalUnits.LEFT_BRACE) {
throw fatalError("left.brace", null);
}
type = scanner.next();
List names = new LinkedList();
space = null;
if (type == LexicalUnits.S) {
space = getCurrentValue();
type = scanner.next();
}
if (type != LexicalUnits.NAME) {
throw fatalError("name", null);
}
name = getCurrentValue();
type = scanner.next();
space2 = null;
if (type == LexicalUnits.S) {
space2 = getCurrentValue();
type = scanner.next();
}
names.add(new OutputManager.NameInfo(space, name, space2));
loop: for (;;) {
switch (type) {
default:
break loop;
case LexicalUnits.PIPE:
type = scanner.next();
space = null;
if (type == LexicalUnits.S) {
space = getCurrentValue();
type = scanner.next();
}
if (type != LexicalUnits.NAME) {
throw fatalError("name", null);
}
name = getCurrentValue();
type = scanner.next();
space2 = null;
if (type == LexicalUnits.S) {
space2 = getCurrentValue();
type = scanner.next();
}
names.add(new OutputManager.NameInfo(space, name, space2));
}
}
if (type != LexicalUnits.RIGHT_BRACE) {
throw fatalError("right.brace", null);
}
output.printEnumeration(names);
type = scanner.next();
break;
case LexicalUnits.LEFT_BRACE:
type = scanner.next();
names = new LinkedList();
space = null;
if (type == LexicalUnits.S) {
space = getCurrentValue();
type = scanner.next();
}
if (type != LexicalUnits.NMTOKEN) {
throw fatalError("nmtoken", null);
}
name = getCurrentValue();
type = scanner.next();
space2 = null;
if (type == LexicalUnits.S) {
space2 = getCurrentValue();
type = scanner.next();
}
names.add(new OutputManager.NameInfo(space, name, space2));
loop: for (;;) {
switch (type) {
default:
break loop;
case LexicalUnits.PIPE:
type = scanner.next();
space = null;
if (type == LexicalUnits.S) {
space = getCurrentValue();
type = scanner.next();
}
if (type != LexicalUnits.NMTOKEN) {
throw fatalError("nmtoken", null);
}
name = getCurrentValue();
type = scanner.next();
space2 = null;
if (type == LexicalUnits.S) {
space2 = getCurrentValue();
type = scanner.next();
}
names.add(new OutputManager.NameInfo(space, name, space2));
}
}
if (type != LexicalUnits.RIGHT_BRACE) {
throw fatalError("right.brace", null);
}
output.printEnumeration(names);
type = scanner.next();
}
if (type == LexicalUnits.S) {
output.printSpaces(getCurrentValue(), true);
type = scanner.next();
}
switch (type) {
default:
throw fatalError("default.decl", null);
case LexicalUnits.REQUIRED_IDENTIFIER:
case LexicalUnits.IMPLIED_IDENTIFIER:
output.printCharacters(getCurrentValue());
type = scanner.next();
break;
case LexicalUnits.FIXED_IDENTIFIER:
output.printCharacters(getCurrentValue());
type = scanner.next();
if (type != LexicalUnits.S) {
throw fatalError("space", null);
}
output.printSpaces(getCurrentValue(), false);
type = scanner.next();
if (type != LexicalUnits.STRING &&
type != LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT) {
throw fatalError("space", null);
}
case LexicalUnits.STRING:
case LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT:
output.printCharacter(scanner.getStringDelimiter());
output.printCharacters(getCurrentValue());
loop: for (;;) {
type = scanner.next();
switch (type) {
case LexicalUnits.STRING:
case LexicalUnits.ATTRIBUTE_FRAGMENT:
case LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT:
case LexicalUnits.LAST_ATTRIBUTE_FRAGMENT:
output.printCharacters(getCurrentValue());
break;
case LexicalUnits.CHARACTER_REFERENCE:
output.printString("&#");
output.printCharacters(getCurrentValue());
output.printCharacter(';');
break;
case LexicalUnits.ENTITY_REFERENCE:
output.printCharacter('&');
output.printCharacters(getCurrentValue());
output.printCharacter(';');
break;
default:
break loop;
}
}
output.printCharacter(scanner.getStringDelimiter());
}
space = null;
}
if (type != LexicalUnits.END_CHAR) {
throw fatalError("end", null);
}
output.printAttlistEnd(space);
type = scanner.next();
}