ERLEDIGT
NEIN
NEIN
ANTWORTEN
4
4
ZUGRIFFE
752
752
EMPFEHLEN
-
Hallo zusammen!
Ich habe Folgendes Problem:
Ich muss eine XML Datei, bei der ich nicht weiss, wieviele Cellen mit verscheidenen Attributen es gibt in ein Wordformat (WordProcessingML) umwandeln.
Das klappt auch soweit:
XML-Datei:
Code xml:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <Table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.phnxsoft.com/Infoware/Protocol Protocol.xsd"> <Data> <Cell attribute="VEUROPA"> <CellValue/> </Cell> <Cell attribute="VEU"> <CellValue/> </Cell> <Cell attribute="CR_DATE"> <CellValue>2001-03-07 22:26:43.0</CellValue> </Cell> </Data> <Data> <Cell attribute="VEUROPA"> <CellValue/> </Cell> <Cell attribute="VEU"> <CellValue/> </Cell> <Cell attribute="CR_DATE"> <CellValue>2001-03-07 22:26:47.0</CellValue> </Cell> </Data> <Data> <Cell attribute="VEUROPA"> <CellValue/> </Cell> <Cell attribute="VEU"> <CellValue/> </Cell> <Cell attribute="CR_DATE"> <CellValue>2001-03-07 22:26:47.0</CellValue> </Cell> </Data> </Table>
XSLT:
Code xml:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <xsl:processing-instruction name="mso-application"> <xsl:text>progid="Word.Document"</xsl:text> </xsl:processing-instruction> <w:wordDocument> <w:body> <w:tbl> <w:tblPr> <w:tblStyle w:val="TableGrid"/> <w:tblW w:w="0" w:type="auto"/> <w:tblLook w:val="01E0"/> </w:tblPr> <w:tblGrid> <w:gridCol w:w="3070"/> <w:gridCol w:w="3071"/> <w:gridCol w:w="3071"/> </w:tblGrid> <xsl:apply-templates select="Table/Data" /> </w:tbl> </w:body> </w:wordDocument> </xsl:template> <xsl:template match="Data"> <w:tr> <xsl:apply-templates select="Cell" /> </w:tr> </xsl:template> <xsl:template match="Cell"> <w:tc> <w:p> <w:r> <w:t> <xsl:apply-templates select="CellValue" /> </w:t> </w:r> </w:p> </w:tc> </xsl:template> </xsl:stylesheet>
Ergebnis:
Code xml:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"> <w:body> <w:tbl> <w:tblPr> <w:tblStyle w:val="TableGrid"/> <w:tblW w:w="0" w:type="auto"/> <w:tblLook w:val="01E0"/> </w:tblPr> <w:tblGrid> <w:gridCol w:w="3070"/> <w:gridCol w:w="3071"/> <w:gridCol w:w="3071"/> </w:tblGrid> <w:tr> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>2001-03-07 22:26:43.0</w:t> </w:r> </w:p> </w:tc> </w:tr> <w:tr> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>2001-03-07 22:26:47.0</w:t> </w:r> </w:p> </w:tc> </w:tr> <w:tr> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>2001-03-07 22:26:47.0</w:t> </w:r> </w:p> </w:tc> </w:tr> </w:tbl> </w:body> </w:wordDocument>
Was mir jetzt noch fehlt ist, dass ich die Attribute auch gerne in einer Zeile hätte! In der ersten quasi! Habt ihr eine Idee wie ich mein XSLT ändern muss um das zu erreichen?
So soll es aussehen:
Code xml:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"> <w:body> <w:tbl> <w:tblPr> <w:tblStyle w:val="TableGrid"/> <w:tblW w:w="0" w:type="auto"/> <w:tblLook w:val="01E0"/> </w:tblPr> <w:tblGrid> <w:gridCol w:w="3070"/> <w:gridCol w:w="3071"/> <w:gridCol w:w="3071"/> </w:tblGrid> *ab hier was ich gern noch hätte ------------------------------------------------------------------------------ <w:tr> <w:tc> <w:p> <w:r> <w:t>VEUROPA<w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>VEU<w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>CR_Date</w:t> </w:r> </w:p> </w:tc> </w:tr> ------------------------------------------------------------------------------ <w:tr> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>2001-03-07 22:26:43.0</w:t> </w:r> </w:p> </w:tc> </w:tr> <w:tr> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>2001-03-07 22:26:47.0</w:t> </w:r> </w:p> </w:tc> </w:tr> <w:tr> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t/> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>2001-03-07 22:26:47.0</w:t> </w:r> </w:p> </w:tc> </w:tr> </w:tbl> </w:body> </w:wordDocument>
-
31.07.09 09:33 #2
- Registriert seit
- Jun 2005
- Beiträge
- 8.169
Hi.
Und wo ist jetzt das Problem?
Attribute kannst du mit @attribute selektieren.
GrußIf at first you don't succeed, try again. Then quit. No use being a damn fool about it.
-
Ja das weiß ich ja,
Nur die Attribute kommen ja jedes mal in dem Tag vor.
Ich will aber jedes Attribut nur genau einmal in der ersten Zeile ausgeben lassen!
Wie würde das denn gehen?
-
Hallo,
kannst du nicht für diese erste Zeile eine for-each-Schleife machen? Die soll ja wohl nur einmal vorkommen, wenn ich das richtig verstanden habe. Alle anderen Zeilen kannst du ja wie bisher mit den Templates erledigen.
-
03.08.09 11:08 #5
- Registriert seit
- Jun 2005
- Beiträge
- 8.169
If at first you don't succeed, try again. Then quit. No use being a damn fool about it.
Ähnliche Themen
-
Sum(attribut) wenn anderes Attribut übereinstimmt
Von Zimmi11 im Forum XML TechnologienAntworten: 2Letzter Beitrag: 28.06.10, 14:11 -
XSLT Tag-Attribut auslesen
Von derdienstag im Forum XML TechnologienAntworten: 1Letzter Beitrag: 08.02.10, 13:39 -
Mehrfachvererbung (mehrere Klassen um ein bestimmtes Attribut erweitern)
Von cocoon im Forum JavaAntworten: 4Letzter Beitrag: 21.07.09, 20:58 -
bestimmtes ParentNode auf bestimmtes ChildNode prüfen
Von Moszeed im Forum Javascript & AjaxAntworten: 6Letzter Beitrag: 22.11.07, 10:06 -
allen <td> tags ein bestimmtes class attribut zuweisen
Von sevi im Forum Javascript & AjaxAntworten: 2Letzter Beitrag: 15.11.03, 19:11





Zitieren

Login





