Jump to content

xsl:template problem


leon_pegg

Recommended Posts

i have this xml<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="test.xsl"?><form><radiogroup group="test"><item value="one">1</item><item value="two">2</item></radiogroup></form>and this xsl<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><form><xsl:apply-templates/><input type="submit" name="submit" value="submit"/></form></body></html></xsl:template><xsl:template match="radiogroup"><xsl:for-each select="item"><input type="radio" name="{@radiogroup/group}" value="{@value}" ><xsl:value-of select="radiogroup/item"/></input><br/></xsl:for-each></xsl:template></xsl:stylesheet>but for some reason it dose not work any ideasregards leon pegg

Link to comment
Share on other sites

Maybe because there's no @radiogroup attribute in your XML, but only a radiogroup element. Also, I see the form element is not translated in any way. I would try something like this:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><xsl:apply-templates/></body></html></xsl:template><xsl:template match="form"><form><xsl:apply-templates/><input type="submit" name="submit" value="submit"/></form></xsl:template><xsl:template match="radiogroup"><ul><xsl:for-each select="item"><li><input type="radio" name="{../@group}" value="{@value}" ><xsl:value-of select="."/></input></li></xsl:for-each></ul></xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...