假设我有这个 XML ......
<books>
<book>
<author>
<title>
<publish_date>
<isbn_number>
<book>
</books>
...我如何编写函数或使用内置函数来返回一个字符串,该字符串只是书的所有子元素名称的逗号分隔连接?像这样...
author,title,publish_date,isbn_number
我需要这个来打印 csv 文件中的第一行标题
以下最小样式表适用于您的给定输入(修改为格式正确):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="book/*">
<xsl:value-of select="local-name()"/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:template>
</xsl:stylesheet>