minchau 2003/09/18 12:18:53
Modified: java/src/org/apache/xalan/processor ProcessorUnknown.java
java/src/org/apache/xalan/templates ElemUnknown.java
ElemFallback.java ElemExtensionCall.java
Log:
PR: Bugzilla 23089
Submitted by: Joanne Tong
Reviewed by: Brian Minchau
A slight rework of Joanne's patch made by Brian and now commited to CVS.
Also just previosly commited was a testcase, extend06 created by Joanne
(thank!).
Revision Changes Path
1.7 +2 -32
xml-xalan/java/src/org/apache/xalan/processor/ProcessorUnknown.java
Index: ProcessorUnknown.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorUnknown.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ProcessorUnknown.java 30 Jan 2003 18:45:45 -0000 1.6
+++ ProcessorUnknown.java 18 Sep 2003 19:18:53 -0000 1.7
@@ -60,42 +60,12 @@
/**
* <meta name="usage" content="internal"/>
- * This class processes an unknown template element, and ignores
- * the startElement and endElement events. It is used both
+ * This class processes an unknown template element. It is used both
* for unknown top-level elements, and for elements in the
* xslt namespace when the version is higher than the version
* of XSLT that we are set up to process.
*/
-public class ProcessorUnknown extends ProcessorTemplateElem
+public class ProcessorUnknown extends ProcessorLRE
{
- /**
- * Receive notification of the start of an element.
- *
- * @param name The element type name.
- *
- * @param handler non-null reference to current StylesheetHandler that is
constructing the Templates.
- * @param uri The Namespace URI, or an empty string.
- * @param localName The local name (without prefix), or empty string if
not namespace processing.
- * @param rawName The qualified name (with prefix).
- * @param attributes The specified or defaulted attributes.
- */
- public void startElement(
- StylesheetHandler handler, String uri, String localName, String
rawName, Attributes attributes)
- throws org.xml.sax.SAXException{}
-
- /**
- * Receive notification of the end of an element.
- *
- * @param name The element type name.
- * @param attributes The specified or defaulted attributes.
- *
- * @param handler non-null reference to current StylesheetHandler that is
constructing the Templates.
- * @param uri The Namespace URI, or an empty string.
- * @param localName The local name (without prefix), or empty string if
not namespace processing.
- * @param rawName The qualified name (with prefix).
- */
- public void endElement(
- StylesheetHandler handler, String uri, String localName, String
rawName)
- throws org.xml.sax.SAXException{}
}
1.9 +90 -5
xml-xalan/java/src/org/apache/xalan/templates/ElemUnknown.java
Index: ElemUnknown.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemUnknown.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ElemUnknown.java 30 Jan 2003 18:45:51 -0000 1.8
+++ ElemUnknown.java 18 Sep 2003 19:18:53 -0000 1.9
@@ -57,18 +57,32 @@
package org.apache.xalan.templates;
import javax.xml.transform.TransformerException;
-
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xpath.XPathContext;
+
/**
* <meta name="usage" content="advanced"/>
- * Implement a Literal Result Element.
+ * Implement an unknown element
*/
public class ElemUnknown extends ElemLiteralResult
{
/**
- * Copy an unknown element to the result tree
+ * Get an int constant identifying the type of element.
+ * @see org.apache.xalan.templates.Constants
+ *
+ [EMAIL PROTECTED] The token ID for this element
+ */
+ public int getXSLToken()
+ {
+ return Constants.ELEMNAME_UNDEFINED;
+ }
+
+ /**
+ * Execute the fallbacks when an extension is not available.
*
* @param transformer non-null reference to the the current transform-time
state.
* @param sourceNode non-null reference to the <a
href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
@@ -76,7 +90,78 @@
*
* @throws TransformerException
*/
- public void execute(
+ private void executeFallbacks(
TransformerImpl transformer)
- throws TransformerException{}
+ throws TransformerException
+ {
+ for (ElemTemplateElement child = m_firstChild; child != null;
+ child = child.m_nextSibling)
+ {
+ if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK)
+ {
+ try
+ {
+ transformer.pushElemTemplateElement(child);
+ ((ElemFallback) child).executeFallback(transformer);
+ }
+ finally
+ {
+ transformer.popElemTemplateElement();
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Return true if this extension element has a <xsl:fallback> child
element.
+ *
+ * @return true if this extension element has a <xsl:fallback> child
element.
+ */
+ private boolean hasFallbackChildren()
+ {
+ for (ElemTemplateElement child = m_firstChild; child != null;
+ child = child.m_nextSibling)
+ {
+ if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK)
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Execute an unknown element.
+ * Execute fallback if fallback child exists or do nothing
+ *
+ * @param transformer non-null reference to the the current transform-time
state.
+ * @param sourceNode non-null reference to the <a
href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
+ * @param mode reference, which may be null, to the <a
href="http://www.w3.org/TR/xslt#modes">current mode</a>.
+ *
+ * @throws TransformerException
+ */
+ public void execute(TransformerImpl transformer)
+ throws TransformerException
+ {
+
+
+ if (TransformerImpl.S_DEBUG)
+ transformer.getTraceManager().fireTraceEvent(this);
+
+ try {
+
+ if (hasFallbackChildren()) {
+ executeFallbacks(transformer);
+ } else {
+ // do nothing
+ }
+
+ } catch (TransformerException e) {
+ transformer.getErrorListener().fatalError(e);
+ }
+ if (TransformerImpl.S_DEBUG)
+ transformer.getTraceManager().fireTraceEndEvent(this);
+ }
+
}
1.15 +4 -2
xml-xalan/java/src/org/apache/xalan/templates/ElemFallback.java
Index: ElemFallback.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemFallback.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ElemFallback.java 30 Jan 2003 18:45:50 -0000 1.14
+++ ElemFallback.java 18 Sep 2003 19:18:53 -0000 1.15
@@ -130,7 +130,9 @@
throws TransformerException
{
- if (Constants.ELEMNAME_EXTENSIONCALL == m_parentNode.getXSLToken())
+ int parentElemType = m_parentNode.getXSLToken();
+ if (Constants.ELEMNAME_EXTENSIONCALL == parentElemType
+ || Constants.ELEMNAME_UNDEFINED == parentElemType)
{
if (TransformerImpl.S_DEBUG)
@@ -146,7 +148,7 @@
// Should never happen
System.out.println(
- "Error! parent of xsl:fallback must be an extension element!");
+ "Error! parent of xsl:fallback must be an extension or unknown
element!");
}
}
}
1.35 +2 -2
xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java
Index: ElemExtensionCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- ElemExtensionCall.java 27 Aug 2003 23:24:56 -0000 1.34
+++ ElemExtensionCall.java 18 Sep 2003 19:18:53 -0000 1.35
@@ -183,7 +183,7 @@
*
* @throws TransformerException
*/
- public void executeFallbacks(
+ private void executeFallbacks(
TransformerImpl transformer)
throws TransformerException
{
@@ -211,7 +211,7 @@
*
* @return true if this extension element has a <xsl:fallback> child
element.
*/
- public boolean hasFallbackChildren()
+ private boolean hasFallbackChildren()
{
for (ElemTemplateElement child = m_firstChild; child != null;
child = child.m_nextSibling)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]