[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

apply-templates - format problem

Subject: apply-templates - format problem
From: "Hubert Holtz" <Turnhose_alt@xxxxxxx>
Date: Thu, 02 Jan 2003 16:22:56 +0100
fake id templates
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.