JAVAを勉強中のものです。
XMLについて質問です。
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class HelloWorldXSLT {
public static void main( String[] args) {
try {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer =
factory.newTransformer(new StreamSource("helloworldxslt.xsl"));
transformer.setOutputProperty("encoding","Shift_JIS");
transformer.transform(new StreamSource( "helloworldxslt.xml"),
new StreamResult(System.out));
} catch(Exception e) {e.printStackTrace();}}}
にてXMLファイルの変わりに
static String xmlData = "<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>
<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"><xsl:template match=\"/\"><html><head><title>Hello World</title></head><body><h1>XSLTでHello World</h1>
<table border=\"1\"><tr><td>NO</td><td>言語</td>
<td>メッセージ</td></tr><xsl:for-each select=\"data/item\">
<tr><td><xsl:value-of select=\"no\"/></td><td>
<xsl:value-of select=\"lang\"/></td><td>
<xsl:value-of select=\"message\"/></td></tr></xsl:for-each></table>
</body></html></xsl:template></xsl:stylesheet> ";
というデータを渡してHTMLを出力したいです。
いろいろやってみたのですが浅学ゆえ分かりません。
何か良い方法はないでしょうか?