I need to change some element names in the source XML. I am trying to do this using XSLT, but cannot make it work.
Here is an example XML:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="test.xsl" type="text/xsl"?> <html> <body> <section>Jabber</section> <itemtitle>JabberJabber</itemtitle> <p>Always Jabber Jabber Jabber</p> <h3>Emboldened Requests </h3> <p>Somemore Jabber Here</p> <img scr="bigpicture.jpg"></img> <poll><p>Which statement best characterizes you?</p></poll> <pcredit>Left: Jumpin Jasper/Jumpy Images</pcredit> </body> </html>
I need to change it to:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="test.xsl" type="text/xsl"?> <html> <body> <div class="issuehead">Jabber</div> <div class="issuetitle">JabberJabber</div> <p>Always Jabber Jabber Jabber</p> <h3>Emboldened Requests </h3> <p>Somemore Jabber Here</p> <img scr="bigpicture.jpg"></img> <div class="poll"><p>Which statement best characterizes you?</p></div> <div class="pcredit">Left: Jumpin Jasper/Jumpy Images</div> </body> </html>
Here is the XSLT I made, but I can't get it to work:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" /> <xsl:template match="/"> <html> <head> </head> <body> <xsl:apply-templates/> </body> </html> <xsl:template match="section"> <div class="issuehead"><xsl:value-of select="."/></div> </xsl:template> <xsl:template match="itemtitle"> <div class="issuetitle"> <xsl:value-of select="."/></div> </xsl:template> <xsl:template match="img"></xsl:template> <xsl:template match="poll"> <div class="poll"><xsl:value-of select="."/></div> </xsl:template> <xsl:template match="pcredit"> <div class="pcredit"><xsl:value-of select="."/></div> </xsl:template> <xsl:template match="p"></xsl:template> <xsl:template match="h3"></xsl:template> </xsl:template> </xsl:stylesheet>
Thanks for the help!
Newtoxml
source share