Saxon9または任意のXSLT2.0プロセッサは、1つのスタイルシートで複数の結果ドキュメントを生成できます。2つのドキュメントをリンクする場合、これは難しいことではありません。他のドキュメントにリンクする属性をa
持つHTML要素を使用するだけです。href
特定のデータについてこれについてサポートが必要な場合は、小さいながらも代表的なXML入力サンプルと作成するHTMLを投稿してください。
[編集]
これらの要素がいくつかある入力ドキュメントがあり、次のように解決できる詳細をリストする個別のファイルへのa:file
すべてのリンクをリストする1つのメインHTMLドキュメントを作成するとします。a:names
<xsl:template match="/">
<xsl:apply-templates select="//a:file" mode="doc"/>
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>Data list</h1>
<ul>
<xsl:apply-templates select="//a:file"/>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="a:file">
<li>
<a href="{a:id}.html">
<xsl:value-of select="a:name"/>
</a>
</li>
</xsl:template>
<xsl:template match="a:file" mode="doc">
<xsl:result-document href="{a:id}.html">
<html>
<head>
<title>Details of <xsl:value-of select="a:name"/></title>
</head>
<body>
<table>
<thead>
<tr>
<xsl:apply-templates mode="thead"/>
</tr>
</thead>
<tbody>
<tr>
<xsl:apply-templates mode="doc"/>
</tr>
</tbody>
</table>
</body>
</html>
</xsl:result-document>
</xsl:template>
<xsl:template match="a:file/*" mode="doc">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="a:file/*" mode="thead">
<th>
<xsl:value-of select="local-name()"/>
</th>
</xsl:template>
テストされていませんが、あなたにアイデアを与えるはずです。さらにヘルプが必要な場合は、入力と必要な出力の詳細を表示してください。メインのHTML結果(リストを使用)と詳細ファイル(テーブルを使用)の両方の形式を作成する必要がありました。
[編集2]完全な入力サンプルが
<a:files xmlns:a="http://example.com/a">
<a:file>
<a:id>33</a:id>
<a:name>hello</a:name>
<a:school>mumbai public</a:school>
<a:marks>80</a:marks>
</a:file>
</a:files>
完全なスタイルシートのサンプルは
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://example.com/a"
exclude-result-prefixes="a"
version="2.0">
<xsl:template match="/">
<xsl:apply-templates select="//a:file" mode="doc"/>
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>Data list</h1>
<ul>
<xsl:apply-templates select="//a:file"/>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="a:file">
<li>
<a href="{a:id}.html">
<xsl:value-of select="a:name"/>
</a>
</li>
</xsl:template>
<xsl:template match="a:file" mode="doc">
<xsl:result-document href="{a:id}.html">
<html>
<head>
<title>Details of <xsl:value-of select="a:name"/></title>
</head>
<body>
<table>
<thead>
<tr>
<xsl:apply-templates mode="thead"/>
</tr>
</thead>
<tbody>
<tr>
<xsl:apply-templates mode="doc"/>
</tr>
</tbody>
</table>
</body>
</html>
</xsl:result-document>
</xsl:template>
<xsl:template match="a:file/*" mode="doc">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="a:file/*" mode="thead">
<th>
<xsl:value-of select="local-name()"/>
</th>
</xsl:template>
</xsl:stylesheet>
次に、コマンドラインからSaxon 9.4 HEを使用すると、たとえばjava -jar saxon9he.jar input.xml sheet.xsl -o:result.html
2つの結果ファイルが表示されます。メインはもちろんresult.html
、もう1つは33.html
次のようになります。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Example</title>
</head>
<body>
<h1>Data list</h1>
<ul>
<li><a href="33.html">hello</a></li>
</ul>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Details of hello</title>
</head>
<body>
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>school</th>
<th>marks</th>
</tr>
</thead>
<tbody>
<tr>
<td>33</td>
<td>hello</td>
<td>mumbai public</td>
<td>80</td>
</tr>
</tbody>
</table>
</body>
</html>
これは、ファイルの数とブラウザ内で機能するリンクの両方に関して、私にとっては問題なく機能します。