sboag 00/10/10 20:36:10
Modified: java/src makexslt4j
java/src/org/apache/xalan/processor ProcessorInclude.java
ProcessorLRE.java StylesheetHandler.java
StylesheetPIHandler.java StylesheetProcessor.java
XSLTElementProcessor.java
java/src/org/apache/xalan/templates ElemTemplateElement.java
java/src/org/apache/xalan/xslt Process.java
Added: java/src/org/apache/xalan/processor StopParseException.java
Log:
getAssociatedStylesheets and processMultiple should now work, enabling
processing of xml-stylesheet PIs.
Processing of LRE as Stylesheet now better, xsl attribute excluded, xsl
attributes are now properly applied to stylesheet, and other attributes applied
to the LRE.
Revision Changes Path
1.18 +1 -0 xml-xalan/java/src/makexslt4j
Index: makexslt4j
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/makexslt4j,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- makexslt4j 2000/10/10 02:22:53 1.17
+++ makexslt4j 2000/10/11 03:36:01 1.18
@@ -69,6 +69,7 @@
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)processor$(PATHSEP)StylesheetHandler.java
\
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)processor$(PATHSEP)StylesheetPIHandler.java
\
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)processor$(PATHSEP)StylesheetProcessor.java
\
+
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)processor$(PATHSEP)StopParseException.java
\
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)processor$(PATHSEP)TemplateElementFactory.java
\
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)processor$(PATHSEP)XSLProcessorVersion.java
\
org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)processor$(PATHSEP)XSLTAttributeDef.java
\
1.5 +10 -1
xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java
Index: ProcessorInclude.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ProcessorInclude.java 2000/08/09 17:51:44 1.4
+++ ProcessorInclude.java 2000/10/11 03:36:03 1.5
@@ -206,7 +206,16 @@
if(null != entityResolver)
reader.setEntityResolver(entityResolver);
reader.setContentHandler(handler);
- reader.parse(inputSource);
+
reader.setFeature("http://apache.org/xml/features/validation/dynamic", true);
+ handler.pushBaseIndentifier(inputSource.getSystemId());
+ try
+ {
+ reader.parse(inputSource);
+ }
+ finally
+ {
+ handler.popBaseIndentifier();
+ }
}
}
catch(InstantiationException ie)
1.7 +51 -2
xml-xalan/java/src/org/apache/xalan/processor/ProcessorLRE.java
Index: ProcessorLRE.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorLRE.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ProcessorLRE.java 2000/10/03 19:38:00 1.6
+++ ProcessorLRE.java 2000/10/11 03:36:03 1.7
@@ -66,9 +66,11 @@
import org.apache.xalan.templates.StylesheetRoot;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;
+import org.xml.sax.helpers.AttributesImpl;
public class ProcessorLRE extends ProcessorTemplateElem
{
+
/**
* Receive notification of the start of an element.
*
@@ -84,17 +86,63 @@
throws SAXException
{
ElemTemplateElement p = handler.getElemTemplateElement();
+ boolean excludeXSLDecl = false;
+
if(null == p)
{
// Literal Result Template as stylesheet.
+
+ XSLTElementProcessor lreProcessor = handler.popProcessor();
+ XSLTElementProcessor stylesheetProcessor
+ = handler.getProcessorFor( Constants.S_XSLNAMESPACEURL,
"stylesheet", "xsl:stylesheet" );
+ handler.pushProcessor(lreProcessor);
+
Stylesheet stylesheet = new StylesheetRoot();
+
// stylesheet.setDOMBackPointer(handler.getOriginatingNode());
stylesheet.setLocaterInfo(new org.xml.sax.helpers.LocatorImpl());
stylesheet.setPrefixes(handler.getNamespaceSupport());
handler.pushStylesheet(stylesheet);
+
+ AttributesImpl stylesheetAttrs = new AttributesImpl();
+ AttributesImpl lreAttrs = new AttributesImpl();
+ int n = attributes.getLength();
+ for(int i = 0; i < n; i++)
+ {
+ String attrLocalName = attributes.getLocalName(i);
+ String attrUri = attributes.getURI(i);
+ String value = attributes.getValue(i);
+
+ if((null != attrUri) && attrUri.equals(Constants.S_XSLNAMESPACEURL))
+ {
+ stylesheetAttrs.addAttribute(null, attrLocalName,
+ attrLocalName,
+ attributes.getType(i),
+ attributes.getValue(i));
+ }
+ else if((attrLocalName.startsWith("xmlns:") ||
+ attrLocalName.equals("xmlns")) &&
+ value.equals(Constants.S_XSLNAMESPACEURL))
+ {
+ // ignore
+ }
+ else
+ {
+ lreAttrs.addAttribute(attrUri, attrLocalName,
+ attributes.getQName(i),
+ attributes.getType(i),
+ attributes.getValue(i));
+ }
+ }
+ attributes = lreAttrs;
- setPropertiesFromAttributes(handler, "stylesheet", attributes,
stylesheet);
+ // Set properties from the attributes, but don't throw
+ // an error if there is an attribute defined that is not
+ // allowed on a stylesheet.
+ stylesheetProcessor.setPropertiesFromAttributes(handler, "stylesheet",
+ stylesheetAttrs,
+ stylesheet);
handler.pushElemTemplateElement(stylesheet);
@@ -106,6 +154,7 @@
// template.setDOMBackPointer(handler.getOriginatingNode());
stylesheet.setTemplate(template);
p = handler.getElemTemplateElement();
+ excludeXSLDecl = true;
}
XSLTElementDef def = getElemDef();
@@ -163,7 +212,7 @@
}
elem.setDOMBackPointer(handler.getOriginatingNode());
elem.setLocaterInfo(handler.getLocator());
- elem.setPrefixes(handler.getNamespaceSupport());
+ elem.setPrefixes(handler.getNamespaceSupport(), excludeXSLDecl);
if(elem instanceof ElemLiteralResult)
{
((ElemLiteralResult)elem).setNamespace(uri);
1.10 +115 -17
xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java
Index: StylesheetHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StylesheetHandler.java 2000/10/04 23:20:08 1.9
+++ StylesheetHandler.java 2000/10/11 03:36:04 1.10
@@ -101,8 +101,6 @@
ContentHandler, ErrorHandler, TemplatesBuilder, PrefixResolver,
NodeConsumer
{
- static boolean m_xpathFunctionsInited = false;
-
/**
* Create a StylesheetHandler object, creating a root stylesheet
* as the target.
@@ -116,7 +114,13 @@
init(processor);
}
-
+
+ /**
+ * Static flag to let us know if the XPath functions table
+ * has been initialized.
+ */
+ private static boolean m_xpathFunctionsInited = false;
+
/**
* Do common initialization.
*/
@@ -250,9 +254,8 @@
* @param baseID Base URL for this stylesheet.
*/
public void setBaseID(String baseID)
- {
- m_baseIdentifiers.push(baseID);
-
+ {
+ pushBaseIndentifier(baseID);
}
////////////////////////////////////////////////////////////////////
@@ -399,11 +402,16 @@
public void endDocument ()
throws SAXException
{
- if(0 == m_stylesheetLevel)
- getStylesheetRoot().recompose();
-
- // Resolve the result prefix tables in the elements.
- getStylesheet().resolvePrefixTables();
+ if(null != getStylesheetRoot())
+ {
+ if(0 == m_stylesheetLevel)
+ getStylesheetRoot().recompose();
+
+ // Resolve the result prefix tables in the elements.
+ getStylesheet().resolvePrefixTables();
+ }
+ else
+ throw new SAXException("Did not find the stylesheet root!");
XSLTElementProcessor elemProcessor = getCurrentProcessor();
if(null != elemProcessor)
@@ -464,8 +472,7 @@
if(null != elemProcessor)
elemProcessor.startNonText(this);
}
-
-
+
/**
* Receive notification of the start of an element.
*
@@ -479,6 +486,11 @@
String rawName, Attributes attributes)
throws SAXException
{
+ m_elementID++;
+ checkForFragmentID(attributes);
+
+ if(!m_shouldProcess)
+ return;
flushCharacters();
XSLTElementProcessor elemProcessor = getProcessorFor( uri, localName,
rawName );
this.pushProcessor(elemProcessor);
@@ -499,8 +511,14 @@
public void endElement (String uri, String localName, String rawName)
throws SAXException
{
+ m_elementID--;
+ if(!m_shouldProcess)
+ return;
+ if((m_elementID+1) == m_fragmentID)
+ m_shouldProcess = false;
flushCharacters();
- getCurrentProcessor().endElement (this, uri, localName, rawName);
+ XSLTElementProcessor p = getCurrentProcessor();
+ p.endElement (this, uri, localName, rawName);
this.popProcessor();
m_nsSupport.popContext();
}
@@ -533,6 +551,8 @@
public void characters (char ch[], int start, int length)
throws SAXException
{
+ if(!m_shouldProcess)
+ return;
XSLTElementProcessor elemProcessor = getCurrentProcessor();
XSLTElementDef def = elemProcessor.getElemDef();
if(def.getType() != XSLTElementDef.T_PCDATA)
@@ -562,6 +582,8 @@
public void ignorableWhitespace (char ch[], int start, int length)
throws SAXException
{
+ if(!m_shouldProcess)
+ return;
getCurrentProcessor().ignorableWhitespace (this, ch, start, length);
}
@@ -584,6 +606,8 @@
public void processingInstruction (String target, String data)
throws SAXException
{
+ if(!m_shouldProcess)
+ return;
flushCharacters();
getCurrentProcessor().processingInstruction (this, target, data);
}
@@ -605,6 +629,8 @@
public void skippedEntity (String name)
throws SAXException
{
+ if(!m_shouldProcess)
+ return;
getCurrentProcessor().skippedEntity (this, name);
}
@@ -739,6 +765,64 @@
throw e;
}
+ /**
+ * If we have a URL to a XML fragment, this is set
+ * to false until the ID is found.
+ * (warning: I worry that this should be in a stack).
+ */
+ private boolean m_shouldProcess = true;
+
+ /**
+ * If we have a URL to a XML fragment, the value is stored
+ * in this string, and the m_shouldProcess flag is set to
+ * false until we match an ID with this string.
+ * (warning: I worry that this should be in a stack).
+ */
+ private String m_fragmentIDString;
+
+ /**
+ * Keep track of the elementID, so we can tell when
+ * is has completed. This isn't a real ID, but rather
+ * a nesting level. However, it's good enough for
+ * our purposes.
+ * (warning: I worry that this should be in a stack).
+ */
+ private int m_elementID = 0;
+
+ /**
+ * The ID of the fragment that has been found
+ * (warning: I worry that this should be in a stack).
+ */
+ private int m_fragmentID = 0;
+
+ /**
+ * Check to see if an ID attribute matched the #id, called
+ * from startElement.
+ */
+ private void checkForFragmentID(Attributes attributes)
+ {
+ if(!m_shouldProcess)
+ {
+ if((null != attributes) && (null != m_fragmentIDString))
+ {
+ int n = attributes.getLength();
+ for(int i = 0; i < n; i++)
+ {
+ String type = attributes.getType(i);
+ if(type.equalsIgnoreCase("ID"))
+ {
+ String val = attributes.getValue(i);
+ if(val.equalsIgnoreCase(m_fragmentIDString))
+ {
+ m_shouldProcess = true;
+ m_fragmentID = m_elementID;
+ }
+ }
+ }
+ }
+ }
+ }
+
/**
* The XSLT Processor for needed services.
*/
@@ -794,7 +878,8 @@
*/
public StylesheetRoot getStylesheetRoot()
{
- return (StylesheetRoot)m_stylesheets.elementAt(0);
+ return (m_stylesheets.size() > 0)
+ ? (StylesheetRoot)m_stylesheets.elementAt(0) : null;
}
/**
@@ -930,9 +1015,22 @@
/**
* Push a base identifier onto the base URI stack.
*/
- void pushBaseIndentifier(String base)
+ void pushBaseIndentifier(String baseID)
{
- m_baseIdentifiers.push(base);
+ if(null != baseID)
+ {
+ int posOfHash = baseID.indexOf('#');
+ if(posOfHash > -1)
+ {
+ m_fragmentIDString = baseID.substring(posOfHash+1);
+ m_shouldProcess = false;
+ }
+ else
+ m_shouldProcess = true;
+ }
+ else
+ m_shouldProcess = true;
+ m_baseIdentifiers.push(baseID);
}
/**
1.2 +58 -1
xml-xalan/java/src/org/apache/xalan/processor/StylesheetPIHandler.java
Index: StylesheetPIHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetPIHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StylesheetPIHandler.java 2000/07/18 01:30:38 1.1
+++ StylesheetPIHandler.java 2000/10/11 03:36:04 1.2
@@ -1,3 +1,59 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
package org.apache.xalan.processor;
import org.xml.sax.helpers.DefaultHandler;
@@ -91,6 +147,7 @@
{
href = tokenizer.nextToken();
href = href.substring(1, href.length()-1);
+
href = SystemIDResolver.getAbsoluteURI(href,
m_source.getSystemId());
}
else if(name.equals("title"))
@@ -161,7 +218,7 @@
String qName, Attributes atts)
throws SAXException
{
- throw new SAXException(STARTELEM_FOUND_MSG);
+ throw new StopParseException();
}
}
1.7 +41 -10
xml-xalan/java/src/org/apache/xalan/processor/StylesheetProcessor.java
Index: StylesheetProcessor.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetProcessor.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StylesheetProcessor.java 2000/10/09 23:25:15 1.6
+++ StylesheetProcessor.java 2000/10/11 03:36:04 1.7
@@ -56,7 +56,6 @@
*/
package org.apache.xalan.processor;
-import java.io.IOException;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.XMLReader;
@@ -67,6 +66,7 @@
import org.w3c.dom.Node;
import org.apache.xalan.utils.TreeWalker;
+import org.apache.xalan.utils.SystemIDResolver;
import trax.Processor;
import trax.ProcessorException;
@@ -76,6 +76,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedInputStream;
+import java.io.StringWriter;
+import java.io.PrintWriter;
+import java.io.StringReader;
import java.util.Properties;
import java.util.Enumeration;
@@ -164,7 +167,7 @@
reader.parse(source);
return builder.getTemplates();
}
-
+
/**
* Process the stylesheet from a DOM tree, if the
* processor supports the "http://xml.org/trax/features/dom/input"
@@ -234,7 +237,33 @@
public Templates processMultiple(InputSource[] source)
throws ProcessorException
{
- return null;
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.println("<?xml version='1.0'?>");
+ pw.println("<xsl:stylesheet
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">");
+ int n = source.length;
+ for(int i = 0; i < n; i++)
+ {
+ pw.print("<xsl:import href=\"");
+ pw.print(source[i].getSystemId());
+ pw.println("\"/>");
+ }
+ pw.println("</xsl:stylesheet>");
+ pw.close();
+ String stylesheetString = sw.toString();
+ StringReader reader = new StringReader(stylesheetString);
+ try
+ {
+ return this.process(new InputSource(reader));
+ }
+ catch(ProcessorException e)
+ {
+ throw e;
+ }
+ catch(Exception e)
+ {
+ throw new ProcessorException("processMultiple failed", e);
+ }
}
/**
@@ -272,20 +301,22 @@
{
reader = XMLReaderFactory.createXMLReader();
}
+
+ // Need to set options!
reader.setContentHandler(handler);
reader.parse(source);
}
- catch(IOException ioe)
+ catch(StopParseException spe)
{
- throw new ProcessorException("getAssociatedStylesheets failed", ioe);
+ // OK, good.
}
catch(SAXException se)
{
- String msg = se.getMessage();
- if((null == msg) ||
!msg.equals(StylesheetPIHandler.STARTELEM_FOUND_MSG))
- {
- throw new ProcessorException("getAssociatedStylesheets failed", se);
- }
+ throw new ProcessorException("getAssociatedStylesheets failed", se);
+ }
+ catch(IOException ioe)
+ {
+ throw new ProcessorException("getAssociatedStylesheets failed", ioe);
}
return handler.getAssociatedStylesheets();
}
1.3 +40 -5
xml-xalan/java/src/org/apache/xalan/processor/XSLTElementProcessor.java
Index: XSLTElementProcessor.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/XSLTElementProcessor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSLTElementProcessor.java 2000/08/29 20:03:06 1.2
+++ XSLTElementProcessor.java 2000/10/11 03:36:04 1.3
@@ -69,6 +69,8 @@
import org.apache.xalan.res.XSLMessages;
import org.apache.xalan.res.XSLTErrorResources;
+import org.xml.sax.helpers.AttributesImpl;
+
import java.util.Vector;
/**
@@ -292,7 +294,30 @@
Object target)
throws SAXException
{
+ setPropertiesFromAttributes(handler, rawName, attributes, target, true);
+ }
+
+ /**
+ * Set the properties of an object from the given attribute list.
+ * @param handler The stylesheet's Content handler, needed for
+ * error reporting.
+ * @param rawName The raw name of the owner element, needed for
+ * error reporting.
+ * @param attributes The list of attributes.
+ * @param target The target element where the properties will be set.
+ * @param throwError True if it should throw an error if an
+ * attribute is not defined.
+ * @return the attributes not allowed on this element.
+ */
+ Attributes setPropertiesFromAttributes(StylesheetHandler handler,
+ String rawName,
+ Attributes attributes,
+ Object target,
+ boolean throwError)
+ throws SAXException
+ {
XSLTElementDef def = getElemDef();
+ AttributesImpl undefines = throwError ? null : new AttributesImpl();
// Keep track of which XSLTAttributeDefs have been processed, so
// I can see which default values need to be set.
@@ -306,10 +331,20 @@
if(null == attrDef)
{
- // Then barf, because this element does not allow this attribute.
- handler.error(attributes.getQName(i)+
- "attribute is not allowed on the "+
- rawName+" element!", null);
+ if(throwError)
+ {
+ // Then barf, because this element does not allow this attribute.
+ handler.error(attributes.getQName(i)+
+ "attribute is not allowed on the "+
+ rawName+" element!", null);
+ }
+ else
+ {
+ undefines.addAttribute(attrUri, attrLocalName,
+ attributes.getQName(i),
+ attributes.getType(i),
+ attributes.getValue(i));
+ }
}
else
{
@@ -340,7 +375,7 @@
handler.error(XSLMessages.createMessage(XSLTErrorResources.ER_REQUIRES_ATTRIB,
new Object[]{rawName, attrDef.getName()}) , null);
}
}
-
+ return undefines;
}
}
1.1
xml-xalan/java/src/org/apache/xalan/processor/StopParseException.java
Index: StopParseException.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xalan.processor;
import org.xml.sax.SAXException;
public class StopParseException extends SAXException
{
StopParseException()
{
super("Stylesheet PIs found, stop the parse");
}
}
1.12 +13 -0
xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
Index: ElemTemplateElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ElemTemplateElement.java 2000/10/10 22:12:32 1.11
+++ ElemTemplateElement.java 2000/10/11 03:36:10 1.12
@@ -567,6 +567,17 @@
public void setPrefixes(NamespaceSupport nsSupport)
throws SAXException
{
+ setPrefixes(nsSupport, false);
+ }
+
+ /**
+ * From the SAX2 helper class, set the namespace table for
+ * this element. Take care to call resolveInheritedNamespaceDecls.
+ * after all namespace declarations have been added.
+ */
+ public void setPrefixes(NamespaceSupport nsSupport, boolean excludeXSLDecl)
+ throws SAXException
+ {
Enumeration decls = nsSupport.getDeclaredPrefixes ();
while(decls.hasMoreElements())
{
@@ -574,6 +585,8 @@
if(null == m_declaredPrefixes)
m_declaredPrefixes = new Vector();
String uri = nsSupport.getURI(prefix);
+ if(excludeXSLDecl && uri.equals(Constants.S_XSLNAMESPACEURL))
+ continue;
// System.out.println("setPrefixes - "+prefix+", "+uri);
XMLNSDecl decl = new XMLNSDecl(prefix, uri, false);
m_declaredPrefixes.addElement(decl);
1.10 +18 -9 xml-xalan/java/src/org/apache/xalan/xslt/Process.java
Index: Process.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/Process.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Process.java 2000/10/09 23:25:21 1.9
+++ Process.java 2000/10/11 03:36:10 1.10
@@ -393,7 +393,9 @@
dumpWriter = new PrintWriter( new FileWriter(dumpFileName) );
}
- Templates stylesheet = processor.process(new
InputSource(xslFileName));
+ Templates stylesheet = (null != xslFileName)
+ ? processor.process(new
InputSource(xslFileName))
+ : null;
PrintWriter resultWriter;
@@ -405,12 +407,18 @@
// document?
if(null == stylesheet)
{
- InputSource[] sources = processor.getAssociatedStylesheets(new
InputSource(inFileName),
- media,
null, null);
- if(null != sources)
+ InputSource[] sources
+ = processor.getAssociatedStylesheets(new InputSource(inFileName),
+ media, null, null);
+ if((null != sources) && (sources.length > 0))
stylesheet = processor.processMultiple(sources);
else
- throw new SAXException("No stylesheet found for media: "+media);
+ {
+ if(null != media)
+ throw new SAXException("No stylesheet found in:
"+inFileName+", media="+media);
+ else
+ throw new SAXException("No xml-stylesheet PI found in:
"+inFileName);
+ }
}
if(null != stylesheet)
@@ -501,13 +509,14 @@
)
doStackDumpOnError = true;
-
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR,
null)
- +" ("+throwable.getClass().getName()+"): "
- + throwable.getMessage());
if(doStackDumpOnError)
throwable.printStackTrace(dumpWriter);
+ else
+
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_XSLT_ERROR,
null)
+ +" ("+throwable.getClass().getName()+"):
"
+ + throwable.getMessage());
-
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL,
null)); //"XSL Process was not successful.");
+ //
diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL,
null)); //"XSL Process was not successful.");
if(null != dumpFileName)
{
dumpWriter.close();