cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lee Burgess <>
Subject disparate XSLT behaviors
Date Mon, 24 Apr 2000 20:36:00 GMT

Hello, I am relatively new to XML and have been learning about XSL
relative to Xalan and Cocoon.  I have a problem that basically
consists of getting different results from the same xml, xsl and
ostensibly the same XSLT.

I am running:

Debian GNU/Linux (frozen/unstable)
Linux 2.2.14
Apache 1.3.9
JServ 1.1
JDK 1.1.8
Cocoon 1.7.2
        (includes fop_0_12_1.jar, xalan_1_0_0.jar, xerces_1_0_3.jar)

I have an xml that references a dtd and a xsl. The dtd is structured
such that it defines an id for a unique attribute of a specific node
in the xml.  Here is an excerpt (article_id is the unique attribute):

-- cut here --
<?xml version="1.0"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>

<!DOCTYPE base SYSTEM "test.dtd">

        <article article_id="1" pubdate="Jan 14, 2000">
                <title>Mailing for Dollars</title>
                <author>Marc Alan Holmes</author>
-- cut here --

The dtd looks like this:

-- cut here --
<!ELEMENT base (article*)>
<!ELEMENT article (title,author,body,topic,link*)>
<!ATTLIST article pubdate CDATA #IMPLIED
                  article_id ID #REQUIRED>
<!ELEMENT title (#PCDATA)>

<!ELEMENT author (#PCDATA)>
<!ELEMENT topic (#PCDATA)>
<!ELEMENT link (link_title, link_url, link_description)>
<!ELEMENT link_title (#PCDATA)>
<!ELEMENT link_url (#PCDATA)>
<!ELEMENT link_description (#PCDATA)>
-- cut here --

The xml has several articles that we want to select individually, by
passing a parameter that can be set in then xsl.  We should then be
able to use the id attibute to pull only that article out of the xml
for display:

-- cut here --
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=""
<xsl:param name="test">YOW</xsl:param>
<xsl:param name="article_id">6</xsl:param>
  <xsl:template match="/">
      <xsl:apply-templates select="base" />
  <xsl:template match="base">
      <xsl:apply-templates select="id($article_id)"/>
      <!--<xsl:apply-templates select="article[@article_id = $article_id]"/>-->
-- cut here --

This all actually works if I run the files directly through Xalan:

$ java org.apache.xalan.xslt.Process -IN test.xml -OUT test.html

This even works for a Xalan based XSLT servlet I wrote myself.

However, when I try running the xml through Cocoon, I get nothing;
which is to say, I don't get the article, but I do get an empty html

If I take the xsl above and comment out the top apply-templates line
and comment in the bottom apply-templates line (in the match="base"
block), *then* it works in Cocoon and Xalan.

I have looked over the lists and cannot find anything similar.  I have
a feeling there is something key I am missing about this.  Any help or
pointers are greatly appreciated.

Lee P. W. Burgess  <<!>>  The first rule of Lefty is: you do not talk
Programmer         <<!>>  about Lefty.
Red Bean Software  <<!>>  The second rule of Lefty is: YOU DO NOT TALK <<!>>  ABOUT LEFTY.

View raw message