Ich freue mich, die ContributionFunds-Elemente im ersten LoanDetails-Element anzuzeigen; ContributionFunds und LoanDetails sind wiederholbare Elemente, also habe ich für die Anzeige zwei Vorlagen erstellt;Eliminieren doppeltes Element, wenn die Elemente in XSLT auf der gleichen Ebene sind
Frage: Gibt es eine Möglichkeit, die Informationen nur im gewünschten Pfad auszugeben? Es spielt keine Rolle, ob ich XSLT 1.0 oder 2.0 verwenden werde.
P.S. Die Information aus den Attributen zählt nicht. Probe:
P.P.S. Es scheint, dass alles, was ich brauchte, war, um die Position zu testen,
ich näherte sich das Problem von Anfang an falsch.
<root>
<Data1>
<Data2>
<Data..>
<ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty">
<Information../>
</ContributionFunds>
<ContributionFunds Amount="10000000" Type="Savings">
<Information../>
</ContributionFunds>
<LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO">
<Information../>
</LoanDetails>
<LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO">
<Information../>
<LoanDetails>
<Foo/>
<Foo.../>
</Data..>
</Data2>
</Data1>
</root>
Der Ausgang erhalten, wenn die Vorlage in ContributionFunds LoanDetails Vorlage für die template
<root>
<Data1>
<Data2>
<Data..>
<LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO2">
<ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty">
<Information../>
</ContributionFunds>
<ContributionFunds Amount="10000000" Type="Savings">
<Information../>
</ContributionFunds>
<Information../>
</LoanDetails>
<LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO2">
<ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty">
<Information../>
</ContributionFunds>
<ContributionFunds Amount="10000000" Type="Savings">
<Information../>
</ContributionFunds>
<Information../>
</LoanDetails>
<Foo/>
<Foo.../>
</Data..>
</Data2>
</Data1>
</root>
Die gewünschte Ausgangs
<root>
<Data1>
<Data2>
<Data..>
<LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO2">
<ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty">
<Information../>
</ContributionFunds>
<ContributionFunds Amount="10000000" Type="Savings">
<Information../>
</ContributionFunds>
<Information../>
</LoanDetails>
<LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO">
<Information../>
<LoanDetails>
<Foo/>
<Foo.../>
</Data..>
</Data2>
</Data1>
</root>
Anwendung ich verwendet habe:
<xsl:template match="LoanDetails">
<LoanDetails>
...information
<xsl:apply-templates select="../ContributionFunds"/>
</LoanDetails>
</xsl:template>
<xsl:template ...>
...
<LoanDetailSegment CombinationLoan="{Overview/@CombinationLoan}">
<xsl:apply-templates select="LoanDetails"/>
...<!--other templates-->
</LoanDetailSegment>
...
</Application>
</xsl:template><!--Not the root-->
Das Beispiel verwirrend ist, da es keine Duplikate in der Quelle nicht beseitigen ist. Vermutlich könnte es mehr Elemente als gezeigt geben - wie entscheidet man, welche 'LoanDetails' welche' ContributionFunds' bekommen? –
Es entscheidet nicht und deswegen möchte ich alle ContributionFunds auf die ersten LoanDetails ausgeben. – DanielCSD
Woher kommt der "VHLIO2"? Es ist nicht in Ihrer Beispieleingabe XML. –