xslt を使用して、いくつかのテンプレートを xml ファイルに適用し、html ページを出力しています。そこで、「xsl:output」のメソッドを「html」と定義しました。ただし、xml ファイルからいくつかの xml ノードを元の形式で表示する必要がありますが、残念ながら期待どおりに html ページに表示されませんでした。
これは、サンプルの xml ファイルです。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<employees>
<employee>
<name>Hello World</name>
<title>UI Designer</title>
</employee>
</employees>
私のxsltは次のとおりです:
<?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="/">
<html>
<head>
<title>Example of Employee Data</title>
</head>
<body>
<h2>The following shows the structure of employee data file: </h2>
<div style="background-color: grey">
<xsl:copy-of select="employees/employee"/>
</div>
......
</body>
</html>
</xsl:template>
</xsl:stylesheet>
ページのソースを表示すると、ノード 'employee' とその子がそこにあり、それらは html ページに表示されませんでした。出力方法を「html」に指定したからだと思います。しかし、HTML ページを生成し、いくつかの xml 形式のノードを自分のページに埋め込む必要があります...
私は試みてきましたが失敗しました...誰か助けてくれませんか?ありがとう!!
出力ページは次のようになると思います。