You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Wouter Heijke <wh...@agency.com> on 2001/02/05 16:30:00 UTC

Added spaces with xsp:attribute

Is it a bug or a feature?

Look at the piece of XSP below and notice the 'goodcustomid' static
attribute and the 'badcustomid' dynamic added attribute to 'testxmltree'.
When you run this XSP with cocoon (1.8.2) it shows something like this:

goodcustomid = 'mystring'
badcustomid = ' mystring '

So the dynamically added attribute's value had whitespaced attatched to it!!

Am I doing something wrong here?

I can try to work around this by calling DOM myself and so creating my own
attributes....

Wouter Heijke



<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="bug1.xsl" type="text/xsl"?>
	
<xsp:page language="java" 
	  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
	  xmlns:util="http://www.apache.org/1999/XSP/Util"
	  >
	  
	<page title="TEST">
		<xsp:logic><![CDATA[
			String val = request.getParameter("customid"); ]]>
		</xsp:logic>

		<testxmltree goodcustomid="mystring">
			<xsp:attribute name="badcustomid">
 				<xsp:expr>val</xsp:expr>
			</xsp:attribute>
			<item id="foo">
				<name>bar</name>
			</item>
		</testxmltree>
	</page>
</xsp:page>


and the stylesheet


<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="page">
	<xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
	<html>
	<head>
	</head>
		<body>
			<xsl:apply-templates/>
		</body>
	</html>
	</xsl:template>

	<xsl:template match="testxmltree">
		<h1>goodcustomid = '<xsl:value-of
select="@goodcustomid"/>'</h1>
		<h1>badcustomid = '<xsl:value-of
select="@badcustomid"/>'</h1>
	</xsl:template>
</xsl:stylesheet>