输入:
<AAA>RIO_CBI_TE01_1 RIO_CBI_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 RIO_ATC_TE01_1 </AAA>
问题:我必须在空格后将其分成多行,并删除重复项
预期输出:
<AAA>RIO_CBI_TE01_1</AAA>
<AAA>RIO_ATC_TE01_1</AAA>
请尝试以下解决方案。
XSLT
<?xml version="1.0"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/AAA">
<root>
<xsl:for-each select="distinct-values(tokenize(., ' '))">
<AAA>
<xsl:value-of select="."/>
</AAA>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
输出XML
<?xml version='1.0' encoding='UTF-8' ?>
<root>
<AAA>RIO_CBI_TE01_1</AAA>
<AAA>RIO_ATC_TE01_1</AAA>
<AAA/>
</root>