garyp 00/12/08 14:48:03
Modified: java/src/org/apache/xalan/processor ProcessorOutputElem.java
java/src/org/apache/xalan/templates OutputProperties.java
Log:
Respect precedence levels when composing xsl:output elements.
Be sure OutputProperties has the correct Uid to ensure proper sorting when
recomposing.
Bring cdata-section-elements processing into standards conformance.
Revision Changes Path
1.11 +1 -0
xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java
Index: ProcessorOutputElem.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ProcessorOutputElem.java 2000/12/07 08:16:56 1.10
+++ ProcessorOutputElem.java 2000/12/08 22:48:01 1.11
@@ -232,6 +232,7 @@
m_outputProperties.setDOMBackPointer(handler.getOriginatingNode());
m_outputProperties.setLocaterInfo(handler.getLocator());
+ m_outputProperties.setUid(handler.nextUid());
setPropertiesFromAttributes(handler, rawName, attributes, this);
// Access this only from the Hashtable level... we don't want to
1.4 +40 -27
xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java
Index: OutputProperties.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OutputProperties.java 2000/12/07 00:59:36 1.3
+++ OutputProperties.java 2000/12/08 22:48:02 1.4
@@ -61,6 +61,7 @@
import java.io.IOException;
import java.util.Vector;
+import java.util.Hashtable;
import java.util.Properties;
import java.util.Enumeration;
@@ -785,7 +786,7 @@
super.compose(); // just good form, not really needed.
- m_currentStylesheetComposed = null;
+ m_propertiesLevels = null;
}
/**
@@ -829,7 +830,8 @@
while (enum.hasMoreElements())
{
String key = (String) enum.nextElement();
- if (null == m_properties.get(key))
+ Object oldValue = m_properties.get(key);
+ if (null == oldValue)
{
String val = (String) src.get(key);
@@ -840,6 +842,10 @@
m_properties.put(key, val);
}
+ else if (key.equals(OutputKeys.CDATA_SECTION_ELEMENTS))
+ {
+ m_properties.put(key, (String) oldValue + (String) src.get(key));
+ }
}
}
@@ -871,36 +877,45 @@
throws TransformerException
{
+ if (null == m_propertiesLevels)
+ m_propertiesLevels = new Hashtable();
+
// This operation assumes that the OutputProperties are being called
- // from most important to least important, in document order.
- // Are the new properties at the same importance level as the properties
- // that were last used?
- StylesheetComposed sc = newProps.getStylesheetComposed();
+ // from most important to least important, in reverse document order.
- if (sc != m_currentStylesheetComposed)
- {
- m_currentStylesheetComposed = sc;
- }
- else
+ int newPrecedence =
newProps.getStylesheetComposed().getImportCountComposed();
+
+ Properties p = newProps.getProperties();
+ Enumeration enum = p.keys();
+
+ while (enum.hasMoreElements())
{
- Properties p = newProps.getProperties();
- Enumeration enum = p.keys();
+ String key = (String) enum.nextElement();
- while (enum.hasMoreElements())
- {
- String key = (String) enum.nextElement();
+ if (key.equals(OutputKeys.CDATA_SECTION_ELEMENTS))
+ continue;
- // Do we already have this property? Call hashtable operation,
- // since we don't want to look at default properties.
- if (null != m_properties.get(key))
+ // Do we already have this property? Call hashtable operation,
+ // since we don't want to look at default properties.
+ Integer oldPrecedence = (Integer) m_propertiesLevels.get(key);
+ if (null == oldPrecedence)
+ {
+ m_propertiesLevels.put(key, new Integer(newPrecedence));
+ }
+ else if (newPrecedence >= oldPrecedence.intValue())
+ {
+ String oldValue = (String) this.m_properties.get(key);
+ String newValue = (String) newProps.m_properties.get(key);
+ if ( ((oldValue == null) && (newValue != null)) ||
!oldValue.equals(newValue) )
{
String msg = key + " can not be multiply defined at the same "
- + "import level!";
+ + "import level! Old value = "
+ + oldValue + "; New value = " + newValue;
throw new TransformerException(msg, newProps);
}
}
}
- }
+}
/**
* Report if the key given as an argument is a legal xsl:output key.
@@ -926,15 +941,13 @@
}
/**
- * This ugly field is to let us know what StylesheetComposed was last
- * used to set this element, so we can flag errors about values being
- * set multiple time at the same precedence level. There is likely to
- * be discovered a better way to do this, but this is the easiest
mechanism
- * I can work out for the moment. Note that this field is only used
+ * This ugly field is used during recomposition to track the import
precedence
+ * at which each attribute was first specified, so we can flag errors
about values being
+ * set multiple time at the same precedence level. Note that this field
is only used
* during recomposition, with the OutputProperties object owned by the
* [EMAIL PROTECTED] org.apache.xalan.templates.StylesheetRoot} object.
*/
- private transient StylesheetComposed m_currentStylesheetComposed;
+ private transient Hashtable m_propertiesLevels;
/** The output properties. */
private Properties m_properties = null;