You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Paul Russell <pa...@luminas.co.uk> on 2000/07/03 00:46:50 UTC

XSLT induced hair loss.

Hi Guys.

Need you to help me confirm I'm not (a) insane or (b) stupid.

I'm writing a custom generator for Cocoon2 to produce status
info (ala Cocoon1's /Cocoon.xml).

The producer produces:

<?xml version="1.0"?>

<statusinfo date="Jul 2, 2000 10:42:03 PM" host="test.stu.uea.ac.uk"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns="http://apache.org/cocoon/status">
    <group name="vm">
        <group name="memory">
	    <value name="total">3362808</value>
	    <value name="free">937072</value>
	</group>
	<group name="jre">
	    <value name="version">1.2.2</value>
	    <value xlink:type="simple"
	        xlink:href="http://java.sun.com/"
		name="java-vendor">Sun Microsystems Inc.</value>
        </group>
	<group name="operating-system">
	    <value name="name">Linux</value>
	    <value name="architecture">i386</value>
	    <value name="version">2.4.0-test1</value>
	</group>
	<value name="classpath">.:./bin/../lib/ant.jar:./bin/../lib/cocoon-latest.jar:./bin/../lib/fop_0_13_0.jar:./bin/../lib/jasper.jar:./bin/../lib/js.jar:./bin/../lib/jstyle.jar:./bin/../lib/servlet.jar:./bin/../lib/servlet_2_2.jar:./bin/../lib/stylebook-1.0-b2.jar:./bin/../lib/svgv_0_8.jar:./bin/../lib/test:./bin/../lib/webserver.jar:./bin/../lib/xalan_1_0_1.jar:./bin/../lib/xerces_1_1_2.jar:./bin/../lib/xml.jar:/usr/local/jdk1.2.2/lib/tools.jar:/usr/share/java/repository:/usr/local/jdk1.2.2/lib/tools.jar:/usr/share/java/xalan.jar:/usr/share/java/xerces.jar:/usr/share/java/cocoon.jar:/usr/share/java/fop.jar</value>
    </group>
</statusinfo>

The stylesheet is the oh-so-involved:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="statusinfo">
        <html>
        </html>
    </xsl:template>
</xsl:stylesheet>
						

The output is:

<?xml version="1.0"?>
33095605308961.2.2Sun Microsystems Inc.Linuxi3862.4.0-test1.:./bin/../lib/ant.jar:./bin/../lib/cocoon-latest.jar:./bin/../lib/fop_0_13_0.jar:./bin/../lib/jasper.jar:./bin/../lib/js.jar:./bin/../lib/jstyle.jar:./bin/../lib/servlet.jar:./bin/../lib/servlet_2_2.jar:./bin/../lib/stylebook-1.0-b2.jar:./bin/../lib/svgv_0_8.jar:./bin/../lib/test:./bin/../lib/webserver.jar:./bin/../lib/xalan_1_0_1.jar:./bin/../lib/xerces_1_1_2.jar:./bin/../lib/xml.jar:/usr/local/jdk1.2.2/lib/tools.jar:/usr/share/java/repository:/usr/local/jdk1.2.2/lib/tools.jar:/usr/share/java/xalan.jar:/usr/share/java/xerces.jar:/usr/share/java/cocoon.jar:/usr/share/java/fop.jar

... which I can't work out at *all*.

I was expecting the somewhat more mundane:

<html>
</html>

Has anyone got any ideas? I can't work out whether this is a
bug (in Xalan), or whether I've left my brain somewhere
embarasing this evening! Heeeeelp!

Cheers,

Paul

-- 
Paul Russell                               <pa...@luminas.co.uk>
Technical Director,                   http://www.luminas.co.uk
Luminas Ltd.

Re: XSLT induced hair loss. -- Wig found.

Posted by Paul Russell <pa...@luminas.co.uk>.
On Sun, Jul 02, 2000 at 11:46:50PM +0100, Paul Russell wrote:
> Need you to help me confirm I'm not (a) insane or (b) stupid.

The latter, it would seem. Aparently I needed to declare the
namespace for the generated output in the stylesheet and then
prefix it in the xsl:match...

Apologies. Hopefully I'll have some shiney new code for you
RealSoonNow :)

Cheers,

-- 
Paul Russell                               <pa...@luminas.co.uk>
Technical Director,                   http://www.luminas.co.uk
Luminas Ltd.

RE: XSLT induced hair loss.

Posted by Jay Cain <ja...@enetsouth.com>.
Paul,

XSLT has built-in template rules. One of them is:

<xsl:template match="*|/">
  <xsl:apply-templates/>
</xsl:template>

which, as you can see, matches the root node and all element nodes. There is
also the built-in rule for text and attribute copying:

<xsl:template match="text()|@*">
  <xsl:value-of select="."/>
</xsl:template>

In your template, you specified the document element, but didn't override
the root node template. So the root node template is applied, which applies
the templates to all the elements, which then dumps out all the text. I
believe if you change the match attribute of your template from "statusinfo"
to "/statusinfo", your problem should be fixed.

Jay Cain
Lead Developer
eNetSouth, LLC