Hallo zusammen,
bitte um Info, was in meinem Code nicht korrekt ist. -> Benötige keine Duplikate von "TEXT_LINE" unter GRP.
Hier mein XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="HeaderText[generate-id() != generate-id(key('header_text', TEXT_LINE)[1])]" />
<xsl:template match="GRP">
<xsl:copy>
<!--copy content of TXT_001 to GRP, so it can be used to set symbol at SalesTable -->
<xsl:for-each select="./TXT_001">
<xsl:if test="./TEXT_LINE != ''">
<TEXT_LINE>
<xsl:text>yes</xsl:text>
</TEXT_LINE>
</xsl:if>
</xsl:for-each>
<!--copy all other nodes-->
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="HeaderText[generate-id() != generate-id(key('header_text', TEXT_LINE)[1])]" />
<!-- delete empty nodes -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(@*|*|comment()|processing-instruction()) and normalize-space()='']"/>
<!-- delete empty nodes -->
</xsl:stylesheet>
und hier mein XML:
<?xml version="1.0"?>
<SEEDELFOR>
<CNT>
<GRP>
<REF_ON>12345</REF_ON>
<TXT_001>
<QUALIFIER>ZZZ</QUALIFIER>
<TEXT_LINE> Test1</TEXT_LINE>
</TXT_001>
<TXT_001>
<QUALIFIER>PUR</QUALIFIER>
<TEXT_LINE> Test2</TEXT_LINE>
</TXT_001>
<ITEM>
<ITEM_NUMBER_EN>1234556789123</ITEM_NUMBER_EN>
</ITEM>
</GRP>
</CNT>
</SEEDELFOR>
Danke & LG Julin