You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2004/04/02 23:32:34 UTC
cvs commit: cocoon-2.1/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript xsp.xsl
joerg 2004/04/02 13:32:34
Modified: src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java
xsp.xsl
. status.xml
src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript
xsp.xsl
Log:
"Fixed" bug 15841 by raising an exception when something is tried to add to elements before attributes.
At least all the samples work with this fix.
Revision Changes Path
1.3 +22 -13 cocoon-2.1/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
Index: xsp.xsl
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xsp.xsl 17 Mar 2004 11:28:22 -0000 1.2
+++ xsp.xsl 2 Apr 2004 21:32:33 -0000 1.3
@@ -14,14 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<!-- $Id$-->
+<!-- CVS $Id$-->
<!--
* XSP Core logicsheet for the Java language
*
* @author <a href="mailto:ricardo@apache.org>Ricardo Rocha</a>
* @author <a href="sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
- * @version CVS $Revision$ $Date$
-->
<xsl:stylesheet version="1.0"
@@ -233,15 +231,10 @@
</xsl:choose>
</xsl:variable>
- <!-- Declare namespaces that are not already present on the parent element.
- Note : we could use "../../namespace::*[...]" to get parent element namespaces
- but Xalan 2.0.1 retunrs only the first namespace (Saxon is OK).
- That's why we store the parent element in a variable -->
- <xsl:variable name="parent-element" select=".."/>
<xsl:for-each select="namespace::*">
<xsl:variable name="ns-prefix" select="local-name(.)"/>
<xsl:variable name="ns-uri" select="string(.)"/>
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
this.contentHandler.startPrefixMapping(
"<xsl:value-of select="local-name(.)"/>",
"<xsl:value-of select="."/>");
@@ -250,14 +243,14 @@
<!-- Declare namespace defined by @uri and @prefix attribute -->
<xsl:if test="$uri != '""'">
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $prefix and string(.) = $uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $prefix and string(.) = $uri])">
this.contentHandler.startPrefixMapping(
<xsl:value-of select="$prefix"/>,
<xsl:value-of select="$uri"/>);
</xsl:if>
</xsl:if>
- <xsl:apply-templates select="xsp:attribute | xsp:logic[xsp:attribute]"/>
+ <xsl:apply-templates select="xsp:attribute | xsp:logic[xsp:attribute]" mode="check"/>
this.contentHandler.startElement(
<xsl:copy-of select="$uri"/>,
@@ -280,7 +273,7 @@
<!-- Declare namespace defined by @uri and @prefix attribute -->
<xsl:if test="$uri != '""'">
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $prefix and string(.) = $uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $prefix and string(.) = $uri])">
this.contentHandler.endPrefixMapping(<xsl:value-of select="$prefix"/>);
</xsl:if>
</xsl:if>
@@ -288,12 +281,26 @@
<xsl:for-each select="namespace::*">
<xsl:variable name="ns-prefix" select="local-name(.)"/>
<xsl:variable name="ns-uri" select="string(.)"/>
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
this.contentHandler.endPrefixMapping("<xsl:value-of select="local-name(.)"/>");
</xsl:if>
</xsl:for-each>
</xsl:template>
+ <xsl:template match="xsp:attribute | xsp:logic[xsp:attribute]" mode="check">
+ <xsl:if test="preceding-sibling::text()[normalize-space()]
+ | preceding-sibling::processing-instruction()
+ | preceding-sibling::*[not(self::xsp:attribute
+ | self::xsp:logic[xsp:attribute]
+ | self::xsp:param
+ | self::xsp:text[not(normalize-space())])]">
+ <xsl:message terminate="yes">
+ You can not add attributes to elements after other node types already have been added.
+ </xsl:message>
+ </xsl:if>
+ <xsl:apply-templates select="."/>
+ </xsl:template>
+
<xsl:template match="xsp:attribute">
<xsl:variable name="uri">
<xsl:call-template name="get-parameter">
@@ -488,6 +495,8 @@
</xsl:choose>
</xsl:template>
+ <!-- FIXME: there seems to be no apply-templates with that mode,
+ i.e. can this template be removed? -->
<xsl:template match="text()" mode="value">
<xsl:value-of select="."/>
</xsl:template>
1.294 +5 -1 cocoon-2.1/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/status.xml,v
retrieving revision 1.293
retrieving revision 1.294
diff -u -r1.293 -r1.294
--- status.xml 2 Apr 2004 20:52:47 -0000 1.293
+++ status.xml 2 Apr 2004 21:32:33 -0000 1.294
@@ -212,6 +212,10 @@
<changes>
<release version="@version@" date="@date@">
+ <action dev="JH" type="fix" fixes-bug="15841">
+ "Fixed" bug 15841 by raising an exception when something is tried to add
+ to elements before attributes.
+ </action>
<action dev="JH" type="update">
Changed blocks selection handling to allow more intuitive
include.block.blockname syntax in (local.)blocks.properties. Old syntax
1.3 +19 -12 cocoon-2.1/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
Index: xsp.xsl
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xsp.xsl 17 Mar 2004 11:28:22 -0000 1.2
+++ xsp.xsl 2 Apr 2004 21:32:34 -0000 1.3
@@ -14,12 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+<!-- CVS $Id$-->
<!--
* XSP Core logicsheet for the JavaScript language
*
* @author <a href="mailto:vgritsenko@apache.org>Vadim Gritsenko</a>
- * @version CVS $Revision$ $Date$
-->
<xsl:stylesheet version="1.0"
@@ -173,27 +172,22 @@
</xsl:choose>
</xsl:variable>
- <!-- Declare namespaces that are not already present on the parent element.
- Note : we could use "../../namespace::*[...]" to get parent element namespaces
- but Xalan 2.0.1 retunrs only the first namespace (Saxon is OK).
- That's why we store the parent element in a variable -->
- <xsl:variable name="parent-element" select=".."/>
<xsl:for-each select="namespace::*">
<xsl:variable name="ns-prefix" select="local-name(.)"/>
<xsl:variable name="ns-uri" select="string(.)"/>
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
contentHandler.startPrefixMapping("<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="."/>");
</xsl:if>
</xsl:for-each>
<!-- Declare namespace defined by @uri and @prefix attribute -->
<xsl:if test="$uri != '""'">
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $prefix and string(.) = $uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $prefix and string(.) = $uri])">
contentHandler.startPrefixMapping(<xsl:value-of select="$prefix"/>, <xsl:value-of select="$uri"/>);
</xsl:if>
</xsl:if>
- <xsl:apply-templates select="xsp:attribute | xsp:logic[xsp:attribute]"/>
+ <xsl:apply-templates select="xsp:attribute | xsp:logic[xsp:attribute]" mode="check"/>
contentHandler.startElement(<xsl:copy-of select="$uri"/>,
<xsl:copy-of select="$name"/>, <xsl:copy-of select="$raw-name"/>, xspAttr);
@@ -209,7 +203,7 @@
<!-- Declare namespace defined by @uri and @prefix attribute -->
<xsl:if test="$uri != '""'">
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $prefix and string(.) = $uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $prefix and string(.) = $uri])">
contentHandler.endPrefixMapping(<xsl:value-of select="$prefix"/>);
</xsl:if>
</xsl:if>
@@ -217,12 +211,25 @@
<xsl:for-each select="namespace::*">
<xsl:variable name="ns-prefix" select="local-name(.)"/>
<xsl:variable name="ns-uri" select="string(.)"/>
- <xsl:if test="not($parent-element/namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
+ <xsl:if test="not(../namespace::*[local-name(.) = $ns-prefix and string(.) = $ns-uri])">
contentHandler.endPrefixMapping("<xsl:value-of select="local-name(.)"/>");
</xsl:if>
</xsl:for-each>
</xsl:template>
+ <xsl:template match="xsp:attribute | xsp:logic[xsp:attribute]" mode="check">
+ <xsl:if test="preceding-sibling::text()[normalize-space()]
+ | preceding-sibling::processing-instruction()
+ | preceding-sibling::*[not(self::xsp:attribute
+ | self::xsp:logic[xsp:attribute]
+ | self::xsp:param
+ | self::xsp:text[not(normalize-space())])]">
+ <xsl:message terminate="yes">
+ You can not add attributes to elements after other node types already have been added.
+ </xsl:message>
+ </xsl:if>
+ <xsl:apply-templates select="."/>
+ </xsl:template>
<xsl:template match="xsp:attribute">
<xsl:variable name="uri">