You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by di...@apache.org on 2001/04/13 14:09:37 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp XSPMarkupLanguage.java
dims 01/04/13 05:09:37
Modified: src/org/apache/cocoon/components/language/markup Tag:
xml-cocoon2 AbstractMarkupLanguage.java
src/org/apache/cocoon/components/language/markup/sitemap
Tag: xml-cocoon2 SitemapMarkupLanguage.java
src/org/apache/cocoon/components/language/markup/xsp Tag:
xml-cocoon2 XSPMarkupLanguage.java
Log:
Fix Bug - Duplicate Logicsheets in c2 xsp engine
Revision Changes Path
No revision
No revision
1.1.2.32 +41 -12 xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java
Index: AbstractMarkupLanguage.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java,v
retrieving revision 1.1.2.31
retrieving revision 1.1.2.32
diff -u -r1.1.2.31 -r1.1.2.32
--- AbstractMarkupLanguage.java 2001/04/12 21:12:35 1.1.2.31
+++ AbstractMarkupLanguage.java 2001/04/13 12:09:35 1.1.2.32
@@ -15,6 +15,8 @@
import java.util.Date;
import java.util.Map;
import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.LinkedList;
import java.util.Vector;
import java.util.List;
import java.util.ArrayList;
@@ -50,7 +52,7 @@
* logicsheets as the only means of code generation. Code generation should be decoupled from this context!!!
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
* @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
- * @version CVS $Revision: 1.1.2.31 $ $Date: 2001/04/12 21:12:35 $
+ * @version CVS $Revision: 1.1.2.32 $ $Date: 2001/04/13 12:09:35 $
*/
public abstract class AbstractMarkupLanguage extends AbstractLoggable implements MarkupLanguage, Composer, Configurable {
/** The supported language table */
@@ -267,23 +269,48 @@
return codeGenerator.generateCode(tranBuilder, input, filename);
}
+ LinkedList logicSheetList = new LinkedList();
+
/**
- * Add a logicsheet to the code generator.
+ * Add logicsheet list to the code generator.
* @param codeGenerator The code generator
+ */
+ protected void addLogicsheetsToGenerator(LogicsheetCodeGenerator codeGenerator)
+ throws MalformedURLException, IOException, SAXException {
+
+ if (codeGenerator == null) {
+ getLogger().debug("This should never happen: codeGenerator is null");
+ throw new SAXException("codeGenerator must never be null.");
+ }
+
+ // Walk backwards and remove duplicates.
+ LinkedList newLogicSheetList = new LinkedList();
+ 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();
+ while(iterator.hasNext()) {
+ Logicsheet logicsheet = (Logicsheet) iterator.next();
+ codeGenerator.addLogicsheet(logicsheet);
+ }
+ }
+
+ /**
+ * Add a logicsheet to the code generator.
* @param logicsheetLocation Location of the logicsheet to be added
* @param document The input document
* @exception MalformedURLException If location is invalid
* @exception IOException IO Error
* @exception SAXException Logicsheet parse error
*/
- protected void addLogicsheet(LogicsheetCodeGenerator codeGenerator, LanguageDescriptor language, String logicsheetLocation, EntityResolver entityResolver)
+ protected void addLogicsheetToList(LanguageDescriptor language, String logicsheetLocation, EntityResolver entityResolver)
throws MalformedURLException, IOException, SAXException {
String systemId = null;
InputSource inputSource = null;
- if (codeGenerator == null) {
- getLogger().debug("This should never happen: codeGenerator is null");
- throw new SAXException("codeGenerator must never be null.");
- }
URL url = null;
URLFactory urlFactory = null;
@@ -317,7 +344,9 @@
if (entry.isFile()) {
this.addDependency(IOUtils.getFullFilename(entry.getFile()));
}
- codeGenerator.addLogicsheet(logicsheet);
+
+ logicSheetList.add(logicsheet);
+
Map namespaces = logicsheet.getNamespaces();
if(!logicsheetLocation.equals(language.getLogicsheet()))
{
@@ -329,7 +358,7 @@
if(namedLogicsheetName!= null && !logicsheetLocation.equals(namedLogicsheetName)) {
getLogger().debug("Adding embedded logic sheet for " + namespace + ":" + namedLogicsheetName);
// Add embedded logic sheets too.
- addLogicsheet(codeGenerator, language, namedLogicsheetName, entityResolver);
+ addLogicsheetToList(language, namedLogicsheetName, entityResolver);
}
}
}
@@ -548,12 +577,12 @@
String[] prefixNamingArray = (String[]) this.startPrefixes.get(i);
String namedLogicsheetName = this.language.getNamedLogicsheet(prefixNamingArray[0]);
if (namedLogicsheetName != null) {
- AbstractMarkupLanguage.this.addLogicsheet(this.logicsheetMarkupGenerator, language,
- namedLogicsheetName, resolver);
+ AbstractMarkupLanguage.this.addLogicsheetToList(language, namedLogicsheetName, resolver);
}
}
// Add the language stylesheet (Always the last one)
- AbstractMarkupLanguage.this.addLogicsheet(this.logicsheetMarkupGenerator, language, this.language.getLogicsheet(), resolver);
+ AbstractMarkupLanguage.this.addLogicsheetToList(language, this.language.getLogicsheet(), resolver);
+ AbstractMarkupLanguage.this.addLogicsheetsToGenerator(this.logicsheetMarkupGenerator);
} catch (IOException ioe) {
throw new SAXException(ioe);
}
No revision
No revision
1.1.2.15 +5 -7 xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java
Index: SitemapMarkupLanguage.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -u -r1.1.2.14 -r1.1.2.15
--- SitemapMarkupLanguage.java 2001/04/12 21:12:37 1.1.2.14
+++ SitemapMarkupLanguage.java 2001/04/13 12:09:36 1.1.2.15
@@ -39,7 +39,7 @@
* <a href="http://xml.apache.org/cocoon/sitemap.html">Sitemap</a>.
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/04/12 21:12:37 $
+ * @version CVS $Revision: 1.1.2.15 $ $Date: 2001/04/13 12:09:36 $
*/
public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
@@ -296,8 +296,8 @@
int end = href.indexOf(quote);
href = href.substring(0, end);
try {
- SitemapMarkupLanguage.this.addLogicsheet(
- this.logicsheetMarkupGenerator, language, href, this.resolver
+ SitemapMarkupLanguage.this.addLogicsheetToList(
+ language, href, this.resolver
);
} catch (IOException ioe) {
log.warn("IOException in SitemapMarkupLanguage", ioe);
@@ -338,10 +338,8 @@
if ("map:logicsheet".equals(qName)) {
String location = atts.getValue("location");
try {
- SitemapMarkupLanguage.this.addLogicsheet(
- this.logicsheetMarkupGenerator, language,
- location,
- this.resolver
+ SitemapMarkupLanguage.this.addLogicsheetToList(
+ language, location,this.resolver
);
} catch (IOException ioe) {
log.warn("IOException in SitemapMarkupLanguage", ioe);
No revision
No revision
1.1.2.12 +5 -7 xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java
Index: XSPMarkupLanguage.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -u -r1.1.2.11 -r1.1.2.12
--- XSPMarkupLanguage.java 2001/04/12 21:12:38 1.1.2.11
+++ XSPMarkupLanguage.java 2001/04/13 12:09:36 1.1.2.12
@@ -41,7 +41,7 @@
*
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
* @author <a href="mailto:ssahuc@apache.org">Sebastien Sahuc</a>
- * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/04/12 21:12:38 $
+ * @version CVS $Revision: 1.1.2.12 $ $Date: 2001/04/13 12:09:36 $
*/
public class XSPMarkupLanguage extends AbstractMarkupLanguage {
@@ -359,9 +359,8 @@
int end = href.indexOf(quote);
href = href.substring(0, end);
try {
- XSPMarkupLanguage.this.addLogicsheet(
- this.logicsheetMarkupGenerator, language,
- href, this.resolver
+ XSPMarkupLanguage.this.addLogicsheetToList(
+ language, href, this.resolver
);
} catch (IOException ioe) {
log.warn("XSPMarkupLanguage.processingInstruction", ioe);
@@ -412,9 +411,8 @@
if ("xsp:logicsheet".equals(qName)) {
String location = atts.getValue("location");
try {
- XSPMarkupLanguage.this.addLogicsheet(
- this.logicsheetMarkupGenerator, language,
- location, this.resolver
+ XSPMarkupLanguage.this.addLogicsheetToList(
+ language, location, this.resolver
);
} catch (IOException ioe) {
log.warn("XSPMarkupLanguage.startElement", ioe);
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org