Wednesday 15 February 2012

html - Can't display xml file after adding xsl stylesheet -



html - Can't display xml file after adding xsl stylesheet -

everything worked fine, before. when added style reference xml blank page in browsers. although in firefox error says."xml parsing error: not well-formed" , points line 16 sec tr tag. when view in preview tool in coda can see table headers , h1, none of info shows up. it's simple document. it's formatted illustration on w3c here. i've tried going though other solutions on here, none of them seem prepare problem. i've tried various combinations of headers, no luck. appreciate help. thanks

the xml:

<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?> <friendlist> <friend> <name>speen</name> <age>23</age> <address>430 street, slc ut</address> <phone>801-555-8796</phone> <email>xxx</email> </friend> <friend> <name>wafiq</name> <age>25</age> <address>xxx</address> <phone>325-555-4232</phone> <email>xxx</email> </friend> </friendlist>

the xsl:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <html> <body> <h1>my friends</h1> <table border="1"> <tr bgcolor="grey"> <th style="text-align:center">name</th> <th style="text-align:center">age</th> <th style="text-align:center">address</th> <th style="text-align:center">phone</th> <th style="text-align:center">email</th> </tr> <xsl:for-each select="friendlist/friend"> <tr> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="age"/></td> <td><xsl:value-of select="address"/></td> <td><xsl:value-of select="phone"/></td> <td><xsl:value-of select="email"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

works fine me in firefox.

data not showing xpath case sensitive. alter xsl utilize right xpath selectors.

class="lang-xml prettyprint-override"><xsl:for-each select="friendlist/friend"> <tr> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="age"/></td> <td><xsl:value-of select="address"/></td> <td><xsl:value-of select="phone"/></td> <td><xsl:value-of select="email"/></td> </tr> </xsl:for-each>

html xml xslt

No comments:

Post a Comment