< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/SerializerBase.java
Print this page
@@ -91,13 +91,15 @@
* from the SAX attributes in a startElement() call.
*/
protected AttributesImplSerializer m_attributes = new AttributesImplSerializer();
/**
- * Tells if we're in an EntityRef event.
+ * Tells if we're in an EntityRef event, true if it's greater than 0. Use
+ * integer type to handle nested entity reference, increase m_inEntityRef in
+ * startEntity, decrease m_inEntityRef in endEntity.
*/
- protected boolean m_inEntityRef = false;
+ protected int m_inEntityRef = 0;
/** This flag is set while receiving events from the external DTD */
protected boolean m_inExternalDTD = false;
/**
@@ -142,11 +144,11 @@
protected boolean m_doIndent = false;
/**
* Amount to indent.
*/
- protected int m_indentAmount = 0;
+ protected int m_indentAmount = 4;
/**
* Tells the XML version, for writing out to the XML decl.
*/
protected String m_version = null;
@@ -442,17 +444,29 @@
* @see #startEntity
*/
public void endEntity(String name) throws org.xml.sax.SAXException {
if (name.equals("[dtd]"))
m_inExternalDTD = false;
- m_inEntityRef = false;
+
+ if (!m_inExternalDTD)
+ m_inEntityRef--;
if (m_tracer != null)
this.fireEndEntity(name);
}
/**
+ * This method checks if current node is in entity reference.
+ *
+ * @return True if current node is in entity reference.
+ */
+ protected boolean isInEntityRef()
+ {
+ return m_inEntityRef > 0;
+ }
+
+ /**
* Flush and close the underlying java.io.Writer. This method applies to
* ToStream serializers, not ToSAXHandler serializers.
* @see ToStream
*/
public void close() {
@@ -1137,12 +1151,12 @@
this.m_StringOfCDATASections = null;
this.m_elemContext = new ElemContext();
this.m_doctypePublic = null;
this.m_doctypeSystem = null;
this.m_doIndent = false;
- this.m_indentAmount = 0;
- this.m_inEntityRef = false;
+ this.m_indentAmount = 4;
+ this.m_inEntityRef = 0;
this.m_inExternalDTD = false;
this.m_mediatype = null;
this.m_needToCallStartDocument = true;
this.m_needToOutputDocTypeDecl = false;
if (this.m_prefixMap != null)
< prev index next >