You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lee Burgess <le...@DigitalWork.com> on 2000/04/24 21:19:41 UTC

disparate XSLT behaviors

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">

<base>
  
	<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,teaser,didyouknow,body,topic,link*)>
<!ATTLIST article pubdate CDATA #IMPLIED
	  	  article_id ID #REQUIRED>
<!ELEMENT title (#PCDATA)>

<!ELEMENT author (#PCDATA)>
<!ELEMENT teaser (#PCDATA)>
<!ELEMENT didyouknow (#PCDATA)>
<!ELEMENT body (#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="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:param name="test">YOW</xsl:param>
<xsl:param name="article_id">6</xsl:param>

  <xsl:template match="/">
    <html>
      <xsl:apply-templates select="base" />
    </html>
  </xsl:template>
  
  <xsl:template match="base">
      <xsl:apply-templates select="id($article_id)"/>
      <!--<xsl:apply-templates select="article[@article_id = $article_id]"/>-->
  </xsl:template>
-- 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
document.

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        <<!>>  Manipulate eternity. Power is a symphony:
Software Engineer        <<!>>  elaborate, enormous, essential.
DigitalWork.com          <<!>>  Dream the moment with a fiddle in summer 
lefty@DigitalWork.com    <<!>>  and a knife in winter.