Hallo,
ich habe da ein Problem, für das mir die Lösung sehr schwer fällt.
Mit dem folgenden XML-Eingabe-Dokument
und dem folgenden Stylesheet
ich habe da ein Problem, für das mir die Lösung sehr schwer fällt.
Mit dem folgenden XML-Eingabe-Dokument
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"> <w:body> <w:p w:rsidR="006216FA" w:rsidRDefault="006216FA" w:rsidP="006216FA"> <w:pPr> <w:pStyle w:val="heading"/> </w:pPr> <w:r> <w:t>Überlastsicherung im Antrieb - Eine sehr lange Überschrift!</w:t> </w:r> </w:p> <w:p w:rsidR="006216FA" w:rsidRDefault="006216FA" w:rsidP="006216FA"> <w:pPr> <w:pStyle w:val="orientation"/> </w:pPr> <w:r> <w:t>Das ist „ein“ Orientierungstext!</w:t> </w:r> </w:p> <w:p w:rsidR="008E05B6" w:rsidRPr="008E05B6" w:rsidRDefault="008E05B6" w:rsidP="008E05B6"> <w:pPr> <w:pStyle w:val="orientation"/> </w:pPr> <w:r> <w:t>Hier kommt noch ein Orientierungstext.</w:t> </w:r> </w:p> <w:p w:rsidR="006216FA" w:rsidRDefault="006216FA" w:rsidP="006216FA"> <w:pPr> <w:pStyle w:val="descriptivebody"/> </w:pPr> <w:r> <w:t xml:space="preserve">Halten Sie den Antrieb sauber, da er sonst nicht funktionieren kann!!! Drücken Sie den </w:t> </w:r> <w:proofErr w:type="gramStart"/> <w:r> <w:t>Button .</w:t> </w:r> <w:proofErr w:type="gramEnd"/> <w:r> <w:t xml:space="preserve"> Hier kommt eine Variable mit dem Produktnamen: </w:t> </w:r> <w:r w:rsidRPr="00D60787"> <w:rPr> <w:rStyle w:val="emphasis"/> </w:rPr> <w:t>MX500</w:t> </w:r> <w:r> <w:t>. Hier kommt ein Textverweis: siehe Abschnitt 2 auf Seite 4. Das kommende Wort wird nicht übersetzt: Hallo! Hier kommen Technische Daten: 1200 Watt, 12 Volt, 15 Zoll, 19 Meilen. Der folgende Text steht in Ausführungszeichen: „Hallo“.</w:t> </w:r> </w:p> <w:p w:rsidR="006774C5" w:rsidRDefault="006774C5" w:rsidP="006774C5"> <w:pPr> <w:pStyle w:val="heading"/> </w:pPr> <w:r> <w:t>Eine zweite Überschrift</w:t> </w:r> </w:p> <w:p w:rsidR="00005DEC" w:rsidRDefault="00005DEC" w:rsidP="00005DEC"> <w:pPr> <w:pStyle w:val="orientation"/> </w:pPr> <w:r> <w:t>Das ist „ein“ Orientierungstext der zweiten Überschrift!</w:t> </w:r> </w:p> <w:p w:rsidR="00005DEC" w:rsidRDefault="00005DEC" w:rsidP="00005DEC"> <w:pPr> <w:pStyle w:val="descriptivebody"/> </w:pPr> <w:r> <w:t>Hier kommt ein Text-Absatz der zweiten Überschrift.</w:t> </w:r> </w:p> <w:sectPr w:rsidR="00005DEC" w:rsidSect="004B65AA"> <w:pgSz w:w="11906" w:h="16838"/> <w:pgMar w:top="1417" w:right="1417" w:bottom="1134" w:left="1417" w:header="708" w:footer="708" w:gutter="0"/> <w:cols w:space="708"/> <w:docGrid w:linePitch="360"/> </w:sectPr> </w:body> </w:document>
und dem folgenden Stylesheet
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" exclude-result-prefixes="w wp"> <xsl:output method="xml" indent="yes" encoding="utf-8"/> <xsl:template match="/"> <mod> <descriptive prodclass-1="" infoclass-1="" infoclass-2=""> <xsl:apply-templates select="(w:document/w:body/w:p[w:pPr/w:pStyle[@w:val = 'heading']])[1] | (w:document/w:body/w:p[w:pPr/w:pStyle[@w:val = 'orientation']])[1] | (w:document/w:body/w:p[w:pPr/w:pStyle[@w:val = 'descriptivebody']])[1]" /> <xsl:for-each select="(w:document/w:body/w:p[w:pPr/w:pStyle[@w:val = 'heading']])[position() > 1]"> <xsl:variable name="pos" select="position()"/> <descriptive prodclass-1="" infoclass-1="" infoclass-2=""> <xsl:apply-templates select=". | (/w:document/w:body/w:p[w:pPr/w:pStyle[@w:val = 'orientation']])[position() > 1][$pos = position()] | (/w:document/w:body/w:p[w:pPr/w:pStyle[@w:val = 'descriptivebody']])[position() > 1][$pos = position()]" /> </descriptive> </xsl:for-each> </descriptive> </mod> </xsl:template> <xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'heading']]"> <heading nodeid="" translate="yes" valid=""> <xsl:apply-templates select="w:r"/> </heading> </xsl:template> <xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'orientation']]"> <orientation> <paragraph> <xsl:apply-templates select="w:r"/> </paragraph> </orientation> </xsl:template> <xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'descriptivebody']]"> <descriptive_body> <paragraph> <xsl:apply-templates select="w:r"/> </paragraph> </descriptive_body> </xsl:template> <xsl:template match="w:r"> <xsl:apply-templates select="w:t[not(preceding-sibling::w:rPr)]/text() | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'emphasis']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'subscript']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'superscript']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'user-interface']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'variable']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'graphiclink']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'textlink']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'transno']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'siinlinedatanumber']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'usinlinedatanumber']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'quoted']] | w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'keyword']] | w:drawing[preceding-sibling::w:rPr/w:rStyle[@w:val = 'inlinegraphic']]"/> </xsl:template> <!-- Match-Templates --> <xsl:template match="w:t[not(preceding-sibling::w:rPr)]/text()"> <xsl:value-of select="." /> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'emphasis']]"> <emphasis><xsl:value-of select="." /></emphasis> </xsl:template> <xsl:template match="w:drawing[preceding-sibling::w:rPr/w:rStyle[@w:val = 'inlinegraphic']]"> <inlinegraphic><xsl:attribute name="graphicname"><xsl:value-of select="wp:inline/wp:docPr/@descr"/></xsl:attribute></inlinegraphic> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'subscript']]"> <subscript><xsl:value-of select="." /></subscript> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'superscript']]"> <superscript><xsl:value-of select="." /></superscript> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'user-interface']]"> <user-interface type="hardware"><xsl:value-of select="." /></user-interface> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'variable']]"> <variable name="Variable"><xsl:value-of select="."/></variable> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'graphiclink']]"> <graphiclink graphicname=""><xsl:value-of select="."/></graphiclink> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'textlink']]"> <textlink><xsl:value-of select="."/></textlink> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'transno']]"> <transno><xsl:value-of select="."/></transno> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'siinlinedatanumber']]"> <inlinedata> <si-value> <number><xsl:value-of select="."/></number> <unit><xsl:value-of select="following::w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'siinlinedataunit']]"/></unit> </si-value> </inlinedata> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'usinlinedatanumber']]"> <inlinedata> <us-value> <number><xsl:value-of select="."/></number> <unit><xsl:value-of select="following::w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'usinlinedataunit']]"/></unit> </us-value> </inlinedata> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'quoted']]"> <quoted><xsl:value-of select="."/></quoted> </xsl:template> <xsl:template match="w:t[preceding-sibling::w:rPr/w:rStyle[@w:val = 'keyword']]"> <keyword> <key-entry> <xsl:value-of select="."/> </key-entry> </keyword> </xsl:template> </xsl:stylesheet>
Comment