RE: [xsl] Newbie: easy one.

Subject: RE: [xsl] Newbie: easy one.
From: "Allan Jones" <allan.jones@xxxxxxxxxxxx>
Date: Tue, 8 Jul 2003 15:01:08 +0100
You probably want something more like this for your xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
	<xsl:template match="/">
		<html>
			<head>
				<title>Web applications list</title>
			</head>
			<body>
				<xsl:for-each select="webapps/website">
					<table border="1" summary="Web
Application Table">
						<tr>
							<td>
	
<xsl:text>Site Name: </xsl:text>
	
<xsl:value-of select="@name"/>
							</td>
						</tr>
						<xsl:apply-templates/>
					</table>
				</xsl:for-each>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="address">
		<tr>
			<td>
				<xsl:text>URL: </xsl:text>
				<xsl:value-of select="."/>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>

Basically, the second template has been altered to match on 'address'
elements to be more specific, and the output side of things has been
manipulated slightly to put it on one line instead of across multiple
columns.

Hope that helps,

b

|-----Original Message-----
|From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
|[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
|Rudi Starcevic
|Sent: 08 July 2003 14:59
|To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
|Subject: [xsl] Newbie: easy one.
|
|
|Hi,
|
|Sorry for bringing such elementarty questions
|but I've been trying to figure this out for about an
|hour without joy so I thought I'd ask.
|
|I'm sending this xml packet straight to the web browser
|which the browser parses and formats:
|
|<?xml version="1.0" encoding="UTF-8"?>
|<?xml-stylesheet type="text/xsl" href="webapps.xsl"?>
|<webapps xmlns:webapps="http://www.rudistarcevic.com";>
|	<website name="Wwnames">
|		<address>http://www.wwnames.com</address>
|		<address>http://www.ozdot.com</address>
|	</website>
|</webapps>
|
|Here is my stylesheet, webapps.xsl, which is not outputing a 
|nice table of 3 rows:
|
|<?xml version="1.0" encoding="UTF-8"?>
|<xsl:stylesheet version="1.0" 
|xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
|xmlns:fo="http://www.w3.org/1999/XSL/Format";>
|
|<xsl:template match="/">
|<html>
|<head><title>Web applications list</title></head>
|<body>
|<xsl:for-each select="webapps/website">
| <table border="1" summary="Web Application Table">
| <tr>
|  <td>Site Name:</td>
|  <td><xsl:value-of select="@name"/></td>
| </tr>
|
| <xsl:apply-templates/>
|
| </table>
| 
|</xsl:for-each>
|
|</body>
|</html>
|</xsl:template>
|
|<xsl:template match="webapps/website">
| <xsl:for-each select="address">
| <tr>
|  <td>URL:</td>
|  <td><xsl:value-of select="address"/></td>
| </tr>
| </xsl:for-each>
|</xsl:template>
|
|</xsl:stylesheet>
|
|Instead of seeing 3 rows like:
|Site Name: Wwnames
|URL: www.wwnames.com
|URL: www.ozdot.com
|
|I see in IE, something like:
|Site Name: Wwnames
|http://www.wwnames.comhttp://www.ozdot.com
|
|I've tried several combinations in my second xsl:template to 
|match the 2 url's for this site without success yet.
|The xml is ment to represent a web site with more than on URL.
|
|Any Advice appreciated.
|
|Thanks
|Kind regards
|Rudi.
|
|
|
|
|
|
|
|
| XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
|
|
|



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


Current Thread