Click to See Complete Forum and Search --> : Xslt


Xandria
01-03-2005, 08:40 AM
Hello

i want this xml document translate too html with xslt, i' ve tried with this code but it doen't work :confused:

this is the xml document

<?xml version="1.0" encoding="utf-16"?>
<CurrentWeather>
<Location>Antwerpen / Deurne, Belgium (EBAW) 51-12N 004-28E 14M</Location>
<Time>Jan 03, 2005 - 07:20 AM EST / 2005.01.03 1220 UTC</Time>
<Wind> from the WSW (240 degrees) at 13 MPH (11 KT):0</Wind>
<Visibility> greater than 7 mile(s):0</Visibility>
<SkyConditions> mostly cloudy</SkyConditions>
<Temperature> 44 F (7 C)</Temperature>
<DewPoint> 41 F (5 C)</DewPoint>
<RelativeHumidity> 87%</RelativeHumidity>
<Pressure> 30.47 in. Hg (1032 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather>


and this is my xls document witch contains a fault :confused:

<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="html" doctype-public= "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />

<xsl:template match="/" >
<html xmlns="http://www.w3.org/1999/xHTML">
<head>
<title>Ledenbeheer V.C.C.P</title>
</head>

<body>
<table>
<tr>
<th><xsl:value-of select="CurrentWeather/Location"/><th>
</tr>
<tr>
<td>Tijd meting:</td>
<td><xsl:value-of select="CurrentWeather/Time"/></td>
</tr>
<tr>
<td>Windrichting:</td>
<td><xsl:value-of select="CurrentWeather/Wind"/></td>
</tr>
<tr>
<td>Lucht:</td>
<td><xsl:value-of select="CurrentWeather/SkyConditions"/></td>
</tr>
<tr>
<td>Temperatuur:</td>
<td><xsl:value-of select="CurrentWeather/Temperature"/></td>
</tr>

</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

LiLcRaZyFuZzY
01-08-2005, 04:10 PM
u have to link to the xsl stylesheet in the xml document

<?xml version="1.0" encoding="utf-16"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<CurrentWeather>
<Location>Antwerpen / Deurne, Belgium (EBAW) 51-12N 004-28E 14M</Location>
<Time>Jan 03, 2005 - 07:20 AM EST / 2005.01.03 1220 UTC</Time>
<Wind> from the WSW (240 degrees) at 13 MPH (11 KT):0</Wind>
<Visibility> greater than 7 mile(s):0</Visibility>
<SkyConditions> mostly cloudy</SkyConditions>
<Temperature> 44 F (7 C)</Temperature>
<DewPoint> 41 F (5 C)</DewPoint>
<RelativeHumidity> 87%</RelativeHumidity>
<Pressure> 30.47 in. Hg (1032 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather>

maybe u could try another encoding, UTF-8 or ISO-8859-1, or is UTF-16 really needed?

Charles
01-09-2005, 05:33 AM
Originally posted by LiLcRaZyFuZzY
u have to link to the xsl stylesheet in the xml document That's not necessarily true. But I also wonder what's up with the utf-16 encoding. ASCII is a subset of iso-8859-1 which is a subset of utf-8. utf-16 is something altogether different.

Charles
01-09-2005, 06:28 AM
Aside from the encoding problem, your HTML was atrocious.

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

<xsl:output
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
encoding="iso-8859-1"
indent="yes"
method="html"
version="4.01"/>

<xsl:template match="/" >
<html>
<head>
<title>Ledenbeheer V.C.C.P</title>
</head>

<body>
<table>
<caption>
<xsl:value-of select="CurrentWeather/Location"/>
</caption>
<tr>
<th>Tijd meting:</th>
<td>
<xsl:value-of select="CurrentWeather/Time"/>
</td>
</tr>
<tr>
<th>Windrichting:</th>
<td>
<xsl:value-of select="CurrentWeather/Wind"/>
</td>
</tr>
<tr>
<th>Lucht:</th>
<td>
<xsl:value-of select="CurrentWeather/SkyConditions"/>
</td>
</tr>
<tr>
<th>Temperatuur:</th>
<td>
<xsl:value-of select="CurrentWeather/Temperature"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>