vgritsenko 02/01/25 18:12:34
Modified: src/java/org/apache/cocoon/components/language/markup
AbstractMarkupLanguage.java Logicsheet.java
LogicsheetCodeGenerator.java NamedLogicsheet.java
src/java/org/apache/cocoon/components/language/markup/sitemap
SitemapMarkupLanguage.java
src/java/org/apache/cocoon/components/language/markup/xsp
XSPMarkupLanguage.java
Log:
Fixing XSP Engine:
- languages are recycleable, to recycle logicSheetList
- do not use temporary resolver (HttpEnvironment) to resolve inclusions
in logicsheets, as logicsheet is cached
- instead, url source factory resolver is used
Revision Changes Path
1.3 +164 -141
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/AbstractMarkupLanguage.java
Index: AbstractMarkupLanguage.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/AbstractMarkupLanguage.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractMarkupLanguage.java 25 Jan 2002 03:38:36 -0000 1.2
+++ AbstractMarkupLanguage.java 26 Jan 2002 02:12:33 -0000 1.3
@@ -5,7 +5,6 @@
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
-
package org.apache.cocoon.components.language.markup;
import org.apache.avalon.framework.component.ComponentException;
@@ -16,19 +15,33 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.excalibur.pool.Recyclable;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
import org.apache.cocoon.components.store.Store;
import org.apache.cocoon.components.url.URLFactory;
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
-import org.xml.sax.*;
+import org.apache.cocoon.environment.URLFactorySourceResolver;
+
import org.xml.sax.helpers.XMLFilterImpl;
import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLFilter;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.Attributes;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.util.*;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
/**
* Base implementation of <code>MarkupLanguage</code>. This class uses
@@ -38,18 +51,21 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ovidiu Predescu</a>
- * @version CVS $Revision: 1.2 $ $Date: 2002/01/25 03:38:36 $
+ * @version CVS $Revision: 1.3 $ $Date: 2002/01/26 02:12:33 $
*/
public abstract class AbstractMarkupLanguage extends AbstractLoggable
- implements MarkupLanguage, Composable, Configurable
+ implements MarkupLanguage, Composable, Configurable, Recyclable
{
/** The 'file' URL protocol. */
private static final String FILE = "file:";
+ /** Prefix for cache keys to avoid name clash with the XSLTProcessor */
+ private static final String CACHE_PREFIX = "logicsheet:";
+
/** The supported language table */
protected Hashtable languages;
- /** The in-memory code-generation logicsheet cache */
+ /** The code-generation logicsheet cache */
protected Store logicsheetCache;
/** The markup language's namespace uri */
@@ -61,13 +77,18 @@
/** The component manager */
protected ComponentManager manager;
- /** Prefix for cache keys to avoid name clash with the XSLTProcessor */
- private static final String CACHE_PREFIX = "logicsheet:";
-
/**
* The URL factory used to resolve URIs.
*/
- URLFactory urlFactory;
+ private URLFactorySourceResolver urlResolver;
+
+ private final LinkedList logicSheetList = new LinkedList();
+
+
+ public void recycle()
+ {
+ this.logicSheetList.clear();
+ }
/**
* Set the global component manager.
@@ -79,8 +100,9 @@
// Initialize logicsheet cache
this.logicsheetCache = (Store) manager.lookup(Store.ROLE);
- // Initialize the URL factory
- urlFactory = (URLFactory)this.manager.lookup(URLFactory.ROLE);
+ // Initialize the URL factory source resolver
+ URLFactory urlFactory = (URLFactory)this.manager.lookup(URLFactory.ROLE);
+ this.urlResolver = new URLFactorySourceResolver(urlFactory, manager);
}
/** The default constructor. */
@@ -99,84 +121,83 @@
this.prefix = params.getParameter("prefix", null);
}
- /**
- * Process additional configuration. Load supported programming
- * language definitions
- *
- * @param conf The language configuration
- * @exception ConfigurationException If an error occurs loading logichseets
- */
- public void configure(Configuration conf) throws ConfigurationException {
- try {
- // Set up each target-language
- Configuration[] l = conf.getChildren("target-language");
- for (int i = 0; i < l.length; i++) {
- LanguageDescriptor language = new LanguageDescriptor();
- language.setName(l[i].getAttribute("name"));
- Parameters lcp = Parameters.fromConfiguration(l[i]);
+ /**
+ * Process additional configuration. Load supported programming
+ * language definitions
+ *
+ * @param conf The language configuration
+ * @exception ConfigurationException If an error occurs loading logichseets
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+ try {
+ // Set up each target-language
+ Configuration[] l = conf.getChildren("target-language");
+ for (int i = 0; i < l.length; i++) {
+ LanguageDescriptor language = new LanguageDescriptor();
+ language.setName(l[i].getAttribute("name"));
+
+ // Create & Store the core logicsheet
+ Logicsheet logicsheet = createLogicsheet(l[i], false);
+ language.setLogicsheet(logicsheet.getSystemId());
+
+ // Set up each built-in logicsheet
+ Configuration[] n = l[i].getChildren("builtin-logicsheet");
+ for (int j = 0; j < n.length; j++) {
+ // Create & Store the named logicsheets
+ NamedLogicsheet namedLogicsheet =
+ (NamedLogicsheet) createLogicsheet(n[j], true);
+
+ // FIXME: Logicsheets should be found by uri--not prefix.
+ language.addNamedLogicsheet(
+ namedLogicsheet.getPrefix(),
+ namedLogicsheet.getSystemId());
+ }
+
+ this.languages.put(language.getName(), language);
+ }
+ } catch (Exception e) {
+ getLogger().warn("Configuration Error: " + e.getMessage(), e);
+ throw new ConfigurationException("AbstractMarkupLanguage: "
+ + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Abstract out the Logicsheet creation. Handles both Named and regular
logicsheets.
+ */
+ private Logicsheet createLogicsheet(Configuration configuration, boolean named)
+ throws Exception
+ {
+ Parameters params = Parameters.fromConfiguration(configuration);
+
+ Logicsheet logicsheet;
+ if (named) {
+ String location = params.getParameter("href", null);
+ String prefix = params.getParameter("prefix", null);
+
+ NamedLogicsheet namedLogicsheet =
+ new NamedLogicsheet(location, manager, urlResolver);
+ namedLogicsheet.setLogger(getLogger());
+ namedLogicsheet.setPrefix(prefix);
+ logicsheet = namedLogicsheet;
+ } else {
+ String location = params.getParameter("core-logicsheet", null);
+ logicsheet = new Logicsheet(location, manager, urlResolver);
+ logicsheet.setLogger(getLogger());
+ }
- // Create & Store the core logicsheet
- Logicsheet logicsheet = createLogicsheet(lcp, false);
String logicsheetName = logicsheet.getSystemId();
logicsheetCache.store(CACHE_PREFIX + logicsheetName, logicsheet);
- language.setLogicsheet(logicsheetName);
- // Set up each built-in logicsheet
- Configuration[] n = l[i].getChildren("builtin-logicsheet");
- for (int j = 0; j < n.length; j++) {
- Parameters ncp = Parameters.fromConfiguration(n[j]);
-
- // Create & Store the named logicsheets
- NamedLogicsheet namedLogicsheet
- = (NamedLogicsheet)createLogicsheet(ncp, true);
- logicsheetName = namedLogicsheet.getSystemId();
- String logicsheetPrefix = namedLogicsheet.getPrefix();
- logicsheetCache.store(CACHE_PREFIX + logicsheetName, namedLogicsheet);
-
- // FIXME: Logicsheets should be found by uri--not prefix.
- language.addNamedLogicsheet(logicsheetPrefix, logicsheetName);
- }
- this.languages.put(language.getName(), language);
- }
- } catch (Exception e) {
- getLogger().warn("Configuration Error: " + e.getMessage(), e);
- throw new ConfigurationException("AbstractMarkupLanguage: "
- + e.getMessage(), e);
- }
- }
-
- /**
- * Abstract out the Logicsheet creation. Handles both Named and regular
logicsheets.
- */
- private Logicsheet createLogicsheet(Parameters params, boolean named)
- throws Exception
- {
- String logicsheetLocation;
- Logicsheet logicsheet;
-
- if (named) {
- logicsheetLocation = params.getParameter("href", null);
-
- NamedLogicsheet namedLogicsheet = new NamedLogicsheet(logicsheetLocation,
- urlFactory,
- manager);
- namedLogicsheet.setLogger(getLogger());
- namedLogicsheet.setPrefix(params.getParameter("prefix", null));
- logicsheet = namedLogicsheet;
- } else {
- logicsheetLocation = params.getParameter("core-logicsheet", null);
- logicsheet = new Logicsheet(logicsheetLocation, urlFactory, manager);
- logicsheet.setLogger(getLogger());
+ return logicsheet;
}
- return logicsheet;
- }
-
/**
* Return the source document's encoding. This can be <code>null</code> for
* the platform's default encoding. The default implementation returns
- * <code>null, but derived classes may override it if encoding applies to
- * their concrete languages. FIXME: There should be a way to get the
+ * <code>null</code>, but derived classes may override it if encoding applies to
+ * their concrete languages.
+ * FIXME: There should be a way to get the
* XML document's encoding as seen by the parser; unfortunately, this
* information is not returned by current DOM or SAX parsers...
* @return The document-specified encoding
@@ -201,8 +222,8 @@
(LogicsheetCodeGenerator logicsheetMarkupGenerator,
SourceResolver resolver)
{
- return new TransformerChainBuilderFilter(logicsheetMarkupGenerator,
- resolver);
+ return new TransformerChainBuilderFilter(logicsheetMarkupGenerator,
+ resolver);
}
/**
@@ -274,14 +295,12 @@
return codeGenerator.generateCode(tranBuilder, input, filename);
}
- LinkedList logicSheetList = new LinkedList();
-
/**
* Add logicsheet list to the code generator.
* @param codeGenerator The code generator
*/
protected void addLogicsheetsToGenerator(LogicsheetCodeGenerator codeGenerator)
- throws MalformedURLException, IOException, SAXException {
+ throws MalformedURLException, IOException, SAXException,
ProcessingException {
if (codeGenerator == null) {
getLogger().debug("This should never happen: codeGenerator is null");
@@ -290,14 +309,14 @@
// Walk backwards and remove duplicates.
LinkedList newLogicSheetList = new LinkedList();
- for(int i = logicSheetList.size()-1;i>=0;i--) {
+ for(int i = logicSheetList.size()-1; i>=0; i--) {
Logicsheet logicsheet = (Logicsheet) logicSheetList.get(i);
if(newLogicSheetList.indexOf(logicsheet) == -1)
newLogicSheetList.addFirst(logicsheet);
}
// Add the list of logicsheets now.
- ListIterator iterator = newLogicSheetList.listIterator();
+ Iterator iterator = newLogicSheetList.iterator();
while(iterator.hasNext()) {
Logicsheet logicsheet = (Logicsheet) iterator.next();
codeGenerator.addLogicsheet(logicsheet);
@@ -312,56 +331,58 @@
* @exception IOException IO Error
* @exception SAXException Logicsheet parse error
*/
- protected void addLogicsheetToList(LanguageDescriptor language,
- String logicsheetLocation,
- SourceResolver resolver)
- throws MalformedURLException, IOException, SAXException, ProcessingException
- {
- Logicsheet logicsheet = (Logicsheet)logicsheetCache.get(CACHE_PREFIX +
logicsheetLocation);
-
- String logicsheetName;
- if (logicsheet == null) {
- Source inputSource = resolver.resolve(logicsheetLocation);
- logicsheet = new Logicsheet(inputSource, manager, resolver);
- logicsheetName = logicsheet.getSystemId();
- logicsheetCache.store(CACHE_PREFIX + logicsheetName, logicsheet);
- // FIXME(VG): inputSource.recylce() !!!
- } else {
- logicsheetName = logicsheet.getSystemId();
- }
-
- getLogger().debug("AbstractMarkupLanguage addLogicsheetToList: "
- + "name: " + logicsheetName
- + ", location: " + logicsheetLocation
- + ", instance: " + logicsheet);
-
- if (logicsheetName.startsWith(FILE)) {
- String filename = logicsheetName.substring(FILE.length());
- addDependency(filename);
- getLogger().debug("AbstractMarkupLanguage addLogicsheetToList: "
- + "adding dependency on file " + filename);
- }
-
- logicSheetList.add(logicsheet);
-
- Map namespaces = logicsheet.getNamespaces();
- if(!logicsheetLocation.equals(language.getLogicsheet())) {
- if(namespaces != null && namespaces.size()>0) {
- Iterator iter = namespaces.keySet().iterator();
- while(iter.hasNext()) {
- String namespace = (String) iter.next();
- String namedLogicsheetName = language.getNamedLogicsheet(namespace);
- if(namedLogicsheetName!= null
- && !logicsheetLocation.equals(namedLogicsheetName)) {
- getLogger().debug("Adding embedded logic sheet for "
- + namespace + ":" + namedLogicsheetName);
- // Add embedded logic sheets too.
- addLogicsheetToList(language, namedLogicsheetName, resolver);
- }
+ protected void addLogicsheetToList(LanguageDescriptor language,
+ String logicsheetLocation,
+ SourceResolver resolver)
+ throws MalformedURLException, IOException, SAXException, ProcessingException
+ {
+ Logicsheet logicsheet = (Logicsheet)logicsheetCache.get(CACHE_PREFIX +
logicsheetLocation);
+ if (logicsheet == null) {
+ Source inputSource = resolver.resolve(logicsheetLocation);
+ // FIXME(VG): resolver (local) could not be used as it is temporary
+ // (per-request) object, yet Logicsheet is being cached and reused
+ // across multiple requests. "Global" url-factory-based resolver
+ // passed to the Logicsheet.
+ logicsheet = new Logicsheet(inputSource, manager, this.urlResolver);
+ logicsheetCache.store(CACHE_PREFIX + logicsheet.getSystemId(),
logicsheet);
+ }
+ String logicsheetName = logicsheet.getSystemId();
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("addLogicsheetToList: "
+ + "name: " + logicsheetName
+ + ", location: " + logicsheetLocation
+ + ", instance: " + logicsheet);
+ }
+
+ if (logicsheetName.startsWith(FILE)) {
+ String filename = logicsheetName.substring(FILE.length());
+ addDependency(filename);
+ getLogger().debug("addLogicsheetToList: "
+ + "adding dependency on file " + filename);
+ }
+
+ logicSheetList.add(logicsheet);
+
+ Map namespaces = logicsheet.getNamespaces();
+ if(!logicsheetLocation.equals(language.getLogicsheet())) {
+ if(namespaces != null && namespaces.size() > 0) {
+ Iterator iter = namespaces.keySet().iterator();
+ while(iter.hasNext()) {
+ String namespace = (String) iter.next();
+ String namedLogicsheetName =
language.getNamedLogicsheet(namespace);
+ if(namedLogicsheetName!= null
+ && !logicsheetLocation.equals(namedLogicsheetName)) {
+ getLogger().debug("Adding embedded logic sheet for "
+ + namespace + ":" + namedLogicsheetName);
+ // Add embedded logic sheets too.
+ addLogicsheetToList(language, namedLogicsheetName,
resolver);
+ }
+ }
+ }
}
- }
}
- }
+
//
// Inner classes
//
@@ -481,11 +502,11 @@
if (!isRootElem) {
super.startPrefixMapping(prefix, uri);
} else {
- // cache the prefix mapping
- String[] prefixArray = new String[2];
- prefixArray[0] = prefix;
- prefixArray[1] = uri;
- this.startPrefixes.add(prefixArray);
+ // Cache the prefix mapping
+ String[] prefixNamingArray = new String[2];
+ prefixNamingArray[0] = prefix;
+ prefixNamingArray[1] = uri;
+ this.startPrefixes.add(prefixNamingArray);
}
}
@@ -503,6 +524,7 @@
AbstractMarkupLanguage.this.addLogicsheetToList(language, namedLogicsheetName,
resolver);
}
}
+
// Add the language stylesheet (Always the last one)
AbstractMarkupLanguage.this.addLogicsheetToList(language,
this.language.getLogicsheet(), resolver);
AbstractMarkupLanguage.this.addLogicsheetsToGenerator(this.logicsheetMarkupGenerator);
@@ -511,6 +533,7 @@
} catch (IOException ioe) {
throw new SAXException(ioe);
}
+
// All stylesheet have been configured and correctly setup.
// Starts firing SAX events, especially the startDocument event,
// and the cached prefixNaming.
1.3 +104 -144
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/Logicsheet.java
Index: Logicsheet.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/Logicsheet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Logicsheet.java 25 Jan 2002 03:38:36 -0000 1.2
+++ Logicsheet.java 26 Jan 2002 02:12:33 -0000 1.3
@@ -5,18 +5,17 @@
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
-
package org.apache.cocoon.components.language.markup;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.AbstractLoggable;
-import org.apache.cocoon.components.source.URLSource;
-import org.apache.cocoon.components.url.URLFactory;
+
import org.apache.cocoon.components.xslt.XSLTProcessor;
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.environment.URLFactorySourceResolver;
+import org.apache.cocoon.ProcessingException;
+
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.XMLFilter;
@@ -41,166 +40,127 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ovidiu Predescu</a>
- * @version CVS $Revision: 1.2 $ $Date: 2002/01/25 03:38:36 $
+ * @version CVS $Revision: 1.3 $ $Date: 2002/01/26 02:12:33 $
*/
public class Logicsheet extends AbstractLoggable
{
- /**
- * The Source object for this logicsheet.
- */
- Source source;
-
- /**
- * the template namespace's list
- */
- protected Map namespaces = new HashMap();
-
- /**
- * The {@link org.apache.cocoon.components.xslt.XSLTProcessor} component.
- */
- XSLTProcessor xsltProcessor;
-
- /**
- * The ComponentManager of this instance.
- */
- ComponentManager manager;
-
- public Logicsheet(Source source, ComponentManager manager, SourceResolver
resolver)
- {
- this.source = source;
- this.manager = manager;
- try {
- xsltProcessor = (XSLTProcessor)manager.lookup(XSLTProcessor.ROLE);
- xsltProcessor.setSourceResolver(resolver);
- }
- catch (ComponentException e) {
- getLogger().error("Cannot obtain XSLTProcessor component: " + e);
- }
- }
-
- /**
- * Creates a new <code>Logicsheet</code> instance given an URL to
- * containing the logicsheet, the {@link
- * org.apache.cocoon.components.url.URLFactory}, and a
- * <code>ComponentManager</code>.
- *
- * @param url an <code>URL</code> value
- * @param urlFactory an <code>URLFactory</code> value
- * @exception MalformedURLException if an error occurs
- * @exception IOException if an error occurs
- */
- public Logicsheet(URL url, URLFactory urlFactory, ComponentManager manager)
- throws MalformedURLException, IOException
- {
- this(url.toString(), urlFactory, manager);
- }
-
- public Logicsheet(String systemId, URLFactory urlFactory,
- ComponentManager manager)
- throws MalformedURLException, IOException
- {
- this.manager = manager;
- URL url = urlFactory.getURL(systemId);
- this.source = new URLSource(url, manager);
- try {
- xsltProcessor = (XSLTProcessor)manager.lookup(XSLTProcessor.ROLE);
- xsltProcessor.setSourceResolver(new URLFactorySourceResolver(urlFactory,
manager));
- }
- catch (ComponentException e) {
- getLogger().error("Cannot obtain XSLTProcessor component: " + e);
- }
- }
-
- public String getSystemId()
- {
- return source.getSystemId();
- }
-
- /**
- * This will return the list of namespaces in this logicsheet.
- */
- public Map getNamespaces()
- {
- // Force the parsing of the Source or, if nothing changed,
- // return the old content of namespaces.
- getTransformerHandler();
- return namespaces;
- }
-
- /**
- * Obtain the TransformerHandler object that will perform the
- * transformation associated with this logicsheet.
- *
- * @return a <code>TransformerHandler</code> value
- */
- public TransformerHandler getTransformerHandler()
- {
- try {
- // If the Source object is not changed, the
- // getTransformerHandler() of XSLTProcessor will simply return
- // the old template object. If the Source is unchanged, the
- // namespaces are not modified either.
- XMLFilter saveNSFilter = new SaveNamespaceFilter(namespaces);
- return xsltProcessor.getTransformerHandler(source, saveNSFilter);
- } catch (Exception e) {
- getLogger().error("Logicsheet.getTransformerHandler: Exception ", e);
- }
- return null;
- }
-
- /**
- * This filter listen for source SAX events, and register the declared
- * namespaces into a <code>Map</code> object.
- *
- */
- protected class SaveNamespaceFilter extends XMLFilterImpl
- {
- private Map originalNamepaces;
-
- /**
- * The contructor needs an initialized <code>Map</code> object where it
- * can store the found namespace declarations.
- * @param originalNamepaces a initialized <code>Map</code> instance.
+ /**
+ * The Source object for this logicsheet.
+ */
+ private Source source;
+
+ /**
+ * the template namespace's list
+ */
+ protected Map namespaces = new HashMap();
+
+ /**
+ * The {@link org.apache.cocoon.components.xslt.XSLTProcessor} component.
+ */
+ private XSLTProcessor xsltProcessor;
+
+ /**
+ * The ComponentManager of this instance.
*/
- public SaveNamespaceFilter(Map originalNamepaces)
+ private ComponentManager manager;
+
+
+ public Logicsheet(Source source, ComponentManager manager, SourceResolver
resolver)
+ throws ProcessingException
+ {
+ this.source = source;
+ this.manager = manager;
+ try {
+ this.xsltProcessor = (XSLTProcessor)manager.lookup(XSLTProcessor.ROLE);
+ this.xsltProcessor.setSourceResolver(resolver);
+ } catch (ComponentException e) {
+ throw new ProcessingException("Could not obtain XSLT processor", e);
+ }
+ }
+
+ public Logicsheet(String systemId, ComponentManager manager, SourceResolver
resolver)
+ throws SAXException, IOException, ProcessingException
+ {
+ this(resolver.resolve(systemId), manager, resolver);
+ }
+
+ public String getSystemId()
{
- this.originalNamepaces = originalNamepaces;
+ return source.getSystemId();
}
/**
- * @param reader the parent reader
- * @see XMLFilter
+ * This will return the list of namespaces in this logicsheet.
*/
- public void setParent(XMLReader reader)
+ public Map getNamespaces() throws ProcessingException
{
- super.setParent(reader);
- reader.setContentHandler(this);
+ // Force the parsing of the Source or, if nothing changed,
+ // return the old content of namespaces.
+ getTransformerHandler();
+ return namespaces;
}
/**
- * @see org.xml.sax.ContentHandler
+ * Obtain the TransformerHandler object that will perform the
+ * transformation associated with this logicsheet.
+ *
+ * @return a <code>TransformerHandler</code> value
*/
- public void startDocument ()
- throws SAXException
+ public TransformerHandler getTransformerHandler() throws ProcessingException
{
- super.startDocument();
+ try {
+ // If the Source object is not changed, the
+ // getTransformerHandler() of XSLTProcessor will simply return
+ // the old template object. If the Source is unchanged, the
+ // namespaces are not modified either.
+ XMLFilter saveNSFilter = new SaveNamespaceFilter(namespaces);
+ return xsltProcessor.getTransformerHandler(source, saveNSFilter);
+ } finally {
+ // Release used resources
+ source.recycle();
+ }
}
/**
+ * This filter listen for source SAX events, and register the declared
+ * namespaces into a <code>Map</code> object.
+ *
+ * @see org.xml.sax.XMLFilter
* @see org.xml.sax.ContentHandler
*/
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException
- {
- originalNamepaces.put(prefix,uri);
- super.startPrefixMapping(prefix, uri);
- }
+ protected class SaveNamespaceFilter extends XMLFilterImpl {
+ private Map originalNamepaces;
- public void startElement (String namespaceURI, String localName,
- String qName, Attributes atts)
- throws SAXException
- {
- super.startElement(namespaceURI, localName, qName, atts);
+ /**
+ * The contructor needs an initialized <code>Map</code> object where it
+ * can store the found namespace declarations.
+ * @param originalNamepaces a initialized <code>Map</code> instance.
+ */
+ public SaveNamespaceFilter(Map originalNamepaces) {
+ this.originalNamepaces = originalNamepaces;
+ }
+
+ public void setParent(XMLReader reader) {
+ super.setParent(reader);
+ reader.setContentHandler(this);
+ }
+
+ public void startDocument() throws SAXException {
+ super.startDocument();
+ }
+
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException
+ {
+ originalNamepaces.put(prefix,uri);
+ super.startPrefixMapping(prefix, uri);
+ }
+
+ public void startElement (String namespaceURI, String localName,
+ String qName, Attributes atts)
+ throws SAXException
+ {
+ super.startElement(namespaceURI, localName, qName, atts);
+ }
}
- }
}
1.3 +18 -13
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java
Index: LogicsheetCodeGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LogicsheetCodeGenerator.java 25 Jan 2002 03:38:36 -0000 1.2
+++ LogicsheetCodeGenerator.java 26 Jan 2002 02:12:33 -0000 1.3
@@ -9,6 +9,8 @@
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.cocoon.util.TraxErrorHandler;
+import org.apache.cocoon.xml.LoggingContentHandler;
+import org.apache.cocoon.ProcessingException;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -24,6 +26,7 @@
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;
+import java.io.IOException;
import java.util.Properties;
/**
@@ -31,7 +34,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
- * @version CVS $Revision: 1.2 $ $Date: 2002/01/25 03:38:36 $
+ * @version CVS $Revision: 1.3 $ $Date: 2002/01/26 02:12:33 $
*/
public class LogicsheetCodeGenerator extends AbstractLoggable implements
MarkupCodeGenerator {
@@ -52,11 +55,9 @@
* Initialize the LogicsheetCodeGenerator.
*/
public void initialize() {
-
Properties format = new Properties();
-
try {
- // set the serializer which would act as ContentHandler for the last
transformer
+ // Set the serializer which would act as ContentHandler for the last
transformer
// FIXME (SSA) change a home made content handler, that extract the
PCDATA
// from the last remaining element
TransformerHandler handler =
getTransformerFactory().newTransformerHandler();
@@ -92,20 +93,19 @@
*
* @param logicsheet The logicsheet to be added
*/
- public void addLogicsheet(Logicsheet logicsheet) {
+ public void addLogicsheet(Logicsheet logicsheet) throws ProcessingException {
if (this.currentParent == null) {
// Setup the first transformer of the chain.
this.currentParent = logicsheet.getTransformerHandler();
// the parent is the rootReader
- this.rootReader.setContentHandler(this.currentParent);;
+ this.rootReader.setContentHandler(this.currentParent);
// Set content handler for the end of the chain : serializer
this.currentParent.setResult(new
SAXResult(this.serializerContentHandler));
-
} else {
// Build the transformer chain on the fly
- TransformerHandler newParent=logicsheet.getTransformerHandler();
+ TransformerHandler newParent = logicsheet.getTransformerHandler();
// the currentParent is the parent of the new logicsheet filter
this.currentParent.setResult(new SAXResult(newParent));
@@ -127,10 +127,15 @@
* @exception Exception If an error occurs during code generation
*/
public String generateCode(XMLReader reader, InputSource input, String
filename) throws Exception {
- // set the root XMLReader of the transformer chain
- this.rootReader = reader;
- // start the parsing
- this.rootReader.parse(input);
- return this.writer.toString();
+ try {
+ // set the root XMLReader of the transformer chain
+ this.rootReader = reader;
+ // start the parsing
+ this.rootReader.parse(input);
+ return this.writer.toString();
+ } catch (SAXException e) {
+ getLogger().debug("Got SAXException, rethrowing cause exception", e);
+ throw e.getException();
+ }
}
}
1.2 +10 -9
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/NamedLogicsheet.java
Index: NamedLogicsheet.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/NamedLogicsheet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NamedLogicsheet.java 3 Jan 2002 12:31:09 -0000 1.1
+++ NamedLogicsheet.java 26 Jan 2002 02:12:33 -0000 1.2
@@ -9,6 +9,8 @@
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.cocoon.components.url.URLFactory;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.SourceResolver;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -21,25 +23,24 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ovidiu Predescu</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:09 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/01/26 02:12:33 $
*/
public class NamedLogicsheet extends Logicsheet {
/**
* The namespace uri
*/
- protected String uri;
+ // FIXME: NOT USED: protected String uri;
/**
* The namespace prefix
*/
- protected String prefix;
+ private String prefix;
- public NamedLogicsheet(String systemId, URLFactory urlFactory,
- ComponentManager manager)
- throws MalformedURLException, IOException
- {
- super(systemId, urlFactory, manager);
- }
+ public NamedLogicsheet(String systemId, ComponentManager manager,
SourceResolver resolver)
+ throws MalformedURLException, IOException, ProcessingException
+ {
+ super(systemId, manager, resolver);
+ }
/**
* Set the logichseet's namespace prefix
1.2 +11 -4
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/sitemap/SitemapMarkupLanguage.java
Index: SitemapMarkupLanguage.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/sitemap/SitemapMarkupLanguage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SitemapMarkupLanguage.java 3 Jan 2002 12:31:10 -0000 1.1
+++ SitemapMarkupLanguage.java 26 Jan 2002 02:12:34 -0000 1.2
@@ -9,6 +9,7 @@
import org.apache.avalon.framework.logger.Loggable;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
import org.apache.cocoon.components.language.markup.LogicsheetCodeGenerator;
@@ -31,14 +32,20 @@
* <a
href="http://xml.apache.org/cocoon2/userdocs/concepts/sitemap.html">Sitemap</a>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:10 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/01/26 02:12:34 $
*/
-public class SitemapMarkupLanguage extends AbstractMarkupLanguage implements
ThreadSafe {
+public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
/**
- * the dependencies' list
- */
+ * The dependencies' list
+ */
private Set dependencies;
+
+ public void recycle()
+ {
+ super.recycle();
+ this.dependencies.clear();
+ }
/**
* The default constructor.
1.2 +107 -172
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPMarkupLanguage.java
Index: XSPMarkupLanguage.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPMarkupLanguage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSPMarkupLanguage.java 3 Jan 2002 12:31:10 -0000 1.1
+++ XSPMarkupLanguage.java 26 Jan 2002 02:12:34 -0000 1.2
@@ -9,6 +9,7 @@
import org.apache.avalon.framework.logger.Loggable;
import org.apache.avalon.excalibur.pool.Recyclable;
+
import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
@@ -16,6 +17,7 @@
import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.log.Logger;
+
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.XMLFilter;
@@ -32,101 +34,102 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Sahuc</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:10 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/01/26 02:12:34 $
*/
-public class XSPMarkupLanguage extends AbstractMarkupLanguage implements Recyclable
{
+public class XSPMarkupLanguage extends AbstractMarkupLanguage {
/**
- * store the dependencies.
- *
- * FIXME (SSA) Should not be shared between different calls.
- * Should be passed as argument of method getPreprocessFilter ?
- */
+ * store the dependencies.
+ *
+ * FIXME (SSA) Should not be shared between different calls.
+ * Should be passed as argument of method getPreprocessFilter ?
+ */
private Set dependencies;
public void recycle()
{
- dependencies.clear();
+ super.recycle();
+ this.dependencies.clear();
}
/**
- * The default constructor.
- */
+ * The default constructor.
+ */
public XSPMarkupLanguage() throws SAXException, IOException {
super();
dependencies = new HashSet();
}
/**
- * Return the XSP language name: <i>xsp</i> :-)
- *
- * @return The <i>xsp</i> constant
- */
+ * Return the XSP language name: <i>xsp</i> :-)
+ *
+ * @return The <i>xsp</i> constant
+ */
public String getName() {
return "xsp";
}
/**
- * FIXME (SSA) : See interface. For now returns null.
- *
- * Return the document-declared encoding or <code>null</code> if it's the
- * platform's default encoding
- *
- * @return The document-declared encoding
- */
+ * FIXME (SSA) : See interface. For now returns null.
+ *
+ * Return the document-declared encoding or <code>null</code> if it's the
+ * platform's default encoding
+ *
+ * @return The document-declared encoding
+ */
public String getEncoding() {
return null;
}
/**
- * Prepare the input source for logicsheet processing and code generation
- * with a preprocess filter.
- * The return <code>XMLFilter</code> object is the first filter on the
- * transformer chain.
- *
- * The XSP preprocess filter adds information on the root element such as
- * creation-date, file-name and file-path, plus it use the the passed
- * programming language to quote <code>Strings</code> on PCDATA node.
- *
- * @param filename The source filename
- * @param language The target programming language
- * @return The preprocess filter
- *
- * @see XSPMarkupLanguage.PreProcessFilter
- */
+ * Prepare the input source for logicsheet processing and code generation
+ * with a preprocess filter.
+ * The return <code>XMLFilter</code> object is the first filter on the
+ * transformer chain.
+ *
+ * The XSP preprocess filter adds information on the root element such as
+ * creation-date, file-name and file-path, plus it use the the passed
+ * programming language to quote <code>Strings</code> on PCDATA node.
+ *
+ * @param filename The source filename
+ * @param language The target programming language
+ * @return The preprocess filter
+ *
+ * @see XSPMarkupLanguage.PreProcessFilter
+ */
protected XMLFilter getPreprocessFilter( String filename, ProgrammingLanguage
language )
{
return new PreProcessFilter(filename, language);
}
/**
- * Add a dependency on an external file to the document for inclusion in
- * generated code. This is used to populate a list of <code>File</code>'s
- * tested for change on each invocation; this information is used to assert
- * whether regeneration is necessary. XSP uses <xsp:dependency>
- * elements for this purpose.
- *
- * @param location The file path of the dependent file
- * @see <code>AbstractMarkupLanguage</code>, <code>ServerPagesGenerator</code>
- * and <code>AbstractServerPage</code>
- */
+ * Add a dependency on an external file to the document for inclusion in
+ * generated code. This is used to populate a list of <code>File</code>'s
+ * tested for change on each invocation; this information is used to assert
+ * whether regeneration is necessary. XSP uses <xsp:dependency>
+ * elements for this purpose.
+ *
+ * @param location The file path of the dependent file
+ * @see <code>AbstractMarkupLanguage</code>, <code>ServerPagesGenerator</code>
+ * and <code>AbstractServerPage</code>
+ */
protected void addDependency(String location) {
dependencies.add(location);
}
/**
- * Returns a filter that chain on the fly the requested transformers for source
- * code generation. This method scans the input SAX events for
- * <?xml-logicsheet?> processing instructions and top-level
- * <xsp:logicsheet> elements. Logicsheet declarations are removed from
- * the input document.
- *
- * @param logicsheetMarkupGenerator the logicsheet markup generator
- * @param language the language descriptor
- * @param resolver the entity resolver
- * @return XMLFilter the filter that build on the fly the transformer chain
- */
+ * Returns a filter that chain on the fly the requested transformers for source
+ * code generation. This method scans the input SAX events for
+ * <?xml-logicsheet?> processing instructions and top-level
+ * <xsp:logicsheet> elements. Logicsheet declarations are removed from
+ * the input document.
+ *
+ * @param logicsheetMarkupGenerator the logicsheet markup generator
+ * @param language the language descriptor
+ * @param resolver the entity resolver
+ * @return XMLFilter the filter that build on the fly the transformer chain
+ */
protected TransformerChainBuilderFilter getTranformerChainBuilder (
LogicsheetCodeGenerator logicsheetMarkupGenerator,
SourceResolver resolver
@@ -137,49 +140,21 @@
);
}
- /**
- * FIXME (SSA) What do we do with that method ?
- * + Should we stay with the Text serializer that returns the wanted String,
- * + Or should we go along with another contentHandler that retrieve the PCDATA
- * from <xsp: element. The last option is way faster because it would avoid the
- * String construction, and would allow working on array of char[] instead.
- *
- * Scan top-level document elements for non-xsp tag names returning the first
- * (and hopefully <i>only</i>) user-defined element
- *
- * @param document The input document
- * @return The first non-xsp element
- */
- /*
- protected Element getUserRoot(Document document) {
- Element root = document.getDocumentElement();
- NodeList elements = root.getElementsByTagName("*");
- int elementCount = elements.getLength();
- for (int i = 0; i < elementCount; i++) {
- Element userRoot = (Element) elements.item(i);
- if (!userRoot.getTagName().startsWith("xsp:")) {
- return userRoot;
- }
- }
-
- return null;
- }
- */
-
//
// Inner classes
//
/**
- * Preprocess filter for XSP Markup language.
- * It looks for PI event other that <?xml-logisheet href="...">
- * for quoting them;
- * It adds creation-date, file-name and file-path attributes to the root
- * Element;
- * And it quotes the PCDATA based by calling the quote method of the
- * programming language.
- *
- */
+ * Preprocess filter for XSP Markup language.
+ * It looks for PI event other that <?xml-logisheet href="...">
+ * for quoting them;
+ * It adds creation-date, file-name and file-path attributes to the root
+ * Element;
+ * And it quotes the PCDATA based by calling the quote method of the
+ * programming language.
+ *
+ * @see org.xml.sax.ContentHandler
+ */
protected class PreProcessFilter extends XMLFilterImpl implements Loggable {
protected Logger log;
@@ -192,8 +167,6 @@
private ProgrammingLanguage language;
/**
- * default constructor
- *
* @param filename the filename
* @param the programming language
*/
@@ -209,18 +182,12 @@
}
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void startDocument() throws SAXException {
super.startDocument();
isRootElem = true;
stack = new Stack();
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void processingInstruction(String target, String data) throws
SAXException {
if (!"xml-logicsheet".equals(target)) {
data = this.language.quoteString(data);
@@ -228,9 +195,6 @@
super.processingInstruction(target, data);
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void startElement (String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException {
if (isRootElem) {
@@ -255,18 +219,12 @@
}
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void endElement (String namespaceURI, String localName,
String qName) throws SAXException {
stack.pop();
super.endElement(namespaceURI, localName, qName);
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void characters(char[] ch, int start, int length) throws
SAXException {
String[] tag = (String[]) stack.peek();
String tagName = tag[2];
@@ -285,25 +243,24 @@
super.characters(value.toCharArray(), 0, value.length());
super.endElement(Constants.XSP_URI, "text", "xsp:text");
}
-
}
-
-
-
}
/**
- * This filter builds on the fly a chain of transformers. It extends the
- * <code>AbstractMArkupLanguage.TransformerChainBuilderFilter</code> so
- * it can adds XSP specific feature such as :
- * looking for <?xml-logisheet href="..."?;> PI and
- * <xsp:xml-logisheet location="..."> elements to register
- * user defined logicsheets ;
- * adding all the dependencies related to the XSP pages as
- * <xsp:dependency;>...</xsp:dependency;>
- *
- */
+ * This filter builds on the fly a chain of transformers. It extends the
+ * <code>AbstractMarkupLanguage.TransformerChainBuilderFilter</code> so
+ * it can add XSP specific features such as:
+ * <ul>
+ * <li>Looking for <?xml-logisheet href="..."?;> PI and
+ * <xsp:xml-logisheet location="..."> elements to register
+ * user defined logicsheets;</li>
+ * <li>Adding all the dependencies related to the XSP pages as
+ * <xsp:dependency;>...</xsp:dependency;></li>
+ * </ul>
+ *
+ * @see org.xml.sax.ContentHandler
+ */
protected class XSPTransformerChainBuilderFilter extends
TransformerChainBuilderFilter implements Loggable {
protected Logger log;
@@ -321,15 +278,13 @@
private boolean finished;
/**
- * default constructor
- *
* @param logicsheetMarkupGenerator the code generator
* @param resolver the entity resolver
*/
- protected XSPTransformerChainBuilderFilter (
+ protected XSPTransformerChainBuilderFilter(
LogicsheetCodeGenerator logicsheetMarkupGenerator,
- SourceResolver resolver
- ) {
+ SourceResolver resolver)
+ {
super(logicsheetMarkupGenerator, resolver);
}
@@ -339,21 +294,17 @@
}
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void processingInstruction(String target, String data) throws
SAXException {
// Retrieve logicsheets declared by processing-instruction
if ("xml-logicsheet".equals(target)) {
int start = data.indexOf("href");
- if (start >=0) {
+ if (start >= 0) {
// add 6, for lenght of 'href', plus '=' char, plus '"' char
start += 6;
// get the quote char. Can be " or '
char quote = data.charAt(start-1);
- String href = data.substring(start);
- int end = href.indexOf(quote);
- href = href.substring(0, end);
+ int end = data.indexOf(quote, start);
+ String href = data.substring(start, end);
try {
XSPMarkupLanguage.this.addLogicsheetToList(
language, href, this.resolver
@@ -369,13 +320,11 @@
// Do not forward the PI event.
return;
}
+
// Call super when this is not a logicsheet related PI
super.processingInstruction(target,data);
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void startDocument () throws SAXException {
isRootElem=true;
insideRootElement=false;
@@ -384,19 +333,16 @@
rootChars = new StringBuffer();
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void startElement (String namespaceURI, String localName,
- String qName, Attributes atts ) throws SAXException {
+ String qName, Attributes atts) throws SAXException {
if (finished) {
- // Call super method
- super.startElement(namespaceURI, localName, qName, atts);
+ // Call super method
+ super.startElement(namespaceURI, localName, qName, atts);
} else {
// Need more work
if(isRootElem) {
isRootElem = false;
- // cache the root element and resend the SAX event when
+ // Cache the root element and resend the SAX event when
// we've finished dealing with <xsp:logicsheet > elements
rootElement = new Object[4];
rootElement[0]=namespaceURI;
@@ -421,24 +367,24 @@
throw new SAXException (ioe);
}
} else {
- // This element is not a <xsp:logicsheet element, so finish
- // by :
+ // This element is not a <xsp:logicsheet> element, so finish
+ // by:
// * setting the 'fisnished' flag to true ;
// * refiring all the cached events ;
// * firing all the necessary event dealing with file
dependencies
- finished=true;
+ finished = true;
- // send SAX events 'startDocument'
+ // Send SAX events 'startDocument'
super.startDocument();
- // send all prefix namespace
+ // Send all prefix namespace
String [] prefixArray;
for (int i=0; i<startPrefix.size(); i++) {
prefixArray = (String []) startPrefix.get(i);
super.startPrefixMapping(prefixArray[0],
prefixArray[1]);
}
- // send cached RootElement event
+ // Send cached RootElement event
super.startElement(
(String) rootElement[0],
(String) rootElement[1],
@@ -446,13 +392,13 @@
(Attributes) rootElement[3]
);
- // send cached characters
+ // Send cached characters
char[] ch = rootChars.toString().toCharArray();
super.characters( ch, 0, ch.length);
- // send the events dealing with dependencies.
+ // Send the events dealing with dependencies.
// If some dependencies exist, then creates
- // <xsp:dependency elements
+ // <xsp:dependency> elements
char[] locationChars;
Iterator iter =
XSPMarkupLanguage.this.dependencies.iterator();
while(iter.hasNext()) {
@@ -472,34 +418,23 @@
}
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void endElement (String namespaceURI, String localName,
- String qName) throws SAXException {
+ String qName) throws SAXException {
if (finished) {
// Forward the events
super.endElement(namespaceURI, localName, qName);
}
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void characters(char[] ch, int start, int length) throws
SAXException {
if (finished) {
super.characters(ch, start, length);
- } else {
- if(!insideRootElement) {
- // caching the PCDATA for the root element
- rootChars.append(ch, start, length);
- }
+ } else if(!insideRootElement) {
+ // Caching the PCDATA for the root element
+ rootChars.append(ch, start, length);
}
}
- /**
- * @see org.xml.sax.ContentHandler
- */
public void startPrefixMapping(String prefix, String uri) throws
SAXException {
if(finished) {
super.startPrefixMapping(prefix, uri);
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]