GNOME Bugzilla – Bug 58791
xsl:element doesn't create the content
Last modified: 2009-08-15 18:40:50 UTC
An xsl:element with attributes is not created with the correct values Example: <?xml version='1.0' encoding='UTF-8'?> <form> <field name='description'> <prompt>Description </prompt> <initialvalue>test</initialvalue> </field> </form> with the XSL: <xsl:template match="form"> <xsl:for-each select="field"> <xsl:element name="input"> <xsl:attribute name="type">text</xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute> <xsl:value-of select="initialvalue" /> </xsl:element><td><input type="text" name="description"></td> </xsl:for-each> </xsl:template> It should give <input type="text" name="description">test but on libxslt 1.0.1 it gives <input type="text" name="description"> I tested it on Sablotron: correct answer.
Well your example is wrong, the opening input tag is not closed. Normally libxml will not give back a tree for such and input and hence xsltproc is unlikely to have ever worked on the example given. Second once the input is fixed the expected output is provided: orchis:~/XSLT/tests/general -> xsltproc bug-57.xsl ../docs/bug-57.xml <?xml version="1.0"?> <input type="text" name="description">test</input><td><input type="text" name="description"/></td> orchis:~/XSLT/tests/general -> Sorry, I'm unable to reproduce the bug, it seems the bug was in your stylesheet in some way. Daniel
I tried to upload some testcase files, but bugzilla didn want to take them... So here I will provide the URL's for the stylesheet http://www.twixel.com/58791/test4.xsl and the xml file http://www.twixel.com/58791/test4.xsl They work OK on Saxon and Sablotron, but not on libxslt. If you remove the <xsl:output method="html"> tag it works....
The bug is on your side I confirm. Saxon and Sablotron are IMHO broken if they accept this: orchis:~/tmp -> xsltproc --debug test4.xsl test4.xml HTML DOCUMENT standalone=true ELEMENT tr ELEMENT td TEXT content=Description ELEMENT td ELEMENT input ATTRIBUTE type TEXT content=text ATTRIBUTE name TEXT content=description TEXT content=test orchis:~/tmp -> xsltproc test4.xsl test4.xml <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <tr> <td>Description </td> <td><input type="text" name="description"></td> </tr> orchis:~/tmp -> The XSLT processing generates the "test" text node. It's however not serialized, the reason is versy simple, the containing element "input" is empty per the HTML4 DTD http://www.w3.org/TR/html4/interact/forms.html#edef-INPUT Fix your stylesheet, Daniel