XML の歌詞のデータベースを XSLT を使用して HTML に変換しようとしています。私の XML は次のように始まります。
<?xml version='1.0' encoding='utf-8'?>
<song xmlns="http://openlyrics.info/namespace/2009/song" version="0.8" createdIn="OpenLP 2.0.1" modifiedIn="OpenLP 2.0.1" modifiedDate="2012-03-14T02:21:52">
<properties>
<titles>
<title>Amazing Grace</title>
</titles>
<authors>
<author>John Newton</author>
</authors>
</properties>
<lyrics>
<verse name="v1">
<lines>Amazing grace, how sweet the sound<br/>That saved a wretch like me<br/>I once was lost, but now am found<br/>Was blind but now I see</lines>
他の投稿から、上記の名前空間を XSLT に追加する必要があることを知っています。試してみたところ、XSLT は次のようになります。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lyrics="http://openlyrics.info/namespace/2009/song">
<xsl:template match="lyrics:song">
<h3><xsl:value-of select="properties/titles/title"/></h3>
<h4><xsl:value-of select="properties/authors/author"/></h4>
<xsl:for-each select="lyrics/verse">
<xsl:copy-of select="lines" /><br /><br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
残念ながら、このコードはまだ機能していません。私の XSLT は、XML の xmlns エントリを削除し、"song" を直接一致させた場合にのみ機能します。「歌詞」というタイトルの xmlns 名前空間に関して、私が間違っていることを誰か指摘できますか? 私は XML/XSLT の初心者です。前もって感謝します!