@@ -829,25 +829,23 @@ public String format(int indent) {
829829 // least the Giants are getting blown out by the Falcons.
830830
831831 final String decl = "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>" ;
832-
833- // needed for splitting or when adding decl below?
834- //System.getProperty("line.separator")
832+ final String sep = System .getProperty ("line.separator" );
835833
836834 StringWriter tempWriter = new StringWriter ();
837835 StreamResult tempResult = new StreamResult (tempWriter );
838836 transformer .transform (new DOMSource (node ), tempResult );
839- String [] tempLines = PApplet .split (tempWriter .toString (), '\n' );
840- PApplet .println (tempLines );
841- if (tempLines [0 ].startsWith (decl )) {
837+ String [] tempLines = PApplet .split (tempWriter .toString (), sep );
838+ // PApplet.println(tempLines);
839+ if (tempLines [0 ].startsWith ("<?xml" )) {
842840 // Remove XML declaration from the top before slamming into one line
843841 int declEnd = tempLines [0 ].indexOf ("?>" ) + 2 ;
844842 //if (tempLines[0].length() == decl.length()) {
845843 if (tempLines [0 ].length () == declEnd ) {
846844 // If it's all the XML declaration, remove it
847- PApplet .println ("removing first line" );
845+ // PApplet.println("removing first line");
848846 tempLines = PApplet .subset (tempLines , 1 );
849847 } else {
850- PApplet .println ("removing part of first line" );
848+ // PApplet.println("removing part of first line");
851849 // If the first node has been moved to this line, be more careful
852850 //tempLines[0] = tempLines[0].substring(decl.length());
853851 tempLines [0 ] = tempLines [0 ].substring (declEnd );
@@ -866,7 +864,7 @@ public String format(int indent) {
866864// DOMSource source = new DOMSource(node);
867865 Source source = new StreamSource (new StringReader (singleLine ));
868866 transformer .transform (source , xmlOutput );
869- return decl + " \n " + stringWriter .toString ();
867+ return decl + sep + stringWriter .toString ();
870868// return xmlOutput.getWriter().toString();
871869
872870 } catch (Exception e ) {
0 commit comments