You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/02/03 19:49:33 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java xsp.xsl
vgritsenko 02/02/03 10:49:33
Modified: . changes.xml
src/java/org/apache/cocoon/components/language/markup
AbstractMarkupLanguage.java Logicsheet.java
NamedLogicsheet.java
src/java/org/apache/cocoon/components/language/markup/xsp
XSPMarkupLanguage.java
src/java/org/apache/cocoon/components/language/markup/xsp/java
xsp.xsl
Log:
Lookup logicsheets by their namespace URI, not prefix.
Revision Changes Path
1.96 +9 -1 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- changes.xml 3 Feb 2002 01:15:16 -0000 1.95
+++ changes.xml 3 Feb 2002 18:49:33 -0000 1.96
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.95 2002/02/03 01:15:16 vgritsenko Exp $
+ $Id: changes.xml,v 1.96 2002/02/03 18:49:33 vgritsenko Exp $
-->
<changes title="History of Changes">
@@ -31,6 +31,14 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="VG" type="fix" fixes-bug="4117">
+ XSP engine verifies that root element is the <page> element in the
+ 'http://apache.org/xsp' namespace.
+ </action>
+ <action dev="VG" type="fix">
+ Markup language logicsheets in general and XSP logicsheets in particular
+ are now looked up by their namespace URI, not prefix.
+ </action>
<action dev="VG" type="update">
xsp-request logicsheet got more tags and now is (almost) backward
compatible with the logicsheet in Cocoon 1.8.
1.7 +38 -34 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractMarkupLanguage.java 29 Jan 2002 15:46:08 -0000 1.6
+++ AbstractMarkupLanguage.java 3 Feb 2002 18:49:33 -0000 1.7
@@ -7,6 +7,7 @@
*****************************************************************************/
package org.apache.cocoon.components.language.markup;
+import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
@@ -14,8 +15,10 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.activity.Disposable;
+
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.cocoon.ProcessingException;
@@ -25,24 +28,23 @@
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.URLFactorySourceResolver;
+import org.apache.cocoon.util.HashMap;
-import org.xml.sax.helpers.XMLFilterImpl;
-import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
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 org.xml.sax.helpers.XMLFilterImpl;
+import org.xml.sax.helpers.XMLReaderFactory;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.ListIterator;
+import java.util.ArrayList;
import java.util.Iterator;
-import java.util.Map;
+import java.util.LinkedList;
import java.util.List;
-import java.util.ArrayList;
+import java.util.Map;
/**
* Base implementation of <code>MarkupLanguage</code>. This class uses
@@ -52,10 +54,12 @@
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
* @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
* @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
- * @version CVS $Revision: 1.6 $ $Date: 2002/01/29 15:46:08 $
+ * @version CVS $Revision: 1.7 $ $Date: 2002/02/03 18:49:33 $
*/
-public abstract class AbstractMarkupLanguage extends AbstractLoggable
- implements MarkupLanguage, Composable, Configurable, Recyclable, Disposable
+public abstract class AbstractMarkupLanguage
+ extends AbstractLoggable
+ implements MarkupLanguage, Composable, Configurable, Parameterizable,
+ Recyclable, Disposable
{
/** The 'file' URL protocol. */
private static final String FILE = "file:";
@@ -64,7 +68,7 @@
private static final String CACHE_PREFIX = "logicsheet:";
/** The supported language table */
- protected Hashtable languages;
+ protected HashMap languages;
/** The code-generation logicsheet cache */
protected Store logicsheetCache;
@@ -90,7 +94,7 @@
/** The default constructor. */
public AbstractMarkupLanguage() throws SAXException, IOException {
// Initialize language table
- this.languages = new Hashtable();
+ this.languages = new HashMap();
}
/**
@@ -119,10 +123,10 @@
NamedLogicsheet namedLogicsheet =
(NamedLogicsheet) createLogicsheet(n[j], true);
- // FIXME: Logicsheets should be found by uri--not prefix.
language.addNamedLogicsheet(
- namedLogicsheet.getPrefix(),
- namedLogicsheet.getSystemId());
+ namedLogicsheet.getURI(),
+ namedLogicsheet.getPrefix(),
+ namedLogicsheet.getSystemId());
}
this.languages.put(language.getName(), language);
@@ -145,11 +149,13 @@
Logicsheet logicsheet;
if (named) {
String location = params.getParameter("href", null);
+ String uri = params.getParameter("uri", null);
String prefix = params.getParameter("prefix", null);
NamedLogicsheet namedLogicsheet =
new NamedLogicsheet(location, manager, urlResolver);
namedLogicsheet.setLogger(getLogger());
+ namedLogicsheet.setURI(uri);
namedLogicsheet.setPrefix(prefix);
logicsheet = namedLogicsheet;
} else {
@@ -199,15 +205,13 @@
/**
* Initialize the (required) markup language namespace definition.
- * @param params The sitemap-supplied parameters
- * @exception Exception Not actually thrown
+ * @param params The supplied parameters
*/
- protected void setParameters(Parameters params) throws Exception {
- this.uri = params.getParameter("uri", null);
+ public void parameterize(Parameters params) throws ParameterException {
+ this.uri = params.getParameter("uri");
this.prefix = params.getParameter("prefix", null);
}
-
/**
* Return the source document's encoding. This can be <code>null</code> for
* the platform's default encoding. The default implementation returns
@@ -385,17 +389,17 @@
logicSheetList.add(logicsheet);
- Map namespaces = logicsheet.getNamespaces();
+ Map namespaces = logicsheet.getNamespaceURIs();
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);
+ String namedLogicsheetName = language.getNamedLogicsheetByURI(namespace);
if(namedLogicsheetName!= null
&& !logicsheetLocation.equals(namedLogicsheetName)) {
getLogger().debug("Adding embedded logic sheet for "
- + namespace + ":" + namedLogicsheetName);
+ + namespace + ": " + namedLogicsheetName);
// Add embedded logic sheets too.
addLogicsheetToList(language, namedLogicsheetName, resolver);
}
@@ -417,11 +421,11 @@
protected String logicsheet;
/** The list of built-in logicsheets defined for this target language */
- protected Hashtable namedLogicsheets;
+ protected HashMap namedLogicsheets;
/** The default constructor */
protected LanguageDescriptor() {
- this.namedLogicsheets = new Hashtable();
+ this.namedLogicsheets = new HashMap();
}
/**
@@ -462,16 +466,16 @@
* @param uri The logichseet's namespace uri
* @param namedLogicsheet The logichseet's location
*/
- protected void addNamedLogicsheet(String prefix, String namedLogicsheet) {
- this.namedLogicsheets.put(prefix, namedLogicsheet);
+ protected void addNamedLogicsheet(String uri, String prefix, String namedLogicsheet) {
+ this.namedLogicsheets.put(uri, namedLogicsheet);
}
/**
- * Return a namespace-mapped logicsheet given its name
+ * Return a namespace-mapped logicsheet given its uri
* @return The namespace-mapped logicsheet
*/
- protected String getNamedLogicsheet(String prefix) {
- return (String)this.namedLogicsheets.get(prefix);
+ protected String getNamedLogicsheetByURI(String uri) {
+ return (String)this.namedLogicsheets.get(uri);
}
}
@@ -540,7 +544,7 @@
int prefixesCount = this.startPrefixes.size();
for (int i = 0; i < prefixesCount; i++) {
String[] prefixNamingArray = (String[]) this.startPrefixes.get(i);
- String namedLogicsheetName = this.language.getNamedLogicsheet(prefixNamingArray[0]);
+ String namedLogicsheetName = this.language.getNamedLogicsheetByURI(prefixNamingArray[1]);
if (namedLogicsheetName != null) {
AbstractMarkupLanguage.this.addLogicsheetToList(language, namedLogicsheetName, resolver);
}
1.4 +9 -9 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Logicsheet.java 26 Jan 2002 02:12:33 -0000 1.3
+++ Logicsheet.java 3 Feb 2002 18:49:33 -0000 1.4
@@ -40,7 +40,7 @@
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
* @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
* @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
- * @version CVS $Revision: 1.3 $ $Date: 2002/01/26 02:12:33 $
+ * @version CVS $Revision: 1.4 $ $Date: 2002/02/03 18:49:33 $
*/
public class Logicsheet extends AbstractLoggable
{
@@ -52,7 +52,7 @@
/**
* the template namespace's list
*/
- protected Map namespaces = new HashMap();
+ protected Map namespaceURIs = new HashMap();
/**
* The {@link org.apache.cocoon.components.xslt.XSLTProcessor} component.
@@ -92,12 +92,12 @@
/**
* This will return the list of namespaces in this logicsheet.
*/
- public Map getNamespaces() throws ProcessingException
+ public Map getNamespaceURIs() throws ProcessingException
{
// Force the parsing of the Source or, if nothing changed,
// return the old content of namespaces.
getTransformerHandler();
- return namespaces;
+ return namespaceURIs;
}
/**
@@ -113,7 +113,7 @@
// 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);
+ XMLFilter saveNSFilter = new SaveNamespaceFilter(namespaceURIs);
return xsltProcessor.getTransformerHandler(source, saveNSFilter);
} finally {
// Release used resources
@@ -129,15 +129,15 @@
* @see org.xml.sax.ContentHandler
*/
protected class SaveNamespaceFilter extends XMLFilterImpl {
- private Map originalNamepaces;
+ private Map originalNamepaceURIs;
/**
* 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 SaveNamespaceFilter(Map originalNamepaceURIs) {
+ this.originalNamepaceURIs = originalNamepaceURIs;
}
public void setParent(XMLReader reader) {
@@ -152,7 +152,7 @@
public void startPrefixMapping(String prefix, String uri)
throws SAXException
{
- originalNamepaces.put(prefix,uri);
+ originalNamepaceURIs.put(uri, prefix);
super.startPrefixMapping(prefix, uri);
}
1.4 +20 -2 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NamedLogicsheet.java 26 Jan 2002 04:42:39 -0000 1.3
+++ NamedLogicsheet.java 3 Feb 2002 18:49:33 -0000 1.4
@@ -25,13 +25,13 @@
*
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
* @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
- * @version CVS $Revision: 1.3 $ $Date: 2002/01/26 04:42:39 $
+ * @version CVS $Revision: 1.4 $ $Date: 2002/02/03 18:49:33 $
*/
public class NamedLogicsheet extends Logicsheet {
/**
* The namespace uri
*/
- // FIXME: NOT USED: protected String uri;
+ protected String uri;
/**
* The namespace prefix
@@ -60,5 +60,23 @@
*/
public String getPrefix() {
return this.prefix;
+ }
+
+ /**
+ * Set the logichseet's namespace prefix
+ *
+ * @param prefix The namespace prefix
+ */
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ /**
+ * Return the logicsheet's namespace prefix
+ *
+ * @return The logicsheet's namespace prefix
+ */
+ public String getURI() {
+ return this.uri;
}
}
1.5 +44 -20 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSPMarkupLanguage.java 29 Jan 2002 15:46:08 -0000 1.4
+++ XSPMarkupLanguage.java 3 Feb 2002 18:49:33 -0000 1.5
@@ -8,7 +8,6 @@
package org.apache.cocoon.components.language.markup.xsp;
import org.apache.avalon.framework.logger.Loggable;
-import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
@@ -16,8 +15,8 @@
import org.apache.cocoon.components.language.markup.LogicsheetCodeGenerator;
import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.log.Logger;
+import org.apache.log.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.XMLFilter;
@@ -26,7 +25,12 @@
import java.io.File;
import java.io.IOException;
-import java.util.*;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
/**
* This class implements <code>MarkupLanguage</code> for Cocoon's
@@ -34,7 +38,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.4 $ $Date: 2002/01/29 15:46:08 $
+ * @version CVS $Revision: 1.5 $ $Date: 2002/02/03 18:49:33 $
*/
public class XSPMarkupLanguage extends AbstractMarkupLanguage {
@@ -54,8 +58,7 @@
dependencies = new HashSet();
}
- public void recycle()
- {
+ public void recycle() {
super.recycle();
this.dependencies.clear();
}
@@ -179,6 +182,8 @@
private ProgrammingLanguage language;
+ private String localPrefix;
+
/**
* @param filename the filename
* @param the programming language
@@ -211,6 +216,15 @@
public void startElement (String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException {
if (isRootElem) {
+ if (!XSPMarkupLanguage.this.getURI().equals(namespaceURI)
+ || !"page".equals(localName)) {
+ throw new SAXException("This page is not valid XSP page."
+ + " Root element is: " + qName);
+ }
+ localPrefix = "";
+ if (qName.indexOf(':') != -1)
+ localPrefix = qName.substring(0, qName.indexOf(':'));
+
stack.push(new String[] { namespaceURI, localName, qName} );
isRootElem=false;
// Store path and file name
@@ -240,25 +254,30 @@
public void characters(char[] ch, int start, int length) throws SAXException {
String[] tag = (String[]) stack.peek();
- String tagName = tag[2];
- if (
- tagName.equals("xsp:expr") ||
- tagName.equals("xsp:logic") ||
- tagName.equals("xsp:structure") ||
- tagName.equals("xsp:include")
- ) {
- super.characters(ch, start, length);
+ String tagURI = tag[0];
+ String tagLName = tag[1];
+ if (XSPMarkupLanguage.this.getURI().equals(tagURI) && (
+ tagLName.equals("expr") || tagLName.equals("logic") ||
+ tagLName.equals("structure") || tagLName.equals("include"))) {
+ super.characters(ch, start, length);
} else {
// Quote the string depending on the programming language
String value = this.language.quoteString(String.valueOf(ch, start, length));
// Create a new element <xsp:text that wrap the quoted PCDATA
- super.startElement(Constants.XSP_URI, "text", "xsp:text", new AttributesImpl() );
+ super.startElement(Constants.XSP_URI, "text", localPrefix + ":text", new AttributesImpl() );
super.characters(value.toCharArray(), 0, value.length());
- super.endElement(Constants.XSP_URI, "text", "xsp:text");
+ super.endElement(Constants.XSP_URI, "text", localPrefix + ":text");
}
}
}
+ public String getURI() {
+ return super.uri;
+ }
+
+ public String getPrefix() {
+ return super.prefix;
+ }
/**
* This filter builds on the fly a chain of transformers. It extends the
@@ -290,6 +309,8 @@
private boolean finished;
+ private String localPrefix;
+
/**
* @param logicsheetMarkupGenerator the code generator
* @param resolver the entity resolver
@@ -355,6 +376,10 @@
} else {
// Need more work
if(isRootElem) {
+ localPrefix = "";
+ if (qName.indexOf(':') != -1)
+ localPrefix = qName.substring(0, qName.indexOf(':'));
+
isRootElem = false;
// Cache the root element and resend the SAX event when
// we've finished dealing with <xsp:logicsheet > elements
@@ -367,7 +392,7 @@
insideRootElement = true;
// Retrieve logicsheets declared by top-level elements <xsp:logicsheet ...>
// And do not forward the startElement event
- if ("xsp:logicsheet".equals(qName)) {
+ if (XSPMarkupLanguage.this.getURI().equals(namespaceURI) && "logicsheet".equals(localName)) {
String href = atts.getValue("location");
try {
XSPMarkupLanguage.this.addLogicsheetToList(
@@ -417,12 +442,11 @@
Iterator iter = XSPMarkupLanguage.this.dependencies.iterator();
while(iter.hasNext()) {
super.startElement(
- namespaceURI, "dependency",
- "xsp:dependency", new AttributesImpl()
+ namespaceURI, "dependency", localPrefix + ":dependency", new AttributesImpl()
);
locationChars = ((String) iter.next()).toCharArray();
super.characters(locationChars, 0 , locationChars.length);
- super.endElement(namespaceURI, "dependency", "xsp:dependency");
+ super.endElement(namespaceURI, "dependency", localPrefix + ":dependency");
}
// And finally forward current Element.
1.2 +28 -28 xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
Index: xsp.xsl
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xsp.xsl 3 Jan 2002 12:31:11 -0000 1.1
+++ xsp.xsl 3 Feb 2002 18:49:33 -0000 1.2
@@ -12,19 +12,16 @@
<!--
* @author <a href="mailto:ricardo@apache.org>Ricardo Rocha</a>
* @author <a href="sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:11 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/02/03 18:49:33 $
-->
<!-- XSP Core logicsheet for the Java language -->
-<xsl:stylesheet
- version="1.0"
-
- xmlns:xsp="http://apache.org/xsp"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
->
+<xsl:stylesheet version="1.0"
+ xmlns:xsp="http://apache.org/xsp"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
- <xsl:variable name="prefix">xsp</xsl:variable>
+ <xsl:variable name="xsp-uri" select="'http://apache.org/xsp'"/>
<xsl:template match="/">
<code xml:space="preserve">
@@ -68,7 +65,6 @@
import org.apache.cocoon.components.language.markup.xsp.XSPRequestHelper;
import org.apache.cocoon.components.language.markup.xsp.XSPResponseHelper;
-
/* User Imports */
<xsl:for-each select="xsp:structure/xsp:include">
import <xsl:value-of select="."/>;
@@ -112,7 +108,7 @@
<!-- Process only 1st non-XSP element as generated root -->
<xsl:call-template name="process-first-element">
- <xsl:with-param name="content" select="*[not(starts-with(name(.), 'xsp:'))][1]"/>
+ <xsl:with-param name="content" select="*[not(namespace-uri(.) = $xsp-uri)][1]"/>
</xsl:call-template>
this.contentHandler.endDocument();
@@ -222,7 +218,10 @@
xspAttr.clear();
- <xsl:apply-templates select="node()[not(name(.) = 'xsp:attribute' or (name(.) = 'xsp:logic' and ./xsp:attribute))]"/>
+ <xsl:apply-templates select="node()[not(
+ (namespace-uri(.) = $xsp-uri and local-name(.) = 'attribute') or
+ (namespace-uri(.) = $xsp-uri and local-name(.) = 'logic' and ./xsp:attribute)
+ )]"/>
this.contentHandler.endElement(
<xsl:copy-of select="$uri"/>,
@@ -279,23 +278,27 @@
<xsl:copy-of select="$name"/>
</xsl:when>
<xsl:otherwise>
- new StringBuffer(<xsl:copy-of select="$prefix"/>).append(":").append(<xsl:copy-of select="$name"/>).toString() </xsl:otherwise>
+ (<xsl:copy-of select="$prefix"/> + ":" + <xsl:copy-of select="$name"/>) </xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content">
<xsl:for-each select="text()|xsp:expr|xsp:text">
+ <xsl:if test="position() > 1">
+ +
+ </xsl:if>
<xsl:choose>
- <xsl:when test="name(.) = 'xsp:expr'">
+ <xsl:when test="namespace-uri(.) = $xsp-uri and local-name(.) = 'expr'">
String.valueOf(<xsl:value-of select="."/>)
</xsl:when>
<xsl:otherwise>
"<xsl:value-of select="."/>"
</xsl:otherwise>
</xsl:choose>
- +
</xsl:for-each>
- ""
+ <xsl:if test="not(text()|xsp:expr|xsp:text)">
+ ""
+ </xsl:if>
</xsl:variable>
xspAttr.addAttribute(
@@ -309,7 +312,7 @@
<xsl:template match="xsp:expr">
<xsl:choose>
- <xsl:when test="starts-with(name(..), 'xsp:') and name(..) != 'xsp:content' and name(..) != 'xsp:element'">
+ <xsl:when test="namespace-uri(..) = $xsp-uri and local-name(..) != 'content' and local-name(..) != 'element'">
<!--
Expression is nested inside another XSP tag:
preserve its Java type
@@ -345,7 +348,7 @@
<xsl:variable name="content">
<xsl:for-each select="text()|xsp:expr">
<xsl:choose>
- <xsl:when test="name(.) = 'xsp:expr'">
+ <xsl:when test="namespace-uri(.) = $xsp-uri and local-name(.) = 'expr'">
String.valueOf(<xsl:value-of select="."/>)
</xsl:when>
<xsl:otherwise>
@@ -369,7 +372,7 @@
</xsl:template>
- <xsl:template match="*[not(starts-with(name(.), 'xsp:'))]">
+ <xsl:template match="*[not(namespace-uri(.) = $xsp-uri)]">
<xsl:variable name="parent-element" select=".."/>
<xsl:for-each select="namespace::*">
<xsl:variable name="ns-prefix" select="local-name(.)"/>
@@ -392,10 +395,12 @@
"<xsl:value-of select="name(.)"/>",
xspAttr
);
-
xspAttr.clear();
- <xsl:apply-templates select="node()[not(name(.) = 'xsp:attribute' or (name(.) = 'xsp:logic' and ./xsp:attribute))]"/>
+ <xsl:apply-templates select="node()[not(
+ (namespace-uri(.) = $xsp-uri and local-name(.) = 'attribute') or
+ (namespace-uri(.) = $xsp-uri and local-name(.) = 'logic' and ./xsp:attribute)
+ )]"/>
this.contentHandler.endElement(
"<xsl:value-of select="namespace-uri(.)"/>",
@@ -412,7 +417,6 @@
);
</xsl:if>
</xsl:for-each>
-
</xsl:template>
<xsl:template match="@*">
@@ -430,7 +434,7 @@
<xsl:template match="text()">
<xsl:choose>
- <xsl:when test="name(..) = 'xsp:logic' or name(..) = 'xsp:expr'">
+ <xsl:when test="namespace-uri(..) = $xsp-uri and (local-name(..) = 'logic' or local-name(..) = 'expr')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
@@ -456,16 +460,12 @@
<xsl:param name="default"/>
<xsl:param name="required">false</xsl:param>
- <xsl:variable name="qname">
- <xsl:value-of select="concat($prefix, ':param')"/>
- </xsl:variable>
-
<xsl:choose>
<xsl:when test="@*[name(.) = $name]">"<xsl:value-of select="@*[name(.) = $name]"/>"</xsl:when>
- <xsl:when test="(*[name(.) = $qname])[@name = $name]">
+ <xsl:when test="(*[namespace-uri(.)=$xsp-uri and local-name(.) = 'param'])[@name = $name]">
<xsl:call-template name="get-nested-content">
<xsl:with-param name="content"
- select="(*[name(.) = $qname])[@name = $name]"/>
+ select="(*[namespace-uri(.)=$xsp-uri and local-name(.) = 'param'])[@name = $name]"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
----------------------------------------------------------------------
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