XML mit Substrukturen Import xslt-Filter

Antwort erstellen


BBCode ist eingeschaltet
[img] ist ausgeschaltet
[url] ist eingeschaltet
Smileys sind ausgeschaltet

Die letzten Beiträge des Themas
   

Ansicht erweitern Die letzten Beiträge des Themas: XML mit Substrukturen Import xslt-Filter

Re: XML mit Substrukturen Import xslt-Filter

von Axel Richter » Sa, 19.02.2011 17:37

Hallo Raphi,

Code: Alles auswählen

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" office:version="1.2" grddl:transformation="http://docs.oasis-open.org/office/1.2/xslt/odf2rdf.xsl">

   <office:body>
    <office:spreadsheet>
     <table:table table:name="dictionary">

      <table:table-row>
       <table:table-cell><text:p>id</text:p></table:table-cell>
       <table:table-cell><text:p>title</text:p></table:table-cell>
       <table:table-cell><text:p>description</text:p></table:table-cell>
       <table:table-cell><text:p>description/title</text:p></table:table-cell>
      </table:table-row>

      <xsl:for-each select="dictionary/item">
       <table:table-row>

        <table:table-cell>
         <text:p><xsl:value-of select="@id" /></text:p>
        </table:table-cell>

        <table:table-cell>
         <text:p><xsl:value-of select="title"/></text:p>
        </table:table-cell>

        <table:table-cell>
         <text:p><xsl:value-of select="description"/></text:p>
        </table:table-cell>

        <table:table-cell>
           <text:p>
            <xsl:for-each select="description/title">
             <xsl:value-of select="."/>
             <xsl:if test="position()!=last()"><xsl:text>&#x0D;&#x0A;</xsl:text></xsl:if>
            </xsl:for-each>
           </text:p>
        </table:table-cell>


       </table:table-row>
      </xsl:for-each>
     </table:table>
    </office:spreadsheet>
   </office:body>

</office:document-content>
</xsl:template>
</xsl:stylesheet>
Schau hier Mal rein, wenn Du Dich mit XSLT beschäftigen musst: http://de.selfhtml.org/xml/darstellung/ ... dlagen.htm.

viele Grüße

Axel

XML mit Substrukturen Import xslt-Filter

von ich_bins_raphi » Do, 17.02.2011 02:05

Hallo,

nach vielem rumgesuche und Probieren bin ich leider immer noch nicht zu meinem erhoften Ergebnis gekommen.
Ich habe diverse XML-Dateien, welche ich als simple Tabele in OO Calc importieren moechte und von dort aus mit Base eine Datenbank erstellen moechte. Hier einen Ausschnitt der XML:

Code: Alles auswählen

<?xml version="1.0" encoding="windows-1252"?>
<dictionary type="x-strong" refbible="any" revision="3" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:noNamespaceSchemaLocation="zefDic1.xsd" dicversion="1.0.0.10">	
	<item id="G1">
		<title>&#913; {A}</title>
		<description>Vorkommen: 3; Stellen: 3; Übersetzungen: 1</description>
		<description>
			<title>Alpha (3x in 3 Stellen)</title>
			<reflink mscope="66;1;8" />; <reflink mscope="66;21;6" />; <reflink mscope="66;22;13" />
		</description>
	</item>
	<item id="G2">
		<title>&#913;&#787;&#945;&#961;&#969;&#769;&#957; {Aar&#333;n}</title>
		<description>Vorkommen: 5; Stellen: 5; Übersetzungen: 2</description>
		<description>
			<title>Aarons (3x in 3 Stellen)</title>
			<reflink mscope="42;1;5" />; <reflink mscope="58;7;11" />; <reflink mscope="58;9;4" />
		</description>
		<description>
			<title>Aaron (2x in 2 Stellen)</title>
			<reflink mscope="44;7;40" />; <reflink mscope="58;5;4" />
		</description>
	</item>
</dictionary>
Mein bisheriger Filteransatz, der leider so nicht funkioneren kann:

Code: Alles auswählen

<?xml version="1.0" encoding="UTF-8"?> 
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
  <xsl:template match="/"> 
   <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 

xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 

xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 

xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" 

xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 

xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-

compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 

xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" 

xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 

xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" 

xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" 

xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0"> 
    <office:body> 
     <office:spreadsheet> 
      <table:table> 
       <table:table-row> 
        <table:table-cell><text:p>item</text:p></table:table-cell> 
        <table:table-cell><text:p>title</text:p></table:table-cell> 
        <table:table-cell><text:p>description</text:p></table:table-cell> 
        <table:table-cell><text:p>description/title</text:p></table:table-cell> 
       </table:table-row> 
      <xsl:for-each select="mp3tag/file"> 
       <table:table-row> 
        <table:table-cell><text:p><xsl:value-of select="item"/></text:p></table:table-cell> 
         <table:table-cell><text:p><xsl:value-of select="title"/></text:p></table:table-cell> 
         <table:table-cell><text:p><xsl:value-of select="description"/></text:p></table:table-cell> 
         <table:table-cell><text:p><xsl:value-of select="description/title"/></text:p></table:table-cell> 
        </table:table-row> 
       </xsl:for-each> 
      </table:table> 
     </office:spreadsheet> 
    </office:body> 
   </office:document-content> 
  </xsl:template> 
 </xsl:stylesheet>
Nun zu dem was ich eigentlich erreichen will:
Eine simple Tabelle mit:
id(G1) | title(&#913; {A}) | description(Vorkommen: 3; Stellen: 3; Übersetzungen: 1) | description/title(Alpha (3x in 3 Stellen))

Ich hoffe es ist verstaendlich ausgedrueckt und nicht zu viel Aufwand. Am besten sollte, wenn moeglich noch eine weitere Aufsplittung stattfinden (zum Beispiel der Description)

Vielen Dank bereits im Vorraus!
Raphi

Nach oben