0
XSLファイルをHTML形式で生成しようとしましたが、動作しません。私は問題は私が定義したテンプレートマッチから来ると思う。ここでXSL変換でのテンプレートマッチの定義方法は?
は、私は、テンプレートの一致を内蔵したものとXMLである:ここでは
<?xml version="1.0" encoding="ISSO−8859−15" ?>
<Library>
<authors>
<Author id="author1" name="Einstein"/>
</authors>
<publications>
<Book year="1900" title="7 Kingdoms" author="author1"/>
<Magazine year="2010" number="203" title="The News"'/>
<Book year="1956" title="The Fall" author="author1"/>
</publications>
</Library>
は私がディスプレイ作家、書籍や出版物に取得したいHTML形式です:
<html>
<h1>Library</h1>
<h2>Authors</h2>
<ul>
<li id="author1">Einstein</li>
</ul>
<h2>Books</h2>
<ul>
<li>7 Kingdoms, 1942, <a href="#author">Einstein</a></li>
<li>The Fall, 1956, <a href="#author">Einstein</a></li>
</ul>
<h2>Magazines</h2> <ul>
<li>The News (203), 2010</li>
</ul>
</html>
これは、私が作成したテンプレートマッチです:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="Author">
<li id= "library/author/Author/@id">
<xsl:value-of select="library/authors/Author/name"/>
</li>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Magazines">
<li>
<xsl:value-of select="library/publications/magazine[@title]"/>
(
<xsl:value-of select="library/publications/magazine[@number]"/>
),
<xsl:value-of select="library/publications/magazine[@year]"/>
</li>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Book">
<li>
<xsl:value-of select="library/publications/book[@year]"/>
,
<xsl:value-of select="library/publications/book[@title]"/>
,
<xsl:value-of select="library/publications/book/author/@ref"/>
</li>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
前述のように、HTMLファイルを適切に埋め込むことができないテンプレートマッチから問題が生じると思います。
ご協力いただければ幸いです。
変換に必要なロジックの説明に加えて、** **に加えて、**の例があります。**ではなく**です。 –
library/publications/bookのような相対パス式は、コンテキスト項目*で始まる選択、つまりテンプレートルールが一致する要素であることを理解する必要があります。すべての選択がルートから始まっているように見えます。 –