Hi Thomas,
leider sieht mein XML nach Anleitung der XSLT-Lösung folg. aus:
<?xml version="1.0" encoding="utf-8"?><SALESINVOICE>
<Interchange>
<Recipient></Recipient>
<Sender></Sender>
<CreationDate></CreationDate>
<Test></Test>
<Interchange_Control_Number></Interchange_Control_Number>
<HeaderInformation><OrigInvoiceNumber></OrigInvoiceNumber><InvoiceType></InvoiceType><InvoiceDate></InvoiceDate><InvoiceNumber></InvoiceNumber><PurchOrderReference /><CustomerOrderReference></CustomerOrderReference><SalesOrderReference></SalesOrderReference><SalesOrderDate></SalesOrderDate><PackingslipId></PackingslipId><DeliveryDate></DeliveryDate><Currency></Currency><TaxExempt></TaxExempt><OurAccountNum /><HeaderText>
<Qualifier>AAI</Qualifier>
<Text>AAI10854</Text>
</HeaderText><HeaderText>
<Qualifier>DEL</Qualifier>
<Text>DEL0854</Text>
</HeaderText><LineItem><Lines><OrderLineNum></OrderLineNum><Promotion /><PackingslipId></PackingslipId><DeliveryDate /><GTINNumber></GTINNumber><GTINDescription></GTINDescription><SupplierArticleNumber></SupplierArticleNumber><BuyerArticleNumber /><Quantity></Quantity><PriceUnit></PriceUnit><FixedPrice></FixedPrice><SalesPrice></SalesPrice><SalesPriceNet /><DiscAmount></DiscAmount><DiscPercent></DiscPercent><SalesLinePercent1></SalesLinePercent1><SalesLinePercent2></SalesLinePercent2><MultiLnDisc></MultiLnDisc><MultiLnPercent></MultiLnPercent><LineAmount></LineAmount><SumLineDisc></SumLineDisc><DeliveredQuantity></DeliveredQuantity><VatBaseAmount></VatBaseAmount><VatPercentage></VatPercentage><Measure_Unit></Measure_Unit><LineText>
<Qualifier>AAA</Qualifier>
<Text>AAA1-0927</Text>
</LineText><LineText>
<Qualifier>LIN</Qualifier>
<Text>LIN1-0927</Text>
</LineText></Lines></LineItem></HeaderInformation>
</Interchange>
</SALESINVOICE>
Jetzt fehlen mir einige meiner Knoten im XML, die Duplikate wurden jedoch korrekterweise entfernt.
Was hab ich hier falsch gemacht?
Hier das vollständige XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SALESINVOICE>
<Interchange>
<Recipient></Recipient>
<Sender></Sender>
<CreationDate></CreationDate>
<Test></Test>
<Interchange_Control_Number></Interchange_Control_Number>
<HeaderInformation>
<OrigInvoiceNumber></OrigInvoiceNumber>
<InvoiceType></InvoiceType>
<InvoiceDate></InvoiceDate>
<InvoiceNumber></InvoiceNumber>
<PurchOrderReference></PurchOrderReference>
<CustomerOrderReference></CustomerOrderReference>
<SalesOrderReference></SalesOrderReference>
<SalesOrderDate></SalesOrderDate>
<PackingslipId></PackingslipId>
<DeliveryDate></DeliveryDate>
<Currency></Currency>
<TaxExempt></TaxExempt>
<OurAccountNum></OurAccountNum>
<HeaderText>
<Qualifier>AAI</Qualifier>
<Text>AAI10854</Text>
</HeaderText>
<HeaderText>
<Qualifier>DEL</Qualifier>
<Text>DEL0854</Text>
</HeaderText>
<HeaderText>
<Qualifier>AAI</Qualifier>
<Text>AAI10854</Text>
</HeaderText>
<HeaderText>
<Qualifier>DEL</Qualifier>
<Text>DEL0854</Text>
</HeaderText>
<HeaderText>
<Qualifier>AAI</Qualifier>
<Text>AAI10854</Text>
</HeaderText>
<HeaderText>
<Qualifier>DEL</Qualifier>
<Text>DEL0854</Text>
</HeaderText>
<Contact>
<Contact></Contact>
<ContactPhone></ContactPhone>
<ContactMail></ContactMail>
</Contact>
<TermsOfPayment>
<PaymTermDescription></PaymTermDescription>
<DueDate></DueDate>
</TermsOfPayment>
<CashDiscountConditions>
<CashDiscountConditions></CashDiscountConditions>
<CashDiscPercent></CashDiscPercent>
<CashDiscDate></CashDiscDate>
</CashDiscountConditions>
<WeightAndVolume>
<NetWeight></NetWeight>
<UnifOfWeight></UnifOfWeight>
</WeightAndVolume>
<SupplierAddressInformation>
<EANcode></EANcode>
<Name></Name>
<Street></Street>
<ZipCode></ZipCode>
<City></City>
<Country></Country>
<CoRegNum></CoRegNum>
<VATNum></VATNum>
<PlaceOfJurisdiction></PlaceOfJurisdiction>
<WeeeNumber></WeeeNumber>
</SupplierAddressInformation>
<BuyerAddressInformation>
<EANcode></EANcode>
<Name></Name>
<Street></Street>
<ZipCode></ZipCode>
<City></City>
<Country></Country>
<VATNum></VATNum>
<InternalNumber></InternalNumber>
</BuyerAddressInformation>
<InvoiceAddressInformation>
<EANcode></EANcode>
<Name></Name>
<Street></Street>
<ZipCode></ZipCode>
<City></City>
<Country></Country>
<VATNum></VATNum>
<InternalNumber></InternalNumber>
</InvoiceAddressInformation>
<DeliveryAddressInformation>
<EANcode></EANcode>
<Name></Name>
<Street></Street>
<ZipCode></ZipCode>
<City></City>
<Country></Country>
<State></State>
<VATNum></VATNum>
<InternalNumber></InternalNumber>
</DeliveryAddressInformation>
<TransportDetails>
<DeliveryMode></DeliveryMode>
<DeliveryTerms></DeliveryTerms>
<DeliveryReason></DeliveryReason>
</TransportDetails>
<LineItem>
<Lines>
<OrderLineNum></OrderLineNum>
<Promotion></Promotion>
<PackingslipId></PackingslipId>
<DeliveryDate></DeliveryDate>
<GTINNumber></GTINNumber>
<GTINDescription></GTINDescription>
<SupplierArticleNumber></SupplierArticleNumber>
<BuyerArticleNumber></BuyerArticleNumber>
<Quantity></Quantity>
<PriceUnit></PriceUnit>
<FixedPrice></FixedPrice>
<SalesPrice></SalesPrice>
<SalesPriceNet></SalesPriceNet>
<DiscAmount></DiscAmount>
<DiscPercent></DiscPercent>
<SalesLinePercent1></SalesLinePercent1>
<SalesLinePercent2></SalesLinePercent2>
<MultiLnDisc></MultiLnDisc>
<MultiLnPercent></MultiLnPercent>
<LineAmount></LineAmount>
<SumLineDisc></SumLineDisc>
<DeliveredQuantity></DeliveredQuantity>
<VatBaseAmount></VatBaseAmount>
<VatPercentage></VatPercentage>
<Measure_Unit></Measure_Unit>
<LineText>
<Qualifier>AAA</Qualifier>
<Text>AAA1-0927</Text>
</LineText>
<LineText>
<Qualifier>LIN</Qualifier>
<Text>LIN1-0927</Text>
</LineText>
<LineText>
<Qualifier>AAA</Qualifier>
<Text>AAA1-0927</Text>
</LineText>
</Lines>
</LineItem>
<Totals>
<InvoiceTotal></InvoiceTotal>
<NetAmount></NetAmount>
<VATAmount></VATAmount>
<DiscountAmount></DiscountAmount>
<AllowanceOrChargeAmount></AllowanceOrChargeAmount>
<DueDate></DueDate>
<VAT>
<VATS>
<Percentage></Percentage>
<Type></Type>
<BaseAmount></BaseAmount>
<VATAmount></VATAmount>
</VATS>
</VAT>
</Totals>
</HeaderInformation>
</Interchange>
</SALESINVOICE>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" standalone="yes" indent="yes"/>
<xsl:key name="header_text" match="HeaderText" use="Text"/>
<xsl:key name="line_text" match="LineText" use="Text"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="HeaderInformation">
<HeaderInformation>
<xsl:copy-of select="HeaderText[1]/preceding-sibling::*"/>
<xsl:for-each select="HeaderText[generate-id() =
generate-id(key('header_text', Text)[1])]">
<xsl:variable name="akt_key" select="Text"/>
<xsl:variable name="akt_group" select="key('header_text', $akt_key)"/>
<xsl:for-each select="$akt_group">
<xsl:if test="position() = 1">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<xsl:apply-templates select="LineItem"/>
</HeaderInformation>
</xsl:template>
<xsl:template match="LineItem">
<LineItem>
<Lines>
<xsl:copy-of select="Lines/LineText[1]/preceding-sibling::*"/>
<xsl:for-each select="Lines/LineText[generate-id() =
generate-id(key('line_text', Text)[1])]">
<xsl:variable name="akt_key" select="Text"/>
<xsl:variable name="akt_group" select="key('line_text', $akt_key)"/>
<xsl:for-each select="$akt_group">
<xsl:if test="position() = 1">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</Lines>
</LineItem>
</xsl:template>
</xsl:stylesheet>
LG Julian