Basic XML to HTML conversion

xsnowfoxx

New Member
I have what is hopefully a simple issue to debug. Using code from a book and a website I am trying to convert my XML file to an HTML file. However, I am getting no output. \[code\]<?xml version="1.0" encoding="UTF-8"?>\[/code\] \[code\] <xsl:template match="/"> <xsl:apply-templates select="greeting"/> </xsl:template><xsl:template match="greeting"> <html> <head> <title>hellowWorld.xsl</title> </head> <body> <h1> <xsl:value-of select="."/> </h1> </body> </html></xsl:template>\[/code\]. . . is the XSL, here is the XML:\[code\]<root><greeting> Hello, world! </greeting></root>\[/code\]And the code:\[code\]private static void XMLtoHTML(String xmlPath, String xslPath, String htmlPath){try {TransformerFactory tFactory = TransformerFactory.newInstance();Transformer transformer = tFactory.newTransformer (new javax.xml.transform.stream.StreamSource (xslPath));transformer.transform (new javax.xml.transform.stream.StreamSource (xmlPath), new javax.xml.transform.stream.StreamResult ( new FileOutputStream(htmlPath)));}catch (Exception e) { e.printStackTrace( );}\[/code\]Thank you very much!
 
Back
Top