XSLTを使用してhtmlコンテンツをxml構造にスクレイプしようとしていますが、XALAN(CLI)を使用してxsltをhtmlに対してテストし、結果に満足したら、xsltファイルを取得し、トランスフォーマーを使用してjavaコードから使用しました( javax.xml.transform.TransformerFactory)、以下は実際のコードとスタイルシートに似たテスト値です。
私のhtmlサンプルデータ:
<html><body class='home'>
<div >Welcome !!</div>
<table border='0'><tr><td colspan='2'>asdas</td></tr>
<tr><td class='footer' colspan='2' align='center'>Disclaimer: The information provided below is for informative purpose only and it is not a legal document.</td></tr>
<tr><td colspan='2'>test;</td></tr>
<tr><td class='Home' width='50%' aligh='center'> number:</td><td class='Home' width='50%' aligh='center'>515120</td></tr><tr><td class='Home' width='50%' aligh='center'>Connection :</td><td class='Home' width='50%' aligh='center'>123.23</td></tr><tr><td class='Home'>period (month / year):</td><td class='Home'>04/2012</td></tr><tr><td class='Home'>Date:</td><td class='Home'>APRIL 08,2012, 21:35</td></tr> </table>
</body>
</html>
私のxslのみのテンプレートは次のとおりです。
<xsl:template match="*">
<usage_channel>
<head><xsl:value-of select="//div/text()" /></head>
<body><xsl:value-of select="//td/font/text()" /></body>
<footer><xsl:value-of select="body/table/tr[contains(td,'number')]/td[1]/text()" /></footer>
</usage_channel>
</xsl:template>
XALAN(cli)を使用した結果:
<?xml version="1.0" encoding="UTF-8"?><usage_channel><head>Welcome !!</head><body/><footer> number:</footer></usage_channel>
Javaトランスフォーマーを使用した結果:
<?xml version="1.0" encoding="UTF-8"?>
<usage_channel>
<head>Welcome !!</head>
<body/>
<footer/>
</usage_channel>
tdの値をキャッチすることを期待してすべての組み合わせを試しましたが、失敗しました。ここで何が欠けていますか?