我正在尝试使用 XSLT 1 将层次结构/结构展平为 XML,但没有成功。- 甚至找到好的链接...
输入xml
<Address addressType="R">
<Structured xmlns="cds_dt">
<Line1>15 Paradise</Line1>
<City>Toronto</City>
<CountrySubdivisionCode>-50</CountrySubdivisionCode>
<PostalZipCode>
<PostalCode>A1A1O1</PostalCode>
</PostalZipCode>
</Structured>
</Address>
所需的输出 xml
<Address addressType="R">
<Formatted xmlns="cds_dt">15 Paradise, Toronto, A1A1O1</Formatted>
</Address>
我试过这个 .xsl 但没有运气 - 文件中的错误
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="cds">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[ancestor::address]">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()[ancestor::address::Structured]">
<xsl:value-of select="concat(',',.)"/>
</xsl:template>
</xsl:stylesheet>