You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by ga...@locus.apache.org on 2000/10/08 05:41:57 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/templates ElemExtensionCall.java ElemExtensionDecl.java
garyp 00/10/07 20:41:57
Modified: java/src/org/apache/xalan/templates ElemExtensionCall.java
ElemExtensionDecl.java
Log:
Implement new extension handling mechanism
Revision Changes Path
1.9 +19 -8 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ElemExtensionCall.java 2000/10/03 19:38:02 1.8
+++ ElemExtensionCall.java 2000/10/08 03:41:56 1.9
@@ -71,7 +71,7 @@
import org.apache.xalan.res.XSLMessages;
import org.apache.xpath.XPathContext;
import org.apache.xalan.res.XSLTErrorResources;
-import org.apache.xalan.extensions.ExtensionNSHandler;
+import org.apache.xalan.extensions.ExtensionHandler;
import org.apache.xalan.extensions.ExtensionsTable;
import org.apache.xalan.transformer.TransformerImpl;
@@ -89,7 +89,6 @@
String m_lang;
String m_srcURL;
String m_scriptSrc;
- Class m_javaClass = null;
ElemExtensionDecl m_decl = null;
/**
@@ -204,13 +203,25 @@
XPathContext liaison = ((XPathContext)transformer.getXPathContext());
ExtensionsTable etable = liaison.getExtensionsTable();
- ExtensionNSHandler nsh = etable.get(m_extns);
+ ExtensionHandler nsh = etable.get(m_extns);
- nsh.processElement (this.getLocalName(), this,
- transformer,
- getStylesheet(),
- sourceNode.getOwnerDocument(),
- sourceNode, mode, m_javaClass, this);
+ // We're seeing this extension namespace used for the first time. Try to
+ // autodeclare it as a java namespace.
+
+ if (null == nsh)
+ {
+ nsh = etable.makeJavaNamespace(m_extns);
+ etable.addExtensionNamespace(m_extns, nsh);
+ }
+
+ nsh.processElement(this.getLocalName(),
+ this,
+ transformer,
+ getStylesheet(),
+ sourceNode.getOwnerDocument(),
+ sourceNode,
+ mode,
+ this);
}
catch(Exception e)
{
1.4 +37 -12 xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionDecl.java
Index: ElemExtensionDecl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionDecl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemExtensionDecl.java 2000/10/04 07:49:59 1.3
+++ ElemExtensionDecl.java 2000/10/08 03:41:56 1.4
@@ -5,7 +5,10 @@
import org.apache.xalan.utils.NameSpace;
import org.apache.xalan.utils.StringToStringTable;
import org.apache.xalan.utils.StringVector;
-import org.apache.xalan.extensions.ExtensionNSHandler;
+import org.apache.xalan.extensions.ExtensionHandler;
+import org.apache.xalan.extensions.ExtensionHandlerGeneral;
+import org.apache.xalan.extensions.ExtensionHandlerJavaClass;
+import org.apache.xalan.extensions.ExtensionHandlerJavaPackage;
import org.apache.xalan.extensions.ExtensionsTable;
import org.apache.xalan.transformer.TransformerImpl;
import org.xml.sax.SAXException;
@@ -131,22 +134,44 @@
}
if(null == lang)
lang = "javaclass";
+
+ if ( ("javaclass" == lang) && (scriptSrc != null) )
+ throw new SAXException("Element content not allowed for lang=javaclass " + scriptSrc);
+
XPathContext liaison = ((XPathContext)transformer.getXPathContext());
ExtensionsTable etable = liaison.getExtensionsTable();
- ExtensionNSHandler nsh = etable.get(declNamespace);
+ ExtensionHandler nsh = etable.get(declNamespace);
+
+ // If we have no prior ExtensionHandler for this namespace, we need to
+ // create one.
+ // If the script element is for javaclass, this is our special compiled java.
+ // Element content is not supported for this so we throw an exception if
+ // it is provided. Otherwise, we look up the srcURL to see if we already have
+ // an ExtensionHandler.
if(null == nsh)
{
- nsh = new ExtensionNSHandler (declNamespace);
- // System.out.println("Adding NS Handler: declNamespace = "+
- // declNamespace+", lang = "+lang+", srcURL = "+
- // srcURL+", scriptSrc="+scriptSrc);
- nsh.setScript (lang, srcURL, scriptSrc);
- nsh.setElements(this.m_elements);
- nsh.setFunctions(this.m_functions);
- etable.addExtensionElementNamespace(declNamespace, nsh);
- }
- }
+ if (lang.equals("javaclass")) {
+ nsh = etable.get(srcURL);
+ if (null == nsh) {
+ nsh = etable.makeJavaNamespace(srcURL);
+ }
+ }
+ else // not java
+ {
+ nsh = new ExtensionHandlerGeneral(declNamespace,
+ this.m_elements,
+ this.m_functions,
+ lang,
+ srcURL,
+ scriptSrc);
+ // System.out.println("Adding NS Handler: declNamespace = "+
+ // declNamespace+", lang = "+lang+", srcURL = "+
+ // srcURL+", scriptSrc="+scriptSrc);
+ }
+ etable.addExtensionNamespace (declNamespace, nsh);
+ }
+ }
}