|
Subject: [xsl] apply-templates - format problem From: "Hubert Holtz" <Turnhose_alt@xxxxxxx> Date: Thu, 02 Jan 2003 16:22:56 +0100 |
Hy,
first thanks to David, Joerg and Ben.
I have 3 news paragraphs which are outputted 2 times, the first time in the table,
which is my intention and the second time right after the table, but I can't find he problem.
Sorry for the long code, but I don't know where my mistake is located.
-------CODE----------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:param name="lang" select="'ger'"/> <!-- globaler Parameter, Startwert 'ger' -->
<xsl:template match="/article">
<xsl:apply-templates select="sect1"/>
</xsl:template>
<xsl:template match="sect1">
<xsl:apply-templates select="sect1[@lang = $lang and @id='content' | not(@lang)]"/> <!-- abhängig vom Parameter wird das entsprechende template bearbeitet -->
</xsl:template>
<!-- ************SECT1 PROCESSING CONTENT************** -->
<xsl:template match="sect1[@lang= $lang and @id='content']"> <!-- um nicht 2 mal dasselbe template für die jeweilige Sprache zu schreiben wird nur eins benutzt, da die Struktur dieselbe ist. -->
<table border="0" cellspacing="0" cellpadding="0" width="610" height="48">
<tr>
<td rowspan="2" height="48" width="162"><xsl:apply-templates select="mediaobject[@id='titel']"/></td>
<td height="28" width="100%" id="mainColor"></td>
</tr>
<tr>
<td height="20" width="100%" id="hiColor"><xsl:apply-templates select="mediaobject[@id='box']"/></td>
<td></td>
</tr>
</table>
<table width="610" height="48" cellpadding="0" cellspacing="0" border="0" id="sectBackground">
<tr>
<td colspan="3" height="20" width="610" id="white" align="right"><a href="#">link nr.1</a><!-- Abstand noch einfügen --><a href="#">link nr.2</a></td>
</tr>
<tr>
<td colspan="3" height="10"><img src="fake.kill/img/pixel.gif" height="10" width="610" /></td>
</tr>
<tr>
<td colspan="3" height="60"><xsl:apply-templates select="mediaobject[@id='contentpicture']"/></td>
</tr>
<tr>
<td colspan="3">
<b><xsl:value-of select="title" /></b>
</td>
</tr>
<tr>
<td colspan="3">
<xsl:apply-templates select="para"/> <!-- ohne Zeichen= Unterelement des aktuell gewaehlten Elementes -->
</td>
</tr>
<xsl:apply-templates select="simplelist"/>
</table>
<table width="610" height="48" cellpadding="0" cellspacing="0" border="0" id="importantBackground">
<tr>
<td colspan="3" height="20" width="610" id="white"><!-- img src="fake.kill/img/pixel.gif" height="20" width="610"--></td>
</tr>
<tr>
<td colspan="2" id="importantHeader" ><span id="h"><xsl:apply-templates select="../sect1[@lang=$lang and @id='news']/title"/></span></td>
<td id="importantHeader" align="right" valign="bottom"><xsl:apply-templates select="mediaobject[@id='box']"/></td>
</tr>
<tr>
<td colspan="3" ><xsl:apply-templates select="../sect1[@lang=$lang and @id='news']"/></td>
</tr>
</table>
</xsl:template>
<!-- ************SECT1 PROCESSING CONTENT END*********** -->
<!-- ************PARA AND LINK PROCESSING ************** -->
<xsl:template match="para">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="ulink">
<xsl:variable name="ulink">
<a>
<xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
<xsl:choose>
<xsl:when test="count(child::node())=0">
<xsl:value-of select="@url"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:variable>
<xsl:copy-of select="$ulink"/>
</xsl:template>
<!-- ************PARA AND LINK PROCESSING END*********** -->
<!-- ************MEDIAOBJECT PROCESSING ************** -->
<xsl:template match="mediaobject[@id='titel']">
<img src="{imageobject/imagedata/@fileref}" alt="{textobject/phrase}"/>
</xsl:template>
<xsl:template match="mediaobject[@id='box']">
<img src="{imageobject/imagedata/@fileref}" alt="{textobject/phrase}" align="{imageobject/imagedata/@align}"/>
</xsl:template>
<xsl:template match="mediaobject[@id='contentpicture']">
<img src="{imageobject/imagedata/@fileref}" alt="{textobject/phrase}" width="{imageobject/imagedata/@width}" height="{imageobject/imagedata/@height}"/>
</xsl:template>
<!-- ************MEDIAOBJECT PROCESSING END*********** -->
<!-- ************LIST PROCESSING ************** -->
<xsl:template match="simplelist">
<xsl:for-each select="member">
<tr>
<td>
<xsl:value-of select="." /><br/>
</td>
<td>
</td>
</tr>
</xsl:for-each>
</xsl:template>
<!-- ************LIST PROCESSING END*********** -->
<!-- ************SECT1 NEWS PROCESSING ************** -->
<xsl:template match="sect1[@lang=$lang and @id='news']/title">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="sect1[@lang=$lang and @id='news']">
<xsl:for-each select="para">
<p><xsl:value-of select="."/></p>
</xsl:for-each>
</xsl:template>
<!-- ************SECT1 NEWS PROCESSING END*********** -->
</xsl:stylesheet>
----------END OF CODE-------------
The following paragraphs are outputted twice, it's in the last "SECT1 NEWS PROCESSING" section it's
<xsl:template match="sect1[@lang=$lang and @id='news']">
...
And I know that @lang=$lang isn't allowed, but I don't know another way of processing my XML document depending on the language,
without writing the whole template a second time for the one language, which is structured the same way as the other language section.
Thanks.
Homer30
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: RE: [xsl] Problems with Oracle , John Pallister | Thread | Re: [xsl] apply-templates - format , David Carlisle |
| [xsl] Problems with Oracle XSL proc, cknell | Date | Re: [xsl] [saxon] catalogs, Tobias Reif |
| Month |