You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/01/07 05:10:35 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/templates ElemExtensionCall.java
sboag 01/01/06 20:10:35
Modified: java/src/org/apache/xalan/templates ElemExtensionCall.java
Log:
Handle null ExtensionHandler from makeJavaNamespace. Put
fallback stuff into executeFallbacks method, so that it can be
called from two places.
Also added "YOU CAN'T DO THIS HERE, AS STYLESHEETS
MUST BE IMMUTABLE DURING RUNTIME." comments to
use of isAvailable member variable. I think this will cause bugs when
a Stylesheet is used among multiple threads. I tried to hack not
having this, but gave up for the moment. I need to talk to Gary about
the right way to address this. I suspect the value should be
kept in the ExtensionHandler instance?
Revision Changes Path
1.19 +51 -20 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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ElemExtensionCall.java 2001/01/02 03:36:46 1.18
+++ ElemExtensionCall.java 2001/01/07 04:10:35 1.19
@@ -97,7 +97,8 @@
// String m_extHandlerLookup;
- /** Flag indicating if the extension is available for execution */
+ // YOU CAN'T DO THIS HERE, AS STYLESHEETS MUST BE IMMUTABLE DURING RUNTIME. -sb
+ /* Flag indicating if the extension is available for execution */
transient boolean isAvailable = false;
/** Language used by extension.
@@ -145,6 +146,7 @@
public boolean elementIsAvailable()
{
return isAvailable;
+ // This needs to ask the execution context...
}
/**
@@ -239,6 +241,39 @@
return decl;
}
+
+ /**
+ * 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>.
+ * @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 executeFallbacks(
+ TransformerImpl transformer, Node sourceNode, QName mode)
+ throws TransformerException
+ {
+ for (ElemTemplateElement child = m_firstChild; child != null;
+ child = child.m_nextSibling)
+ {
+ if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK)
+ {
+ try
+ {
+ transformer.pushElemTemplateElement(child);
+ child.execute(transformer, sourceNode, mode);
+ }
+ finally
+ {
+ transformer.popElemTemplateElement();
+ }
+ }
+ }
+
+ }
+
/**
* Execute an extension.
@@ -269,7 +304,14 @@
{
nsh = etable.makeJavaNamespace(m_extns);
- etable.addExtensionNamespace(m_extns, nsh);
+ if(null != nsh)
+ etable.addExtensionNamespace(m_extns, nsh);
+ else
+ {
+ executeFallbacks(transformer, sourceNode, mode);
+ return;
+ }
+
}
try
@@ -278,6 +320,7 @@
// We set isAvailable to true so that if the extension element processes its
// children, and one of those children is an <xsl:fallback>, it won't get invoked.
+ // YOU CAN'T DO THIS HERE, AS STYLESHEETS MUST BE IMMUTABLE DURING RUNTIME. -sb
isAvailable = true;
nsh.processElement(this.getLocalName(), this, transformer,
getStylesheet(), sourceNode.getOwnerDocument(),
@@ -287,7 +330,7 @@
{
// System.out.println(e);
- // e.printStackTrace();
+ // e.printzStackTrace();
String msg = e.getMessage();
if (null != msg)
@@ -307,24 +350,12 @@
}
// transformer.message(msg);
+
+ // YOU CAN'T DO THIS HERE, AS STYLESHEETS MUST BE IMMUTABLE DURING RUNTIME. -sb
isAvailable = false;
-
- for (ElemTemplateElement child = m_firstChild; child != null;
- child = child.m_nextSibling)
- {
- if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK)
- {
- try
- {
- transformer.pushElemTemplateElement(child);
- child.execute(transformer, sourceNode, mode);
- }
- finally
- {
- transformer.popElemTemplateElement();
- }
- }
- }
+
+ executeFallbacks(
+ transformer, sourceNode, mode);
}
}
catch(org.xml.sax.SAXException se)