Newbie question on XSL and lists

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

A collegue of mine pointed out that the following should solve a lot:

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


As it turned out, the results are close to what we need. Only problem now
is that
the titles appear twice (once as title, once as part of the paragraph).
I'll dive
into that problem and see what happens next.

Cheers,

Michiel

>Date: Fri, 08 Sep 2000 10:50:09 +0200
>To: xsl-list@xxxxxxxxxxxxxxxx
>From: Michiel Verhoef <michielv@xxxxxxxxx>
>Subject: Newbie question on XSL and lists
>
>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:
>
><par-f>
>  <listing>
>     <item>
>        <par-f>
>     </item>
>     <item>
>        <par-f>
>     </item>
>  </listing>
></par-f>
>
>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>
>else
>   display the content of <par-f>
>endif
>
>if the <listing> contains <item>
>   process the <item>
>else
>  /* error */
>endif
>
>if the <item> contains a <par-f>
>   process the <par-f>
>else
>  /* error */
>endif
>
>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,
>
>Michiel
>
>
>
>Basically my output looks like this:
>
>The data types can be divided into five categories:
category1;category2;category3;category4;category5. * 
>* 
>* 
>* 
>* 
>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="http://www.w3.org/TR/WD-xsl"; >
><xsl:template><xsl:apply-templates/></xsl:template>
>
><html>
><head>
><title>Section1</title>
></head>
><body>
><xsl:apply-templates/>
></body>
></html>
>
><xsl:template match="section1">
>	<h2><xsl:value-of select="stitle"/></h2><hr/>
>	<xsl:apply-templates match="introduction"/>
>	<hr/>
></xsl:template>
>
>
><xsl:template match="introduction">
><!--        <xsl:value-of select="par-f"/>
>	<xsl:for-each select="listing">
>		<xsl:apply-templates match="listing"/>
>	</xsl:for-each>-->
>	<xsl:apply-templates/>
>	<xsl:for-each select="par-f">
>		<xsl:apply-templates match="par-f"/>
>	</xsl:for-each>
>
></xsl:template>
>
><xsl:template match="functional-description">
>	<xsl:apply-templates/>
></xsl:template>
>
><xsl:template match="subsection">
>	<h3><xsl:value-of select="stitle"/></h3><hr/>
>	<xsl:apply-templates/>
>        <xsl:for-each select="/par-f">
>	   <xsl:apply-templates match="par-f"/><br/>
>	</xsl:for-each>
></xsl:template>
>
>
><xsl:template match="listing">
>	<xsl:for-each select="item">
>        	<xsl:apply-templates match="item"/>
>	</xsl:for-each>
></xsl:template>
>
><xsl:template match="item">
>	* <xsl:value-of select="/par-f"/> <br/>
></xsl:template>
>
><xsl:template match="par-f">
>        <xsl:value-of/>
>	<xsl:for-each select="listing">
>		<xsl:apply-templates match="listing"/>
>	</xsl:for-each>
></xsl:template>
>
>
></xsl:stylesheet>
>
>
>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">
>   <item><par-f>category1;</par-f></item>
>   <item><par-f>category2;</par-f></item>
>   <item><par-f>category3;</par-f></item>
>   <item><par-f>category4;</par-f></item>
>   <item><par-f>category5.</par-f></item>
>   </listing> </par-f></introduction>
></docsection></section1>
>
>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

michielv@xxxxxxxxx
http://www.xs4all.nl/~michielv/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread