thanks Joerg
i have written the stylesheet as you suggested but it is still
producing the doubled output.
i think we should give some condition in the template match="form"
that aply-templates to all but the text following <input>but
how??????
the html is
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>HELLO</title>
</head>
<body bgcolor="#C0C0C0" text="#443481" link="#0000EE">
<p>HELLO ALL</p>
<div>This is a hotel with your favourite musIc</div>
<a href="pcs1.html"> MUSIC LINK</a>
<div><font size="+1">EAST TO WEST </font></div>
<form method="POST" action="urlToInvoke">
<p>Specify your music preferences (check all that apply):</p>
<p><input type="checkbox" name="musicpref_rnb" checked="checked"
/>R&B<br />
<input type="checkbox" name="musicpref_jazz" checked="checked"
/>Jazz<br />
<input type="checkbox" name="musicpref_blues" />Blues<br />
<input type="checkbox" name="musicpref_newage" />New Age</p>
<p>Choose a Category of Room:</p>
<div style="margin-left: 2em"><input type="radio" name="category"
value="liv" checked="checked" /> Living<br />
<input type="radio" name="category" value="din" /> Dining<br
/>
<input type="radio" name="category" value="bed" />
Bedroom</div>
</form>
<br />
<br />
All Latinos have their own rhythms.Columbia has its
Salsa,Argentina its Tango,and of course, <a
href="pcs5.html">Brazil</a> its Samba.<br />
<br />
</body>
</html>
and the style sheet is
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="radios" match="input[@type='radio']"
use="@name"/>
<xsl:key name="checkboxes" match="input[@type='checkbox']"
use="@type"/>
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<wml>
<card title="wml output">
<xsl:apply-templates/>
</card>
</wml>
</xsl:template>
<xsl:template match="head"/>
<xsl:template match="body">
<xsl:apply-templates/>
</xsl:template>
<!--This is for matching div tag -->
<xsl:template match="p/div | div/div | center/div | ul/div |
a/div | form/div | font/div | b/div | u/div | i/div | table/div
|tr/div | td/div | tbody/div | th/div">
<xsl:apply-templates/>
</xsl:template>
<!--This is for matching div tag when it is not inside of any
tag -->
<xsl:template match="div">
<p><xsl:apply-templates/></p>
</xsl:template>
<!--This is for matching a tag -->
<xsl:template match="a/a | div/a | center/a | p/a | ul/a |
li/a | tr/a | td/a | th/a | table/a | font/a | b/a | u/a | i/a |
span/a | dl/a | dt/a | em/a | address/a">
<xsl:variable name="url">
<xsl:value-of select="@href"/>
</xsl:variable>
<a
href="http://localhost/transform1.php?url={$url}">
<xsl:apply-templates/></a><br/>
</xsl:template>
<!--This is for matching a tag when it is not inside of any
tag-->
<xsl:template match="a">
<p><xsl:variable name="url">
<xsl:value-of select="@href"/>
</xsl:variable>
<a
href="http://localhost/transform1.php?url={$url}">
<xsl:apply-templates/></a></p>
</xsl:template>
<!--This is for matching p tag -->
<xsl:template match="p/p | div/p | center/p | ul/p | a/p |
table/p | tr/p | td/p | th/p | form/p">
<xsl:apply-templates/>
</xsl:template>
<!--This is for matching p tag when it is not inside of any
tag-->
<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>
<!--This is for matching input tag -->
<xsl:template match="font/input | form/input | td/input |
p/input | div/input | center/input | table/input">
<xsl:choose>
<xsl:when test="@type='text' or @type='password'">
<input name="{@name}" type="{@type}">
<xsl:apply-templates/>
</input>
</xsl:when>
<xsl:when test="@type='radio' and count( . | key('radios',
@name)[1] ) = 1">
<select name="{@name}">
<xsl:for-each select="key('radios', @name)">
<option value="{@value}">
<xsl:value-of
select="following-sibling::text()[1]"/>
</option>
</xsl:for-each>
</select>
</xsl:when>
<xsl:when test="@type='checkbox'">
<select name="{@name}" multiple="true">
<xsl:if test="@checked='checked'">
<xsl:attribute name="ivalue">1</xsl:attribute>
</xsl:if>
<option value="{@value}">
<xsl:value-of
select="following-sibling::text()[1]"/>
</option>
</select>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--This is for matching br tag -->
<xsl:template match="a/br | div/br | center/br | p/br | ul/br
| li/br | tr/br | td/br | th/br | table/br | form/br | input/br |
font/br">
<br/>
</xsl:template>
<!--This is for matching form tag -->
<xsl:template match="p/form | div/form | center/form | a/form
| table/form | tr/form | td/form | th/form | select/form | ul/form
| li/form">
<xsl:apply-templates select="*"/>
</xsl:template>
<!--This is for matching form tag when it is not inside of
any tag -->
<xsl:template match="form">
<p><xsl:apply-templates select="*"/></p>
</xsl:template>
<!--This is for matching font tag -->
<xsl:template match="p/font | center/font | div/font |
ul/font | li/font | a/font | tr/font | td/font | th/font |
table/font | form/font | font/font | b/font | u/font | i/font">
<xsl:apply-templates/>
</xsl:template>
<!--This is for matching font tag when it is not inside of
any tag -->
<xsl:template match="font">
<p><xsl:apply-templates/></p>
</xsl:template>
<!--This is for matching text which is inside body tag -->
<xsl:template match="body/text()">
<p><xsl:value-of select="."/></p>
</xsl:template>
</xsl:stylesheet>
<p>is used because in wml every thing should be between <p>and</p>
and one<p> can not contain another <p> so for every tag which is
not inside any tag(except body ) i have put <p>and </p>(though
there can be other possibilities of tags which can be parent but i
have used few one just trying if that works )
when applying that stylesheet it is giving doubled output
may be there is something wrong in it or i have missed something
.
can you check and suggest .
ashu
On Tue, 16 Jul 2002 Joerg Heinicke wrote :
I thought I provided the solution (despite the "new"
HTML-structure) in the last mail.
At the <option> element you have to use the <xsl:value-of
select="following-sibling::text()[1]"/>. But at the template
matching on any kind of form, you must not use
<xsl:apply-templates/> but <xsl:apply-templates select="*"/>.
This should solve the problem of doubled text output.
But a comment: If the stylesheet shell work on "any" website, you
will get problems I think. In your example it's written
<input/>text<br/>
while I would write
<input>text</input><br/>
So you will have to implement some logic for it.
Regards,
Joerg
_________________________________________________________
There is always a better job for you at Monsterindia.com.
Go now http://monsterindia.rediff.com/jobs
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list