Tonny Kohar wrote:
I would like to submit enhancement for OutputManager. This patch will format the attrib to have new line on the specified
documentWidth and indent the newline according to getTabulationWidth
useful for example to format very long path element d attribute.
There is a problem here. You can't just add newlines to all attributes. For example if you add a newline in the middle of preserveAspectRatio='xMidYMid split' the result is an invalid SVG.
The only solution to this is for the OutputManager to have a list of attributes (namespace qualified) for particular elements (or elements in a particular namespace).
I attached the cvs diff -u format in this message and here is the bug(not a bug just enhancement) id # 26651
btw, there is no Transcoder group on the bugzilla under batik. So I just
put in under utilities group.
This is fine. I'll attach the above commentary to the bug report.
Regards Tonny Kohar http://www.kiyut.com
------------------------------------------------------------------------
? this.diff
Index: OutputManager.java
===================================================================
RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/transcoder/svg2svg/OutputManager.java,v
retrieving revision 1.7
diff -u -r1.7 OutputManager.java
--- OutputManager.java 8 Aug 2003 11:39:26 -0000 1.7
+++ OutputManager.java 4 Feb 2004 07:35:07 -0000
@@ -468,25 +468,11 @@
}
printCharacter('<');
printCharacters(name);
+ printCharacter(' ');
if (prettyPrinter.getFormat()) {
Iterator it = attributes.iterator();
- if (it.hasNext()) {
- AttributeInfo ai = (AttributeInfo)it.next();
-
- if (ai.isAttribute("xml:space")) {
- xmlSpace.set(0, (ai.value.equals("preserve")
- ? Boolean.TRUE
- : Boolean.FALSE));
- }
- - printCharacter(' ');
- printCharacters(ai.name);
- printCharacter('=');
- printCharacter(ai.delimiter);
- printString(ai.value);
- printCharacter(ai.delimiter);
- }
+ while (it.hasNext()) {
AttributeInfo ai = (AttributeInfo)it.next();
@@ -496,22 +482,27 @@
: Boolean.FALSE));
}
- int len = ai.name.length + ai.value.length() + 4;
- if (lineAttributes ||
- len + column > prettyPrinter.getDocumentWidth()) {
- printNewline();
- printString(margin.toString());
- for (int i = 0; i < name.length + 2; i++) {
- printCharacter(' ');
+ // patch format the attrib to have new line on the specified documentWidth
+ // and indent the newline according to getTabulationWidth
+ // useful for example to format very long path element d attribute
+ // The line break is calculated using StringTokenizer which is using word boundary
+ // as a token
+ StringBuffer sb = new StringBuffer();
+ sb.append(ai.name);
+ sb.append('=');
+ sb.append(ai.delimiter + ai.value + ai.delimiter);
+ java.util.StringTokenizer st = new java.util.StringTokenizer(sb.toString());
+ while (st.hasMoreTokens()) {
+ String str = st.nextToken();
+ if (str.length() + column > prettyPrinter.getDocumentWidth()) {
+ printNewline();
+ printString(margin.toString());
+ for(int i=0; i<prettyPrinter.getTabulationWidth(); i++) {
+ printCharacter(' ');
+ }
}
- } else {
- printCharacter(' ');
+ printString(str + ' ');
}
- printCharacters(ai.name);
- printCharacter('=');
- printCharacter(ai.delimiter);
- printString(ai.value);
- printCharacter(ai.delimiter);
}
} else {
Iterator it = attributes.iterator();
------------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]