0

私はxmlとXSLTを勉強しています。

そして、family.xmlファイルからすべての名前を表示できるXSLTファイルを作成したいと思います。

私は持っています...

doc( "family.xml")// NAME

ただし、XSLTファイルでdoc関数を使用するための構文がよくわかりません。

誰かが私を助けることができますか?

ありがとう

4

1 に答える 1

1

filename.xml が次のようになっているとしましょう。

<?xml version="1.0"?>
<bookstore>
  <book category="COOKING">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>
  <book category="CHILDREN">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
  <book category="WEB">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>39.95</price>
  </book>
</bookstore>

すべてのタイトルを取得するには:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">

<!-- match root documents tag -->
<xsl:template match="/">
<xsl:apply-templates select="document('filename.xml')/bookstore//title/node()" mode="document"/>
</xsl:template>


  <xsl:template match="/" mode="document">
    <xsl:copy-of select="."/>
  </xsl:template>

</xsl:stylesheet>
于 2013-02-15T01:22:25.520 に答える