Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailemVyřešeno Xsl transformace xml na html

Mám xml:

<?xml version="1.0" encoding="windows-1250" ?> 
<?xml-stylesheet type="text/xsl" href="auto-html2.xsl"?>
<auto>
	<input>
		<label>Značka: </label>
		<name>znacka</name>
		<type>text</type>
		<value>Renault</value>
	</input>
	<input>
		<label>Model: </label>
		<name>model</name>
		<type>text</type>
		<value>Clio</value>
	</input>
	<input>
		<label>RZ (SPZ): </label>
		<name>spz</name>
		<type>text</type>
		<value>1AC2889</value>
	</input>
        ...
</auto>

K němu mám xsl:

<?xml version="1.0" encoding="windows-1250" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/1999/XSL/Transform">

<xsl:template match="input">
	<tr>
		<td width="200px"><label for="{name}"><xsl:value-of select="label" /></label></td>
		<td>
			<xsl:choose>
				<xsl:when test="type='text'">
  					<input type="{type}" name="{name}" id="{name}" value="{value}" /> 
  				</xsl:when>
  				...
  			</xsl:choose>
  		</td>
  	</tr>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="windows-1250" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/1999/XSL/Transform">
<xsl:import href="input.xsl" /> 
<xsl:template match="auto">  	
<html>
<head></head>
<body>
	<table width="900px" cellspacing="0" cellpadding="2">  	
   		<xsl:apply-templates select="input" />
  	</table>
</body>
</html> 
</xsl:template> 
</xsl:stylesheet>

Výsledkem je html tabulka, kde každý řádek má 2 buňky - v první je label inputu, ve 2. input.
A já bych chtěla, aby v té tabulce byly na jednom řádku 3 inputy, tedy 6 sloupců. Jak to udělat?

Předmět Autor Datum
Už jsem to vyřešila :-) šablona pro vypsání auta: <xsl:template match="auto"> <html> <head></head>… poslední
Anicka 31.10.2010 12:37
Anicka

Už jsem to vyřešila :-)

šablona pro vypsání auta:

<xsl:template match="auto">  	
<html>
<head></head>
<body>
	<table width="900px" cellspacing="0" cellpadding="2"> 
		<xsl:for-each select="input">
			<xsl:if test="position() mod 3 = 1">  	
   		  		<xsl:call-template name="radek"  />
   			</xsl:if>
   		</xsl:for-each>
  	</table>
  	
</body>
</html> 
</xsl:template> 

šablona pro vypsání jednoho řádku:

<xsl:template name="radek">
	<tr>
		<xsl:apply-templates select="." />
		<xsl:apply-templates select="following-sibling::*[position() = 1]" />
		<xsl:apply-templates select="following-sibling::*[position() = 2]" />
	</tr>
</xsl:template>

Zpět do poradny Odpovědět na původní otázku Nahoru