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 2002/07/19 21:18:41 UTC
cvs commit: xml-xerces/java/src/org/apache/xml/serialize BaseMarkupSerializer.java
elena 2002/07/19 12:18:39
Modified: java/src/org/apache/xml/serialize BaseMarkupSerializer.java
Log:
Code cleanup for handling DOM L3 features.
Revision Changes Path
1.37 +27 -25 xml-xerces/java/src/org/apache/xml/serialize/BaseMarkupSerializer.java
Index: BaseMarkupSerializer.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/BaseMarkupSerializer.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- BaseMarkupSerializer.java 17 Jul 2002 00:28:11 -0000 1.36
+++ BaseMarkupSerializer.java 19 Jul 2002 19:18:38 -0000 1.37
@@ -109,6 +109,7 @@
import org.w3c.dom.DOMLocator;
import org.apache.xerces.dom.DOMErrorImpl;
import org.apache.xerces.dom.DOMLocatorImpl;
+import org.apache.xerces.impl.Constants;
import org.w3c.dom.ls.DOMWriterFilter;
import org.w3c.dom.traversal.NodeFilter;
@@ -1141,8 +1142,7 @@
}
child = node.getFirstChild();
- if ( child == null || (fFeatures !=null &&
- !((Boolean)fFeatures.get("entities")).booleanValue() )) {
+ if ( child == null || (fFeatures !=null && getFeature(Constants.DOM_ENTITIES))){
_printer.printText("&");
_printer.printText(node.getNodeName());
_printer.printText(";");
@@ -1357,27 +1357,26 @@
state.inCData = true;
}
index = text.indexOf( "]]>" );
- if (index >=0 && (fFeatures != null && !((Boolean)fFeatures.get("split-cdata-sections")).booleanValue())) {
- // issue fatal error
- if (fDOMErrorHandler != null) {
- modifyDOMError("The character sequence \"]]>\" must not appear in content"+
- " unless used to mark the end of a CDATA section.", DOMError.SEVERITY_FATAL_ERROR);
- boolean continueProcess = fDOMErrorHandler.handleError(fDOMError);
- // Should we always terminate the serialization?
- // otherwise should we split CDATA section..?
- if (!continueProcess) {
- throw new IOException();
+ if (index >=0) {
+ // DOM Level 3 Load and Save
+ //
+ if (fFeatures != null && fDOMErrorHandler != null) {
+ if (!getFeature(Constants.DOM_SPLIT_CDATA)) {
+ // issue fatal error
+ modifyDOMError("The character sequence \"]]>\" must not appear in content"+
+ " unless used to mark the end of a CDATA section.", DOMError.SEVERITY_FATAL_ERROR);
+ boolean continueProcess = fDOMErrorHandler.handleError(fDOMError);
+ if (!continueProcess) {
+ throw new IOException();
+ }
+ } else {
+ // issue warning
+ modifyDOMError("Spliting a CDATA section containing the CDATA section termination marker ']]>' ",
+ DOMError.SEVERITY_WARNING);
+ fDOMErrorHandler.handleError(fDOMError);
}
}
}
- else if (index >=0 && (fFeatures !=null &&((Boolean)fFeatures.get("split-cdata-sections")).booleanValue())) {
- // issue warning
- if (fDOMErrorHandler != null) {
- modifyDOMError("Spliting a CDATA section containing the CDATA section termination marker ']]>' ",
- DOMError.SEVERITY_WARNING);
- fDOMErrorHandler.handleError(fDOMError);
- }
- }
while ( index >= 0 ) {
fStrBuffer.append( text.substring( 0, index + 2 ) ).append( "]]><![CDATA[" );
@@ -1584,7 +1583,6 @@
throws IOException
{
String charRef;
-
// If there is a suitable entity reference for this
// character, print it. The list of available entity
// references is almost but not identical between
@@ -1596,7 +1594,6 @@
_printer.printText( ';' );
} else if ( ( ch >= ' ' && _encodingInfo.isPrintable(ch) && ch != 0xF7 ) ||
ch == '\n' || ch == '\r' || ch == '\t' ) {
- // If the character is not printable, print as character reference.
// Non printables are below ASCII space but not tab or line
// terminator, ASCII delete, or above a certain Unicode threshold.
if (ch < 0x10000) {
@@ -1605,8 +1602,8 @@
_printer.printText((char)(((ch-0x10000)>>10)+0xd800));
_printer.printText((char)(((ch-0x10000)&0x3ff)+0xdc00));
}
-
} else {
+ // The character is not printable, print as character reference.
_printer.printText( "&#x" );
_printer.printText(Integer.toHexString(ch));
_printer.printText( ';' );
@@ -1702,7 +1699,7 @@
* Leave the current element state and return to the
* state of the parent element. If this was the root
* element, return to the state of the document.
- *
+ *
* @return Previous element state
*/
protected ElementState leaveElementState()
@@ -1777,5 +1774,10 @@
return fDOMError;
}
+
+ private boolean getFeature(String feature){
+ return ((Boolean)fFeatures.get(feature)).booleanValue();
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org