You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2006/10/16 05:22:38 UTC
svn commit: r464369 - in /xerces/java/trunk/src/org/apache/xml/serialize:
BaseMarkupSerializer.java XML11Serializer.java XMLSerializer.java
Author: mrglavas
Date: Sun Oct 15 20:22:35 2006
New Revision: 464369
URL: http://svn.apache.org/viewvc?view=rev&rev=464369
Log:
JIRA Issue #1197:
http://issues.apache.org/jira/browse/XERCESJ-1197
Various code cleanup. Patch thanks to Nathan Beyer.
Modified:
xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java
xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java
xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java
Modified: xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java?view=diff&rev=464369&r1=464368&r2=464369
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java (original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java Sun Oct 15 20:22:35 2006
@@ -51,18 +51,15 @@
import org.apache.xerces.dom.DOMLocatorImpl;
import org.apache.xerces.dom.DOMMessageFormatter;
import org.apache.xerces.util.XMLChar;
-import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.DOMError;
+import org.w3c.dom.DOMErrorHandler;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.DocumentType;
-import org.w3c.dom.DOMError;
-import org.w3c.dom.DOMErrorHandler;
import org.w3c.dom.Element;
-import org.w3c.dom.Entity;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-import org.w3c.dom.Notation;
import org.w3c.dom.ls.LSException;
+import org.w3c.dom.ls.LSSerializer;
import org.w3c.dom.ls.LSSerializerFilter;
import org.w3c.dom.traversal.NodeFilter;
import org.xml.sax.ContentHandler;
@@ -509,19 +506,19 @@
surrogates(ch, chars[index], true);
}
else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
- } else {
- if ( ( ch >= ' ' && _encodingInfo.isPrintable((char)ch) && ch != 0xF7 ) ||
- ch == '\n' || ch == '\r' || ch == '\t' ) {
- _printer.printText((char)ch);
- } else {
- // The character is not printable -- split CDATA section
- _printer.printText("]]>&#x");
- _printer.printText(Integer.toHexString(ch));
- _printer.printText(";<![CDATA[");
- }
+ }
+ if ( ( ch >= ' ' && _encodingInfo.isPrintable(ch) && ch != 0xF7 ) ||
+ ch == '\n' || ch == '\r' || ch == '\t' ) {
+ _printer.printText(ch);
+ }
+ else {
+ // The character is not printable -- split CDATA section
+ _printer.printText("]]>&#x");
+ _printer.printText(Integer.toHexString(ch));
+ _printer.printText(";<![CDATA[");
}
}
_printer.setNextIndent( saveIndent );
@@ -1170,18 +1167,12 @@
}
case Node.DOCUMENT_NODE : {
DocumentType docType;
- DOMImplementation domImpl;
- NamedNodeMap map;
- Entity entity;
- Notation notation;
- int i;
// If there is a document type, use the SAX events to
// serialize it.
docType = ( (Document) node ).getDoctype();
if (docType != null) {
// DOM Level 2 (or higher)
- domImpl = ( (Document) node ).getImplementation();
try {
String internal;
@@ -1252,7 +1243,7 @@
* state with <tt>empty</tt> and <tt>afterElement</tt> set to false.
*
* @return The current element state
- * @throws IOException An I/O exception occured while
+ * @throws IOException An I/O exception occurred while
* serializing
*/
protected ElementState content()
@@ -1309,9 +1300,6 @@
// state) or whether we are inside a CDATA section or entity.
if ( state.inCData || state.doCData ) {
- int index;
- int saveIndent;
-
// Print a CDATA section. The text is not escaped, but ']]>'
// appearing in the code must be identified and dealt with.
// The contents of a text node is considered space preserving.
@@ -1319,7 +1307,7 @@
_printer.printText("<![CDATA[");
state.inCData = true;
}
- saveIndent = _printer.getNextIndent();
+ int saveIndent = _printer.getNextIndent();
_printer.setNextIndent( 0 );
printCDATAText( text);
_printer.setNextIndent( saveIndent );
@@ -1421,13 +1409,11 @@
modifyDOMError(msg, DOMError.SEVERITY_FATAL_ERROR, "wf-invalid-character", fCurrentNode);
fDOMErrorHandler.handleError(fDOMError);
throw new LSException(LSException.SERIALIZE_ERR, msg);
- }
- else {
- // issue error
- modifyDOMError(msg, DOMError.SEVERITY_ERROR, "cdata-section-not-splitted", fCurrentNode);
- if (!fDOMErrorHandler.handleError(fDOMError)) {
- throw new LSException(LSException.SERIALIZE_ERR, msg);
- }
+ }
+ // issue error
+ modifyDOMError(msg, DOMError.SEVERITY_ERROR, "cdata-section-not-splitted", fCurrentNode);
+ if (!fDOMErrorHandler.handleError(fDOMError)) {
+ throw new LSException(LSException.SERIALIZE_ERR, msg);
}
} else {
// issue warning
@@ -1455,20 +1441,20 @@
surrogates(ch, text.charAt(index), true);
}
else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
- } else {
- if ( ( ch >= ' ' && _encodingInfo.isPrintable((char)ch) && ch != 0xF7 ) ||
- ch == '\n' || ch == '\r' || ch == '\t' ) {
- _printer.printText((char)ch);
- } else {
+ }
+ if ( ( ch >= ' ' && _encodingInfo.isPrintable(ch) && ch != 0xF7 ) ||
+ ch == '\n' || ch == '\r' || ch == '\t' ) {
+ _printer.printText(ch);
+ }
+ else {
- // The character is not printable -- split CDATA section
- _printer.printText("]]>&#x");
- _printer.printText(Integer.toHexString(ch));
- _printer.printText(";<![CDATA[");
- }
+ // The character is not printable -- split CDATA section
+ _printer.printText("]]>&#x");
+ _printer.printText(Integer.toHexString(ch));
+ _printer.printText(";<![CDATA[");
}
}
}
@@ -1522,8 +1508,6 @@
boolean preserveSpace, boolean unescaped )
throws IOException
{
- int index;
- char ch;
if ( preserveSpace ) {
// Preserving spaces: the text must print exactly as it is,
@@ -1531,12 +1515,14 @@
// consolidating spaces. If a line terminator is used, a line
// break will occur.
while ( length-- > 0 ) {
- ch = chars[ start ];
+ char ch = chars[ start ];
++start;
- if ( ch == '\n' || ch == '\r' || unescaped )
+ if ( ch == '\n' || ch == '\r' || unescaped ) {
_printer.printText( ch );
- else
+ }
+ else {
printEscaped( ch );
+ }
}
} else {
// Not preserving spaces: print one part at a time, and
@@ -1545,14 +1531,17 @@
// by printing mechanism. Line terminator is treated
// no different than other text part.
while ( length-- > 0 ) {
- ch = chars[ start ];
+ char ch = chars[ start ];
++start;
- if ( ch == ' ' || ch == '\f' || ch == '\t' || ch == '\n' || ch == '\r' )
+ if ( ch == ' ' || ch == '\f' || ch == '\t' || ch == '\n' || ch == '\r' ) {
_printer.printSpace();
- else if ( unescaped )
+ }
+ else if ( unescaped ) {
_printer.printText( ch );
- else
+ }
+ else {
printEscaped( ch );
+ }
}
}
}
@@ -1584,12 +1573,15 @@
// no different than other text part.
for ( index = 0 ; index < text.length() ; ++index ) {
ch = text.charAt( index );
- if ( ch == ' ' || ch == '\f' || ch == '\t' || ch == '\n' || ch == '\r' )
+ if ( ch == ' ' || ch == '\f' || ch == '\t' || ch == '\n' || ch == '\r' ) {
_printer.printSpace();
- else if ( unescaped )
+ }
+ else if ( unescaped ) {
_printer.printText( ch );
- else
+ }
+ else {
printEscaped( ch );
+ }
}
}
}
@@ -1753,14 +1745,13 @@
{
if ( _elementStateCount > 0 ) {
/*Corrected by David Blondeau (blondeau@intalio.com)*/
- _prefixes = null;
- //_prefixes = _elementStates[ _elementStateCount ].prefixes;
+ _prefixes = null;
+ //_prefixes = _elementStates[ _elementStateCount ].prefixes;
-- _elementStateCount;
return _elementStates[ _elementStateCount ];
- } else {
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.SERIALIZER_DOMAIN, "Internal", null);
- throw new IllegalStateException(msg);
}
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.SERIALIZER_DOMAIN, "Internal", null);
+ throw new IllegalStateException(msg);
}
@@ -1771,8 +1762,7 @@
*
* @return True if in the state of the document
*/
- protected boolean isDocumentState()
- {
+ protected boolean isDocumentState() {
return _elementStateCount == 0;
}
@@ -1798,15 +1788,14 @@
if ( prefix != null )
return prefix;
}
- if ( _elementStateCount == 0 )
+ if ( _elementStateCount == 0 ) {
return null;
- else {
- for ( int i = _elementStateCount ; i > 0 ; --i ) {
- if ( _elementStates[ i ].prefixes != null ) {
- prefix = (String) _elementStates[ i ].prefixes.get( namespaceURI );
- if ( prefix != null )
- return prefix;
- }
+ }
+ for ( int i = _elementStateCount ; i > 0 ; --i ) {
+ if ( _elementStates[ i ].prefixes != null ) {
+ prefix = (String) _elementStates[ i ].prefixes.get( namespaceURI );
+ if ( prefix != null )
+ return prefix;
}
}
return null;
Modified: xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java?view=diff&rev=464369&r1=464368&r2=464369
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java (original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java Sun Oct 15 20:22:35 2006
@@ -35,13 +35,13 @@
import java.io.Writer;
import org.apache.xerces.dom.DOMMessageFormatter;
-import org.apache.xerces.impl.Constants;
import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.XML11Char;
import org.apache.xerces.util.XMLChar;
-import org.xml.sax.SAXException;
import org.w3c.dom.DOMError;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
/**
* Implements an XML serializer supporting both DOM and SAX pretty
@@ -75,7 +75,7 @@
* @version $Revision$ $Date$
* @see Serializer
*/
-public class XML11Serializer
+public class XML11Serializer
extends XMLSerializer {
//
@@ -116,10 +116,6 @@
*/
protected boolean fNamespaces = false;
-
- private boolean fPreserveSpace;
-
-
/**
* Constructs a new serializer. The serializer cannot be used without
* calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
@@ -214,23 +210,24 @@
surrogates(ch, chars[index], true);
}
else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
- } else {
- if ( _encodingInfo.isPrintable((char)ch) && XML11Char.isXML11ValidLiteral(ch)) {
- _printer.printText((char)ch);
- } else {
- // The character is not printable -- split CDATA section
- _printer.printText("]]>&#x");
- _printer.printText(Integer.toHexString(ch));
- _printer.printText(";<![CDATA[");
- }
+ }
+ if ( _encodingInfo.isPrintable(ch) && XML11Char.isXML11ValidLiteral(ch)) {
+ _printer.printText(ch);
+ }
+ else {
+ // The character is not printable -- split CDATA section
+ _printer.printText("]]>&#x");
+ _printer.printText(Integer.toHexString(ch));
+ _printer.printText(";<![CDATA[");
}
}
_printer.setNextIndent( saveIndent );
- } else {
+ }
+ else {
int saveIndent;
@@ -243,16 +240,17 @@
_printer.setNextIndent( 0 );
printText( chars, start, length, true, state.unescaped );
_printer.setNextIndent( saveIndent );
- } else {
+ }
+ else {
printText( chars, start, length, false, state.unescaped );
}
}
- } catch ( IOException except ) {
+ }
+ catch ( IOException except ) {
throw new SAXException( except );
}
}
-
//
// overwrite printing functions to make sure serializer prints out valid XML
//
@@ -263,24 +261,30 @@
if (!XML11Char.isXML11Valid(ch)) {
if (++i <length) {
surrogates(ch, source.charAt(i), false);
- } else {
+ }
+ else {
fatalError("The character '"+(char)ch+"' is an invalid XML character");
}
continue;
}
- if (ch == '\n' || ch == '\r' || ch == '\t' || ch == 0x0085 || ch == 0x2028){
- printHex(ch);
- } else if (ch == '<') {
- _printer.printText("<");
- } else if (ch == '&') {
- _printer.printText("&");
- } else if (ch == '"') {
- _printer.printText(""");
- } else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) {
- _printer.printText((char) ch);
- } else {
- printHex(ch);
- }
+ if (ch == '\n' || ch == '\r' || ch == '\t' || ch == 0x0085 || ch == 0x2028) {
+ printHex(ch);
+ }
+ else if (ch == '<') {
+ _printer.printText("<");
+ }
+ else if (ch == '&') {
+ _printer.printText("&");
+ }
+ else if (ch == '"') {
+ _printer.printText(""");
+ }
+ else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) {
+ _printer.printText((char) ch);
+ }
+ else {
+ printHex(ch);
+ }
}
}
@@ -339,52 +343,50 @@
// check if it is surrogate
if (++index < length) {
surrogates(ch, text.charAt(index), true);
- } else {
- fatalError(
- "The character '"
- + (char) ch
- + "' is an invalid XML character");
+ }
+ else {
+ fatalError("The character '" + ch + "' is an invalid XML character");
}
continue;
- } else {
- if (_encodingInfo.isPrintable((char) ch)
- && XML11Char.isXML11ValidLiteral(ch)) {
- _printer.printText((char) ch);
- } else {
-
- // The character is not printable -- split CDATA section
- _printer.printText("]]>&#x");
- _printer.printText(Integer.toHexString(ch));
- _printer.printText(";<![CDATA[");
- }
+ }
+ if (_encodingInfo.isPrintable(ch)
+ && XML11Char.isXML11ValidLiteral(ch)) {
+ _printer.printText(ch);
+ }
+ else {
+ // The character is not printable -- split CDATA section
+ _printer.printText("]]>&#x");
+ _printer.printText(Integer.toHexString(ch));
+ _printer.printText(";<![CDATA[");
}
}
}
-
// note that this "int" should, in all cases, be a char.
// REVISIT: make it a char...
protected final void printXMLChar( int ch ) throws IOException {
-
- if (ch == '\r' || ch == 0x0085 || ch == 0x2028) {
- printHex(ch);
- } else if ( ch == '<') {
+ if (ch == '\r' || ch == 0x0085 || ch == 0x2028) {
+ printHex(ch);
+ }
+ else if ( ch == '<') {
_printer.printText("<");
- } else if (ch == '&') {
+ }
+ else if (ch == '&') {
_printer.printText("&");
- } else if (ch == '>'){
- // character sequence "]]>" can't appear in content, therefore
- // we should escape '>'
- _printer.printText(">");
- } else if ( _encodingInfo.isPrintable((char)ch) && XML11Char.isXML11ValidLiteral(ch)) {
+ }
+ else if (ch == '>'){
+ // character sequence "]]>" can't appear in content, therefore
+ // we should escape '>'
+ _printer.printText(">");
+ }
+ else if ( _encodingInfo.isPrintable((char)ch) && XML11Char.isXML11ValidLiteral(ch)) {
_printer.printText((char)ch);
- } else {
- printHex(ch);
+ }
+ else {
+ printHex(ch);
}
}
-
-
protected final void surrogates(int high, int low, boolean inContent) throws IOException{
if (XMLChar.isHighSurrogate(high)) {
if (!XMLChar.isLowSurrogate(low)) {
@@ -408,13 +410,13 @@
}
}
}
- } else {
+ }
+ else {
fatalError("The character '"+(char)high+"' is an invalid XML character");
}
}
-
protected void printText( String text, boolean preserveSpace, boolean unescaped )
throws IOException {
int index;
@@ -432,16 +434,19 @@
if (++index <length) {
surrogates(ch, text.charAt(index), true);
} else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
if ( unescaped && XML11Char.isXML11ValidLiteral(ch)) {
_printer.printText( ch );
- } else
+ }
+ else {
printXMLChar( ch );
+ }
}
- } else {
+ }
+ else {
// Not preserving spaces: print one part at a time, and
// use spaces between parts to break them into different
// lines. Spaces at beginning of line will be stripped
@@ -454,25 +459,22 @@
if (++index <length) {
surrogates(ch, text.charAt(index), true);
} else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
-
- if ( unescaped && XML11Char.isXML11ValidLiteral(ch) )
+ if ( unescaped && XML11Char.isXML11ValidLiteral(ch) ) {
_printer.printText( ch );
- else
- printXMLChar( ch);
+ }
+ else {
+ printXMLChar( ch );
+ }
}
}
}
-
-
protected void printText( char[] chars, int start, int length,
boolean preserveSpace, boolean unescaped ) throws IOException {
- int index;
- char ch;
if ( preserveSpace ) {
// Preserving spaces: the text must print exactly as it is,
@@ -480,56 +482,54 @@
// consolidating spaces. If a line terminator is used, a line
// break will occur.
while ( length-- > 0 ) {
- ch = chars[start++];
+ char ch = chars[start++];
if (!XML11Char.isXML11Valid(ch)) {
// check if it is surrogate
if ( length-- > 0) {
surrogates(ch, chars[start++], true);
} else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
- if ( unescaped && XML11Char.isXML11ValidLiteral(ch))
+ if ( unescaped && XML11Char.isXML11ValidLiteral(ch)) {
_printer.printText( ch );
- else
+ }
+ else {
printXMLChar( ch );
+ }
}
- } else {
+ }
+ else {
// Not preserving spaces: print one part at a time, and
// use spaces between parts to break them into different
// lines. Spaces at beginning of line will be stripped
// by printing mechanism. Line terminator is treated
// no different than other text part.
while ( length-- > 0 ) {
- ch = chars[start++];
+ char ch = chars[start++];
if (!XML11Char.isXML11Valid(ch)) {
// check if it is surrogate
if ( length-- > 0) {
surrogates(ch, chars[start++], true);
} else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
-
- if ( unescaped && XML11Char.isXML11ValidLiteral(ch))
+ if ( unescaped && XML11Char.isXML11ValidLiteral(ch)) {
_printer.printText( ch );
- else
+ }
+ else {
printXMLChar( ch );
+ }
}
}
}
-
public boolean reset() {
super.reset();
return true;
-
}
}
-
-
-
-
Modified: xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java?view=diff&rev=464369&r1=464368&r2=464369
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java (original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java Sun Oct 15 20:22:35 2006
@@ -216,7 +216,6 @@
ElementState state;
String name;
String value;
- boolean addNSAttr = false;
if (DEBUG) {
System.out.println("==>startElement("+namespaceURI+","+localName+
@@ -271,13 +270,16 @@
if (namespaceURI != null && ! namespaceURI.equals( "" )) {
String prefix;
prefix = getPrefix( namespaceURI );
- if (prefix != null && prefix.length() > 0)
+ if (prefix != null && prefix.length() > 0) {
rawName = prefix + ":" + localName;
- else
+ }
+ else {
rawName = localName;
- } else
+ }
+ }
+ else {
rawName = localName;
- addNSAttr = true;
+ }
}
_printer.printText( '<' );
@@ -764,13 +766,11 @@
// xmlns:foo = ""
}
continue;
- } else { // xmlns
- // empty prefix is always bound ("" or some string)
-
- value = fSymbolTable.addSymbol(value);
- fNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, value);
- continue;
}
+ // xmlns --- empty prefix is always bound ("" or some string)
+ value = fSymbolTable.addSymbol(value);
+ fNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, value);
+ continue;
} // end-else: valid declaration
} // end-if: namespace declaration
} // end-for
@@ -952,22 +952,20 @@
// xmlns:foo = ""
}
continue;
- } else { // xmlns
- // empty prefix is always bound ("" or some string)
-
- uri = fNSBinder.getURI(XMLSymbols.EMPTY_STRING);
- localUri=fLocalNSBinder.getURI(XMLSymbols.EMPTY_STRING);
- value = fSymbolTable.addSymbol(value);
- if (localUri == null ){
- // declaration was not printed while fixing element namespace binding
- if (fNamespacePrefixes) {
- printNamespaceAttr(XMLSymbols.EMPTY_STRING, value);
- }
- // case 4 does not apply here since attributes can't use
- // default namespace
+ }
+ // xmlns --- empty prefix is always bound ("" or some string)
+ uri = fNSBinder.getURI(XMLSymbols.EMPTY_STRING);
+ localUri= fLocalNSBinder.getURI(XMLSymbols.EMPTY_STRING);
+ value = fSymbolTable.addSymbol(value);
+ if (localUri == null ) {
+ // declaration was not printed while fixing element namespace binding
+ if (fNamespacePrefixes) {
+ printNamespaceAttr(XMLSymbols.EMPTY_STRING, value);
}
- continue;
+ // case 4 does not apply here since attributes can't use
+ // default namespace
}
+ continue;
}
uri = fSymbolTable.addSymbol(uri);
@@ -1189,8 +1187,6 @@
AttributesImpl attrsOnly;
String rawName;
int i;
- int indexColon;
- String prefix;
int length;
if (attrs == null) {
@@ -1287,7 +1283,7 @@
if (++index <length) {
surrogates(ch, text.charAt(index), true);
} else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
@@ -1309,7 +1305,7 @@
if (++index <length) {
surrogates(ch, text.charAt(index), true);
} else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
@@ -1326,8 +1322,6 @@
protected void printText( char[] chars, int start, int length,
boolean preserveSpace, boolean unescaped ) throws IOException {
- int index;
- char ch;
if ( preserveSpace ) {
// Preserving spaces: the text must print exactly as it is,
@@ -1335,20 +1329,23 @@
// consolidating spaces. If a line terminator is used, a line
// break will occur.
while ( length-- > 0 ) {
- ch = chars[start++];
+ char ch = chars[start++];
if (!XMLChar.isValid(ch)) {
// check if it is surrogate
if ( length-- > 0 ) {
surrogates(ch, chars[start++], true);
- } else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ }
+ else {
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
- if ( unescaped )
+ if ( unescaped ) {
_printer.printText( ch );
- else
+ }
+ else {
printXMLChar( ch );
+ }
}
} else {
// Not preserving spaces: print one part at a time, and
@@ -1357,20 +1354,23 @@
// by printing mechanism. Line terminator is treated
// no different than other text part.
while ( length-- > 0 ) {
- ch = chars[start++];
+ char ch = chars[start++];
if (!XMLChar.isValid(ch)) {
// check if it is surrogate
if ( length-- > 0 ) {
surrogates(ch, chars[start++], true);
- } else {
- fatalError("The character '"+(char)ch+"' is an invalid XML character");
+ }
+ else {
+ fatalError("The character '"+ch+"' is an invalid XML character");
}
continue;
}
- if ( unescaped )
+ if ( unescaped ) {
_printer.printText( ch );
- else
+ }
+ else {
printXMLChar( ch );
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org