[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: Re: Doubled output of text nodes

Subject: Re: Re: Re: Doubled output of text nodes
From: "ashu t" <aashut@xxxxxxxxxxxxxx>
Date: 15 Jul 2002 14:05:19 -0000
checkbox removing childnodes
Thanks charles
actually i have no control over the input file it can be any html page.
i am writting a stylesheet to convert them to wml.
before applying the stylesheet to input html i am converting that into well formed xhtml using tidy.
the solution which you have given is giving the text between<option>and </option>
but the problem is that in the <xsl:template match="form"> i have used <xsl:apply-templates/> for processing child nodes of form which can be any thing along with <select> .so that is also producing the text which is after <input> in html like jazz or living.
which i do not want it is actually wrong it should come only once that is between<option >and </option> .
can you suggest a better way as i am trying but output is coming twice.
ashu












On Fri, 12 Jul 2002 Charles Knell wrote :
My problem involved recursively invoking a template to process a nested
set of elements with the same tag name. It doesn't apply in your situation.
I did look over your stuff and I've simplified your HTML and XSLT so
that I believe what I've done contains the kernel of a fix for your issue.
You'll have to add back the complexity to see if I missed something important.
I had not worked with <xsl:key> or the key() function before, so this
was a valuable experience for me. I hope the following will be valuable
to you, too.
########################################
The simplified HTML:


<html>
<body>
<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>
</body>
</html>
########################################
The simplifed XSLT:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" encoding="UTF-8" />
<xsl:key name="rtl" match="input[@type='radio']" use="@name" />
<xsl:template match="div">
<xsl:variable name="name" select="key('rtl', 'category')[position()=1]/@name"
/>
<select name="{$name}">
<xsl:for-each select="key('rtl', 'category')">
<option value="{@value}">
<xsl:value-of select="following-sibling::text()"/>
</option>
</xsl:for-each>
</select>
</xsl:template>
</xsl:stylesheet>
########################################
The output:


Specify your music preferences (check all that apply):
R&B
Jazz
Blues
New Age
Choose a Category of Room:
<select name="category">
  <option value="liv"> Living</option>
  <option value="din"> Dining</option>
  <option value="bed"> Bedroom</option>
</select>

--
Charles Knell
cknell@xxxxxxxxxx - email


---- "ashu t" <aashut@xxxxxxxxxxxxxx> wrote:
> could you please give the solution what you have found in the book
>
> as i have the same problem of doubled output
> i have a html file which has
> <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>
>
> when i am using this style sheet
> <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()"/>
> </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()"/>
> </option>
> </select>
> </xsl:when>
>
> </xsl:choose>
> </xsl:template>
>
> <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/>
> </xsl:template>
>
> it is producing out put like this
> <p>
> Specify your music preferences (check all that apply):
>
> <select name="musicpref_rnb" multiple="true" ivalue="1"><option
> value="">R&B</option></select>R&B<br/>
> <select name="musicpref_jazz" multiple="true" ivalue="1"><option
> value="">Jazz</option></select>Jazz<br/>
> <select name="musicpref_blues" multiple="true"><option
> value="">Blues</option></select>Blues<br/>
> <select name="musicpref_newage" multiple="true"><option
> value="">New Age</option></select>New Age
>
> Choose a Category of Room:
>
> <select name="category"><option value="liv">
> Living</option><option value="din"> Dining</option><option
> value="bed"> Bedroom</option></select> Living<br/>
> Dining<br/>
> Bedroom
> </p>
> but i need output only between <option>and </option>
> may be it is being processed two times one by code in tempplate
> match ="input" and one by <apply-templates> in template
> match="form" if i remove this line
> <xsl:value-of select="following-sibling::text()"/>
> text is not coming between <option> and </option> which is
> required
> can you help me
> ashu
> _________________________________________________________
> 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
>
>


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


_________________________________________________________ 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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.