Hallo liebe Helfer,
ich habe max. 10 XML-Dateien, die alle im Aufbau identisch sind, sich allerdings in der Anzahl ihrer Einträge unterscheiden. Hier mal exemplarisch drei Dateien:
Datei1: 0.xml
Datei2: 1.xml
Datei3: 2.xml
Beim Öffnen der ersten Datei (0.xml) mittels Browser hätte ich gerne folgendes Ergebnis:
Pro Datei also eine Spalte und die Zuordnung in den Zeilen entsprechend der Angaben im Attribut lfd-Nr.
Wie kann das per xsl umgesetzt werden? Hier mein Denkansatz:
Datei: Start0.xsl
Wäre schön, wenn das machbar wäre. Im Voraus vielen Dank
Gruß MaxW
ich habe max. 10 XML-Dateien, die alle im Aufbau identisch sind, sich allerdings in der Anzahl ihrer Einträge unterscheiden. Hier mal exemplarisch drei Dateien:
Datei1: 0.xml
Code:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="Start0.xsl"?> <Root> <Item lfd-Nr="1" GebSt="0"> <AGS>112000</AGS> <Name>erter Text</Name> </Item> <Item lfd-Nr="2" GebSt="0"> <AGS>133112</AGS> <Name>zweiter Text</Name> </Item> <Item lfd-Nr="3" GebSt="0"> <AGS>433131</AGS> <Name>dritter Text</Name> </Item> <Item lfd-Nr="4" GebSt="0"> <AGS>133120</AGS> <Name>vierter Text</Name> </Item> </Root>
Code:
<?xml version="1.0"?> <Root> <Item lfd-Nr="1" GebSt="0"> <AGS>112000</AGS> <Name>erster Text</Name> </Item> <Item lfd-Nr="2" GebSt="0"> <AGS>133112</AGS> <Name>zweiter Text</Name> </Item> <Item lfd-Nr="3" GebSt="0"> <AGS>433131</AGS> <Name>dritter Text</Name> </Item> <Item lfd-Nr="4" GebSt="0"> <AGS>133120</AGS> <Name>vierter Text</Name> </Item> </Root>
Code:
<?xml version="1.0"?> <Root> <Item lfd-Nr="1" GebSt="0"> <AGS>111000</AGS> <Name>erster geänderter Text</Name> </Item> <Item lfd-Nr="2" GebSt="2"> <AGS>133112</AGS> <Name>zweiter Text</Name> </Item> </Root>
HTML Code:
<html> <body> <table border="1" bordercolor="green"> <tr> <td>112000</td> <td>112000</td> <td>111000</td> </tr> <tr> <td>133112</td> <td>133112</td> <td>133112</td> </tr> <tr> <td>433131</td> <td>433131</td> <td></td> </tr> <tr> <td>133120</td> <td>133120</td> <td></td> </tr> </table> </body> </html>
Wie kann das per xsl umgesetzt werden? Hier mein Denkansatz:
Datei: Start0.xsl
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:variable name="File1" select="document('1.xml')" /> <xsl:variable name="File2" select="document('2.xml')" /> <xsl:template match="/"> <html> <body> <xsl:apply-imports /> </body> </html> </xsl:template> <xsl:template match="Root"> <table border="1" bordercolor="green"> <xsl:for-each select="Item"> <tr> <td> <xsl:value-of select="AGS" /></td> <!-- Item @lfd-Nr = @lfd-Nr der anderen Dateien... --> <td> <xsl:value-of select="$File1/Root/Item/AGS" /></td> <td> <xsl:value-of select="$File2/Root/Item/AGS" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet>
Gruß MaxW
Comment