You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Matthew Cline <ma...@mail.nightrealms.com> on 2000/02/06 11:16:37 UTC
xml AND xsl passthrough
After upgrading to Cocoon 1.6, my XML pages were simply being passed
through by Cocoon, as described by Ed Knutson in the message
"Apparent XSLT passthrough". I attempted doing what several people
suggested, adding <?cocoon-process type="xslt"?> to the XML file,
but this only causes the XSL file to be passed through to the
web browser, rather than the XML file; not much of an improvement.
What might I be doing wrong?
Following are the XML and XSL files in question.
Thanks in advance.
==================== index.xml =================
<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="default.xsl" type="text/xsl"?>
<?xml-stylesheet href="default.text.xsl" type="text/xsl" media="lynx"?>
<page_home>
<title>Matt Cline's Home Page</title>
<author>Matt Cline</author>
<version>$Id: index.html,v 1.2 2000/01/07 03:53:23 matt Exp $</version>
<body>
<banner src="/images/banner.gif" alt="The Night Realms"/>
<p>
(If I'm not the Matt Cline you're looking for, look <A
HREF="matts.html">here</A>.)
</p>
<h1>A Brief History of Me</h1>
<p>
I was born and raised in Berkeley, California. I graduated from
Berkeley High in 1992, and went to UCSC. I graduated in 1996
with a degree in Computer Engineering and went to work for
<i>Viman, Inc.</i> Viman merged with <i>Central Design Systems,
Inc.</i>, was spun off as <i>Wyatt River Software</i>, and was
bought by <a href="http://www.rainbow.com">Rainbow
Technologies</a>. I worked with them until 1999, when I left to
have time to write fiction.
</p>
<h1>A Gratuitous Plug</h1>
My <a href="resume/">resume</a>.
<h1>Some Stuff About Me</h1>
<p>
I am now attempting to <a href="writing/">write fiction</a> (I'll
put up the first chapter of my novel once I get it in shape).
While not doing that, I read <a href="manga.html">manga</a>
(Japanese comics), <a href="fantasy.html">fantasy</a>, and <a
href="sci-fi.html">science fiction</a>, and watch <a
href="anime.html">Japanese animation</a>. I also geek on
<a href="computer.html">my computer</a>, and mantain
<a href="site.html">this website</a>.
</p>
<p>
Oh, and here's my <a href="pgp.html">PGP key</a>.
</p>
<h1>Lists of Links</h1>
<ul>
<li>
<a href="list_humor.html">Humor links.</a>
</li>
<li>
<a href="list_web.html">HTML/XML/XSL/etc links.</a>
</li>
<!--
<li>
</li>
<li>
</li>
-->
</ul>
<hr/>
<address><a href="mailto:matt@nightrealms.com">Matthew
Cline</a></address>
</body>
</page_home>
======================= default.xsl ======================
<?xml version="1.0"?>
<!-- Version: $Id: default.xsl,v 1.3 2000/01/07 07:18:11 matt Exp $ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/TR/WD-xsl"
xmlns="http://www.w3.org/TR/REC-html40"
result-ns=""
>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<!--
== Three different kinds of pages: the home page, index pages,
== and normal pages. They're all handled by the same template.
-->
<xsl:template match="page_home|page_index|page">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="Author" content="Matt Cline"/>
<meta name="Version" content="{version}"/>
<title><xsl:value-of select="title"/></title>
</head>
<xsl:apply-templates select="body"/>
</html>
</xsl:template>
<!--
== Three different body templates, one for each different kind of
== page.
-->
<xsl:template match="page_home/body">
<body bgcolor="#FFFFFF">
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="page_index/body">
<body bgcolor="#FFFFFF">
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="page/body">
<body bgcolor="#FFFFFF">
<xsl:apply-templates/>
</body>
</xsl:template>
<!-- The banner for a page. This will be different for the LYNX xsl. -->
<xsl:template match="banner">
<img src="{@src}" alt="{@alt}"/>
</xsl:template>
<!-- Templates for entries in a list of books, animes, mangas, or comics. -->
<xsl:template match="book|anime|manga|comic">
<!--
== If there is a "link" value, then make the header
== also be a link.
-->
<xsl:choose>
<xsl:when test="link">
<a href="{link}"><h1><xsl:value-of select="title"/></h1></a>
</xsl:when>
<xsl:otherwise>
<h1><xsl:value-of select="title"/></h1>
</xsl:otherwise>
</xsl:choose>
<!-- If there is an "image" value, use it. -->
<xsl:if test="image">
<img src="{image}" alt="{title}" align="middle"/>
</xsl:if>
<xsl:apply-templates select="desc"/>
</xsl:template>
<!-- Copy through everything that hasn't been modified by the processor -->
<xsl:template match="text()|@*|*">
<xsl:copy>
<xsl:apply-templates
select="*|@*|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Re: xml AND xsl passthrough
Posted by Phil Lanch <ph...@aldigital.co.uk>.
Matthew Cline wrote:
>
> After upgrading to Cocoon 1.6, my XML pages were simply being passed
> through by Cocoon, as described by Ed Knutson in the message
> "Apparent XSLT passthrough". I attempted doing what several people
> suggested, adding <?cocoon-process type="xslt"?> to the XML file,
> but this only causes the XSL file to be passed through to the
> web browser, rather than the XML file; not much of an improvement.
>
> What might I be doing wrong?
the XSLT namespace you're using-
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/TR/WD-xsl"
> xmlns="http://www.w3.org/TR/REC-html40"
> result-ns=""
> >
-is obsolete - the W3C changed it (sometime before XSLT became a
recommendation) to-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-& Cocoon 1.6 is now up to date. since the XSLT processor didn't
recognize the namespace, it interpreted all xsl: elements as literal
result elements.
--
cheers
phil
"When they bring me fear soup to eat,
I try not to eat it, I try to send it back.
But sometimes I'm too afraid to and have to eat it anyway."