Subject: AW: [xsl] An easy problem From: "Thomas Bayer" <bayer@xxxxxx> Date: Sat, 27 Jul 2002 17:43:11 +0200 |
Hello Alexek, I think the following Stylesheet will do it. Use an index for alle radio input fields. You can create the index with xsl:key. Iterate over the index and take only the first element for each key. To do this I used a method called muenchs method [Correct me for the right spelling]. <?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:key name="radios" match="//input[@type='radio']" use="@name"/> <xsl:template match="form"> <do type="accept" label="submit"> <go href="{@action}" method="{@method}"> <xsl:apply-templates select=".//input[@type='checkbox']"/> <xsl:for-each select="//input[generate-id(.)=generate-id(key('radios', @name))]"> <postfield name="{@name}" value="{concat('$',@name)}"/> </xsl:for-each> </go> </do> <xsl:apply-templates select="*"/> </xsl:template> <xsl:template match="input[@type='checkbox']"> <postfield name="{@name}" value="{concat('$',@name)}"/> </xsl:template> </xsl:stylesheet> Thomas Orientation in Objects http://www.oio.de > -----Ursprüngliche Nachricht----- > Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von alex ek > Gesendet: Samstag, 27. Juli 2002 16:51 > An: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Betreff: [xsl] An easy problem > > > Hello All > I have a problem in xslt style sheet in which i am writing > template match for the form tag of HTML. > I hev some thing like this in HTML > <form method="POST" action="choice.html"> > <p>Enter the choices</p> > <p><input type="checkbox" name="name1" checked="checked" > />America<br /> > <input type="checkbox" name="name2" checked="checked" > />Europe<br /> > <input type="checkbox" name="name3" />Asia </p> > <p>Enter the gender</p> > <input type="radio" name="gender" value="mal" />male<br /> > <input type="radio" name="gender" value="fem" /> female > </form> > > And i want to convert it in this form > > <do label="submit" type="accept"> > <go href="choice.html" method="post"> > <postfield name="name1" value="$name1"/> > <postfield name="name2" value="$name2"/> > <postfield name="name3" value="$name3"/> > <postfield name="gender" value="$gender"/> > </go> > </do> > > And the style sheet i am using is > > <xsl:template match="form"> > <do type="accept" label="submit"> > <go href="@action" method="@method"> > <xsl:choose> > <xsl:when test="input[@type='checkbox']"> > <xsl:for-each select="input[@type='checkbox']"> > <postfield name="@name" value="$@name"> > </xsl:for-each> > </xsl:when> > <xsl:when test="input[@type='radio']> > <postfield name=@name" value="$@name"> > </xsl:when> > </xsl:choose> > </go> > </do> > <xsl:apply-templates select="*"/> > </xsl:template> > > Though i should check in input[@type='radio'] that name of the > preceding sibling is same or not because in type radio name is > same for all.so it should come only once . > But this is not working even after removing the when condition of > input type radio and simply using type check box only . > It is giving error . > What is wrong in it and what should be the correct way. > Itried various combinations even removing for-each loop and giving > only one input type =checkbox in input but it is not working . > The rest of style sheet working . > if i use only > > <xsl:template match="form"> > <p><xsl:apply-templates select="*"/> > </xsl:template> > It is working but as obvious not creating any post field which is > required for form handling. > Need help. > Alexek > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] An easy problem, alex ek | Thread | Re: [xsl] An easy problem, Joerg Heinicke |
[xsl] ampersands in URL as attribut, Phillip Rhodes | Date | RE: [xsl] ampersands in URL as attr, Julian Reschke |
Month |