XML:
<?xml version="1.0" encoding="UTF-8"?>
<Service>
<Author name="Raymond">
<Book>Master Mind</Book>
<Book>Big Bites</Book>
</Author>
<Author name="CLAYTON">
<Book>Beyond the RACK</Book>
</Author>
</Service>`
使用此XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="//Author">
<xsl:value-of select="@name" />
<xsl:for-each select="//Book">
<xsl:value-of select="." />
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>`
预期产出:
Raymond Master Mind Big Bites CLAYTON Beyond the RACK
答案 0 :(得分:2)
为内部select="Book"
for-each
答案 1 :(得分:1)
<xsl:for-each select="//Book">
从/
根节点开始,从整个文档中选择所有 Book节点。要仅选择作为当前作者的孩子的书籍,请尝试:
<xsl:for-each select="Book">
-
注意:我不清楚您希望在写入输出的值之间插入空格的基础。