sboag 99/12/13 16:21:57
Modified: . bsf.jar
src/org/apache/xalan/xpath ExtensionFunctionHandler.java
src/org/apache/xalan/xpath/xml XMLParserLiaisonDefault.java
src/org/apache/xalan/xslt ElemExtensionCall.java
ExtensionNSHandler.java Stylesheet.java
StylesheetHandler.java XSLTEngineImpl.java
Added: . bsfengines.jar
Log:
Fixed minor bugs relating to extension handling, updated to new BSF.
Revision Changes Path
1.2 +102 -145 xml-xalan/bsf.jar
<<Binary file>>
1.1 xml-xalan/bsfengines.jar
<<Binary file>>
1.6 +12 -2
xml-xalan/src/org/apache/xalan/xpath/ExtensionFunctionHandler.java
Index: ExtensionFunctionHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/ExtensionFunctionHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ExtensionFunctionHandler.java 1999/12/03 08:43:12 1.5
+++ ExtensionFunctionHandler.java 1999/12/14 00:21:52 1.6
@@ -271,8 +271,18 @@
}
catch (Exception e)
{
- throw new XPathException ("Error with extension in callFunction.", e);
+ // throw new XPathException ("Error with extension in callFunction.",
e);
+ String msg = e.getMessage();
+ if(null != msg)
+ {
+ if(msg.startsWith("Stopping after fatal error:"))
+ {
+ msg = msg.substring("Stopping after fatal error:".length());
+ }
+ System.out.println("Call to extension function failed: "+msg);
+ }
}
+ return new XNull();
}
/////////////////////////////////////////////////////////////////////////
@@ -308,7 +318,7 @@
// the class name to run. If it starts with class: then use the
// class object with that name instead of init'ing it as the
// target of the calls later
- if (scriptLang.equals ("javaclass"))
+ if (scriptLang.equals ("javaclass") && (scriptSrcURL != null))
{
try
{
1.13 +25 -3
xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
Index: XMLParserLiaisonDefault.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XMLParserLiaisonDefault.java 1999/12/13 08:22:54 1.12
+++ XMLParserLiaisonDefault.java 1999/12/14 00:21:53 1.13
@@ -1837,6 +1837,18 @@
addExtensionNamespace (uri, fh);
}
+ if(null == m_extensionFunctionNamespaces.get
("http://xsl.lotus.com/java"))
+ {
+ // register the java namespace as being implemented by the
+ // xslt-javaclass engine. Note that there's no real code
+ // per se for this extension as the functions carry the
+ // object on which to call etc. and all the logic of breaking
+ // that up is in the xslt-javaclass engine.
+ String uri = "http://xsl.lotus.com/java";
+ ExtensionFunctionHandler fh = new ExtensionFunctionHandler (uri, null,
"xslt-javaclass", null, null);
+
+ addExtensionNamespace (uri, fh);
+ }
Object result = null;
if (null != ns)
@@ -1875,9 +1887,19 @@
catch (Exception e)
{
// e.printStackTrace();
- throw new XPathProcessorException ("Extension function '" + ns +
- ":" + funcName +
- "', threw exception: " + e, e);
+ // throw new XPathProcessorException ("Extension function '" + ns +
+ // ":" + funcName +
+ // "', threw exception: " + e, e);
+ String msg = e.getMessage();
+ if(null != msg)
+ {
+ if(msg.startsWith("Stopping after fatal error:"))
+ {
+ msg = msg.substring("Stopping after fatal error:".length());
+ }
+ System.out.println("Call to extension function failed: "+msg);
+ result = new XNull();
+ }
}
}
else
1.4 +9 -1
xml-xalan/src/org/apache/xalan/xslt/ElemExtensionCall.java
Index: ElemExtensionCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemExtensionCall.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemExtensionCall.java 1999/12/03 08:43:14 1.3
+++ ElemExtensionCall.java 1999/12/14 00:21:54 1.4
@@ -179,7 +179,15 @@
catch(Exception e)
{
String msg = e.getMessage();
- processor.message(msg);
+ if(null != msg)
+ {
+ if(msg.startsWith("Stopping after fatal error:"))
+ {
+ msg = msg.substring("Stopping after fatal error:".length());
+ }
+ processor.message("Call to extension element failed: "+msg);
+ }
+ // processor.message(msg);
isAvailable = false;
for (ElemTemplateElement child = m_firstChild; child != null; child =
child.m_nextSibling)
{
1.4 +15 -0
xml-xalan/src/org/apache/xalan/xslt/ExtensionNSHandler.java
Index: ExtensionNSHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ExtensionNSHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExtensionNSHandler.java 1999/12/03 08:43:14 1.3
+++ ExtensionNSHandler.java 1999/12/14 00:21:55 1.4
@@ -358,6 +358,10 @@
liaison.setErrorHandler(new ExtErrorHandler(url.toString()));
}
Element componentElement = null;
+ /*
+ try
+ {
+ */
liaison.parse(new InputSource(url.toString()));
Document compSpec = liaison.getDocument();
componentElement = compSpec.getDocumentElement ();
@@ -385,6 +389,17 @@
throw new XSLProcessorException ("too many <script>s in component");
}
componentDescLoaded = true;
+ /*
+ }
+ catch(org.xml.sax.SAXException se)
+ {
+
+ }
+ catch(java.net.UnknownHostException uhe)
+ {
+
+ }
+ */
}
/////////////////////////////////////////////////////////////////////////
1.14 +2 -1 xml-xalan/src/org/apache/xalan/xslt/Stylesheet.java
Index: Stylesheet.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/Stylesheet.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Stylesheet.java 1999/12/13 08:19:31 1.13
+++ Stylesheet.java 1999/12/14 00:21:55 1.14
@@ -404,7 +404,8 @@
{
if(uri.equals(m_XSLNameSpaceURL)
|| (null != lookupExtensionNSHandler(uri))
- || uri.equalsIgnoreCase(XSLTEngineImpl.m_XSLT4JNameSpaceURL))
+ || uri.equals("http://xml.apache.org/xslt")
+ || uri.equals("http://xsl.lotus.com/"))
return true;
if((prefix == null) || (prefix.length() == 0))
1.10 +4 -2
xml-xalan/src/org/apache/xalan/xslt/StylesheetHandler.java
Index: StylesheetHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/StylesheetHandler.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StylesheetHandler.java 1999/12/13 08:22:54 1.9
+++ StylesheetHandler.java 1999/12/14 00:21:55 1.10
@@ -444,7 +444,8 @@
case Constants.ELEMNAME_EXTENSION:
{
- if((null != ns) &&
!ns.equalsIgnoreCase(m_processor.m_XSLT4JNameSpaceURL))
+ if((null != ns) && !(ns.equals("http://xml.apache.org/xslt") ||
+ ns.equals("http://xsl.lotus.com/")))
{
m_processor.warn(XSLTErrorResources.WARNING0009, new Object[]
{m_processor.m_XSLT4JNameSpaceURL}); //"Old syntax: the functions instruction
should use a url of "+m_processor.m_XSLT4JNameSpaceURL);
}
@@ -880,7 +881,8 @@
}
// BEGIN SANJIVA CODE
else if (!m_inTemplate && (null != ns) &&
- ns.startsWith (m_processor.m_XSLT4JNameSpaceURL))
+ (ns.equals ("http://xml.apache.org/xslt")
+ || ns.equals("http://xsl.lotus.com/")))
{
if (localName.equals ("component"))
{
1.20 +1 -64 xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java
Index: XSLTEngineImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- XSLTEngineImpl.java 1999/12/13 08:19:31 1.19
+++ XSLTEngineImpl.java 1999/12/14 00:21:55 1.20
@@ -1121,71 +1121,8 @@
throws SAXException
{
throw new XSLProcessorException ("xsl:functions is unsupported");
- /*
- Attr nsPrefixAttr =
extensionElem.getAttributeNode(Constants.ATTRNAME_NS);
- String namespace = null;
- if(null == nsPrefixAttr)
- {
- warn(extensionElem, null,
- "xsl:functions must have a '"+Constants.ATTRNAME_NS+"' attribute!");
- }
- else
- {
- namespace =
m_parserLiaison.getNamespaceForPrefix(nsPrefixAttr.getValue(),
- extensionElem);
- }
-
- String codetype = getAttrVal(extensionElem, Constants.ATTRNAME_CODETYPE);
- // String functions = getAttrVal(extensionElem,
Constants.ATTRNAME_METHOD);
-
- Dispatcher extension = null;
- Object obj = m_dispatcherFactories.get(codetype);
- if(null == obj)
- {
- if(null == codetype)
- {
- // Assume Java, I guess
- codetype = "application/java";
- }
-
- if(codetype.equals("text/javascript"))
- {
-
registerExtensionHandlerByName("org.apache.xalan.xpath.xml.dispatchers.JavaScriptDispatcher",
- codetype);
- obj = m_dispatcherFactories.get(codetype);
- }
- else if(codetype.equals("application/java"))
- {
-
registerExtensionHandlerByName("org.apache.xalan.xpath.xml.dispatchers.JavaDispatcher",
- codetype);
- obj = m_dispatcherFactories.get(codetype);
- }
- }
-
- if(null != obj)
- {
- DispatcherFactory factory = (DispatcherFactory)obj;
- extension = factory.create(extensionElem, null);
- }
- else
- {
- warn(extensionElem, null,
- "Could not get factory for codetype "+codetype+"!");
- }
-
- if(extension != null)
- {
-
((XMLParserLiaisonDefault)m_parserLiaison).m_extensionNamespaces.put(namespace,
extension);
- }
- else
- {
- warn(extensionElem, null,
- "can't register extension handler for namespace: "+namespace);
- }
- */
}
-
//==========================================================
// SECTION: Diagnostic functions
//==========================================================
@@ -3979,7 +3916,7 @@
}
if(null != xmlListener)
{
- System.out.println("Setting the method automatically to HTML");
+ // System.out.println("Setting the method automatically to
HTML");
m_stylesheetRoot.setOutputMethod("html");
m_flistener = new FormatterToHTML(xmlListener);
}