You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2003/05/13 16:28:32 UTC
cvs commit: xml-xerces/java/src/org/apache/xml/serialize XMLSerializer.java XML11Serializer.java
elena 2003/05/13 07:28:32
Modified: java/src/org/apache/xml/serialize XMLSerializer.java
XML11Serializer.java
Log:
The predefined entity quot should only be used in attribute values.
It should not be used in character data. Applying patch thanks to Ias (
iasandcb@apache-korea.org)
Revision Changes Path
1.50 +12 -14 xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java
Index: XMLSerializer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- XMLSerializer.java 24 Mar 2003 20:32:30 -0000 1.49
+++ XMLSerializer.java 13 May 2003 14:28:32 -0000 1.50
@@ -1248,24 +1248,24 @@
}
continue;
}
- printXMLChar(ch);
+ printXMLChar(ch, false);
}
}
-
// note that this "int" should, in all cases, be a char.
- protected void printXMLChar( int ch ) throws IOException {
-
+ // if printing out attribute values, the double quotes mark is converted to
+ // quot, otherwise keep quotations as is.
+ protected void printXMLChar( int ch, boolean keepQuot) throws IOException {
+
if ( ch == '<') {
_printer.printText("<");
} else if (ch == '&') {
_printer.printText("&");
- } else if ( ch == '"') {
- // REVISIT: for character data we should not convert this into
- // char reference
+ } else if ( ch == '"' && ! keepQuot) {
_printer.printText(""");
} else if ( ( ch >= ' ' && _encodingInfo.isPrintable((char)ch)) ||
ch == '\n' || ch == '\r' || ch == '\t' ) {
+ // REVISIT: new line characters must be escaped
_printer.printText((char)ch);
} else {
// The character is not printable, print as character reference.
@@ -1275,8 +1275,6 @@
}
}
-
-
protected void printText( String text, boolean preserveSpace, boolean unescaped )
throws IOException {
int index;
@@ -1301,7 +1299,7 @@
if ( unescaped ) {
_printer.printText( ch );
} else
- printXMLChar( ch );
+ printXMLChar( ch, true );
}
} else {
// Not preserving spaces: print one part at a time, and
@@ -1325,7 +1323,7 @@
else if ( unescaped )
_printer.printText( ch );
else
- printXMLChar( ch );
+ printXMLChar( ch, true);
}
}
}
@@ -1357,7 +1355,7 @@
if ( unescaped )
_printer.printText( ch );
else
- printXMLChar( ch );
+ printXMLChar( ch, true );
}
} else {
// Not preserving spaces: print one part at a time, and
@@ -1383,7 +1381,7 @@
else if ( unescaped )
_printer.printText( ch );
else
- printXMLChar( ch );
+ printXMLChar( ch, true );
}
}
}
1.3 +8 -10 xml-xerces/java/src/org/apache/xml/serialize/XML11Serializer.java
Index: XML11Serializer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/XML11Serializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XML11Serializer.java 13 May 2003 13:23:49 -0000 1.2
+++ XML11Serializer.java 13 May 2003 14:28:32 -0000 1.3
@@ -311,7 +311,7 @@
}
continue;
}
- printXMLChar(ch);
+ printXMLChar(ch, false);
}
}
@@ -376,15 +376,13 @@
// note that this "int" should, in all cases, be a char.
// REVISIT: make it a char...
- protected final void printXMLChar( int ch ) throws IOException {
+ protected final void printXMLChar( int ch, boolean keepQuot ) throws IOException {
if ( ch == '<') {
_printer.printText("<");
} else if (ch == '&') {
_printer.printText("&");
- } else if ( ch == '"') {
- // REVISIT: for character data we should not convert this into
- // char reference
+ } else if ( ch == '"' && !keepQuot) {
_printer.printText(""");
} else if ( _encodingInfo.isPrintable((char)ch) && XML11Char.isXML11ValidLiteral(ch)) {
_printer.printText((char)ch);
@@ -454,7 +452,7 @@
if ( unescaped && XML11Char.isXML11ValidLiteral(ch)) {
_printer.printText( ch );
} else
- printXMLChar( ch );
+ printXMLChar( ch, true );
}
} else {
// Not preserving spaces: print one part at a time, and
@@ -478,7 +476,7 @@
else if ( unescaped && XML11Char.isXML11ValidLiteral(ch) )
_printer.printText( ch );
else
- printXMLChar( ch );
+ printXMLChar( ch, true);
}
}
}
@@ -510,7 +508,7 @@
if ( unescaped && XML11Char.isXML11ValidLiteral(ch))
_printer.printText( ch );
else
- printXMLChar( ch );
+ printXMLChar( ch, true );
}
} else {
// Not preserving spaces: print one part at a time, and
@@ -536,7 +534,7 @@
else if ( unescaped && XML11Char.isXML11ValidLiteral(ch))
_printer.printText( ch );
else
- printXMLChar( ch );
+ printXMLChar( ch, true );
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org