You may find Java Almanac a useful resource.
specifically the Quintessential Program, which converts an XML file with XSL . Sample copied from page (as it continues to fade)
import java.io.*; import org.w3c.dom.*; import org.xml.sax.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; public class BasicXsl {
Input Example:
<?xml version="1.0" encoding="UTF-8"?> <map> <entry key="key1" value="value1" /> <entry key="key2" /> </map>
Example XSLT program:
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="map"> <HTML> <HEAD> <TITLE>Map</TITLE> </HEAD> <BODY> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="entry"> <xsl:value-of select="@key"/>=<xsl:value-of select="@value"/> <br></br> </xsl:template> </xsl:stylesheet>
As a result of the HTML from the example:
<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Map</TITLE> </HEAD> <BODY> key1=value1<br> key2=<br> </BODY> </HTML>
Thorbjรธrn Ravn Andersen
source share