If you don't specify a template rule for a particular element, then the
default template rule kicks in. The default template rule for elements
copies the content to the output. If this isn't what you want, you can
override it:
<xsl:template match="*"/>
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Elijah Mori
Sent: 10 April 2003 04:50
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Newbie Q: Why are element contents being
passed through?
Many apologies if this is a FAQ; I didn't find it when
looking, but the
FAQ at dpawson.co.uk is massive and I may have missed it.
I have an xml source doc which I want to turn into an xhtml document
with a form, inputs, labels and so forth. What is happening
is that the
contents of the elements in the xml document are turning up in the
output and I can't understand why. I have simplified the xml
and the xsl
until there is almost nothing happening, and the element
contents still
come through.
What can I do? Any help will be appreciated. (And if there is
any way to
deal with the bizarre spacing in the output document that would be
appreciated too!)
Best regards
Eli
Here are the two input docs and the output.
xml:
<?xml version="1.0"?>
<form name="rateshop" action="backend/update-shop.php">
<shopid>
<label>Shop ID</label>
<input type="hidden"/>
</shopid>
<name>
<label>Name</label>
<input type="text"/>
</name>
<regionid>
<label>Region</label>
<input type="select" option="singlechoice"><option
value="1">Hokkaido</option><option value="2">Aomori</option><option
value="3">Iwate</option><option value="4">Miyagi</option><option
value="5">Yamagata</option></input>
</regionid>
<city>
<label>City</label>
<input type="text"/>
</city>
<blockaddress>
<label>Block Address</label>
<input type="text"/>
</blockaddress>
<phonenumber>
<label>Phone Number</label>
<input type="text"/>
</phonenumber>
<openingtime>
<label>Opening Time</label>
<input type="select" option="singlechoice"><option
value="10:00">10:00</option><option
value="11:00">11:00</option><option
value="12:00">12:00</option><option
value="13:00">13:00</option><option
value="14:00">14:00</option><option value="15:00">15:00</option>
</openingtime>
<closingtime>
<label>Closing Time</label>
<input type="select" option="singlechoice"><option
value="00:00">00:00</option><option
value="01:00">01:00</option><option
value="02:00">02:00</option><option
value="03:00">03:00</option><option
value="04:00">04:00</option><option
value="05:00">05:00</option><option
value="23:00">23:00</option></input>
</closingtime>
<rating>
<label>Rating</label>
<input type="select" option="singlechoice">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</input>
</rating>
<userid>
<label>User ID</label>
<input id="userid" type="hidden"/>
</userid>
</form>
xslt:
<?xml version="1.0"?>
<xsl:stylesheet version =' 1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output
doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
doctype-public='-//W3C//DTD XHTML 1.1//EN'
method='xml'
/>
<xsl:output
encoding="iso-8859-1"
/>
<xsl:template match='/'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Shop</title>
<link href='css/site.css' type='text/css'
rel='stylesheet'/>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match='form'>
<form>
<xsl:copy-of select='@*'/>
<xsl:apply-templates/>
</form>
</xsl:template>
</xsl:stylesheet>
output:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Shop</title>
<link href="css/site.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<form name="rateshop" action="backend/update-shop.php">
Shop ID
Name
Region
HokkaidoAomoriIwateMiyagiYamagata
City
Block Address
Phone Number
Opening Time
10:0011:0012:0013:0014:0015:00
Closing Time
00:0001:0002:0003:0004:0005:0023:00
Rating
1
2
3
4
5
6
7
8
9
10
User ID
</form>
</body>
</html>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list