この質問は、XSLT に精通した作成者にとってはおそらく簡単に答えることができます。
次の XML ドキュメントの例があります。
<?xml version="1.0" encoding="UTF-8"?>
<students>
<student num="12345678">
<name>Dona Diller</name>
<dob>1970-07-21</dob>
<education>BSc</education>
<education>MSc</education>
<status>Married</status>
</student>
<!-- more student elements to follow... -->
</students>
そして、次の XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<title>Test</title>
<body>
<h1>Personal details</h1>
<xsl:apply-templates select="students/student"/>
</body>
</html>
</xsl:template>
<xsl:template match="student">
<p>
Student number:
<xsl:value-of select="@num"/>
</p>
<p>Full name:
<xsl:value-of select="name"/>
</p>
<p>Date of birth
<xsl:value-of select="dob"/>
</p>
<!-- TODO: text of 'education' elements must be separated by a space -->
<p>Degrees:
<xsl:apply-templates select="education"/>
</p>
<p>Status:
<xsl:value-of select="status"/>
</p>
</xsl:template>
</xsl:stylesheet>
この投稿の冒頭に含まれている XML ドキュメントに適用すると、次の XHTML 出力が生成されます。
<html>
<title>Test</title>
<body>
<h1>Personal details</h1>
<p>
Student number:
12345678
</p>
<p>Full name:
Dona Diller
</p>
<p>Date of birth
1970-07-21
</p>
<p>Degrees:
BScMSc
</p>
<p>Status:
Married
</p>
</body>
</html>
私の問題は、学位名が 1 つの文字列 (教育要素のテキスト) としてマージされることです。したがって、出力で「BScMSc」を取得する代わりに、前の例で「BSc MSc」を表示したいと思います。何かご意見は?