Newbie question on XSL and lists

Subject: Newbie question on XSL and lists
From: Michiel Verhoef <michielv@xxxxxxxxx>
Date: Fri, 08 Sep 2000 10:50:09 +0200
Hi all,

Though I have been reading the XSL list for a while I only recently 
made my first steps in writing my own XSL style sheets.

Does anybody know of a good tutorial on XSL? I'm sort of experienced
in writing CSS and (think I) have a decent knowledge of the general
ideas of stylesheets but I need a manual. Any good book recommendations
are also welcome.

I ran into a problem which I think has something to do with the structure
the document I'm trying to display has.

In a nutshell the problem structure is this:


I am trying to get a listing on my screen (like HTML's <ul>) but only get
either no
content of the <par-f> or the content of the <par-f> within <item> twice.

The algoritm should be something like:
If <par-f> contains a <listing>
    process the <listing>
   display the content of <par-f>

if the <listing> contains <item>
   process the <item>
  /* error */

if the <item> contains a <par-f>
   process the <par-f>
  /* error */

Assuming this idea is reasonably close to reality I haven't got a clue how
to get
this done in XSL. Any hints and tips would be very welcome.

Thanks in advance,


Basically my output looks like this:

The data types can be divided into five categories:
category1;category2;category3;category4;category5. * 

Whereas is should look like:

The data types can be divided into five categories: 
* category1;
* category2;
* category3;
* category4;
* category5.

My style sheet looks like this:
<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl=""; >


<xsl:template match="section1">
	<h2><xsl:value-of select="stitle"/></h2><hr/>
	<xsl:apply-templates match="introduction"/>

<xsl:template match="introduction">
<!--        <xsl:value-of select="par-f"/>
	<xsl:for-each select="listing">
		<xsl:apply-templates match="listing"/>
	<xsl:for-each select="par-f">
		<xsl:apply-templates match="par-f"/>


<xsl:template match="functional-description">

<xsl:template match="subsection">
	<h3><xsl:value-of select="stitle"/></h3><hr/>
        <xsl:for-each select="/par-f">
	   <xsl:apply-templates match="par-f"/><br/>

<xsl:template match="listing">
	<xsl:for-each select="item">
        	<xsl:apply-templates match="item"/>

<xsl:template match="item">
	* <xsl:value-of select="/par-f"/> <br/>

<xsl:template match="par-f">
	<xsl:for-each select="listing">
		<xsl:apply-templates match="listing"/>


My content looks like this:

<?xml version="1.0"?>
<?xml-stylesheet href="kapdoc.xsl" type="text/xsl"?>
<!DOCTYPE section1 SYSTEM "kapdoc.dtd">
<section1><stitle>Data Model</stitle>
<docsection><stitle><?xm-replace_text {stitle}?></stitle>
<introduction><par-f>The data types can be divided into five categories: 
<listing type="ord">
   </listing> </par-f></introduction>

The relevant parts of the DTD are:

<!ELEMENT par-f  (#PCDATA|listing)*>
<!ELEMENT listing  (stitle? , item+ )>
<!ELEMENT item  (par-f | listing )+>

"If at first you don't succeed, destroy all evidence that you ever tried"

Michiel Verhoef


 XSL-List info and archive:

Current Thread