Joy: Tabellenattribute auslesen

Beitrag lesen

Hi,

also mein XML sieht ungefähr so aus:

--------------XML File -------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<data xmlns:deltaxml="http://www.deltaxml.com/ns/well-formed-delta-v1" xmlns:html="http://www.w3.org/TR/xhtml1/strict" xmlns:xhtml="http://www.w3.org/1999/xhtml" >
<meineForm>
<meineTabelle>
<div xmlns="http://www.w3.org/1999/xhtml">
 <xhtml:div >
 <xhtml:table class="dataTableStyle msoUcTable" style="TABLE-LAYOUT: fixed; WIDTH: 895px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none" tabIndex="-1" borderColor="#c0c0c0" cellPadding="0" width="100%" border="1">
  xhtml:tbody
  xhtml:tr
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">xhtml:div </xhtml:div></xhtml:td>
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">xhtml:div<xhtml:span nowrap="1"/> </xhtml:div></xhtml:td>
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">xhtml:divxhtml:strongZeile 1Spalte3</xhtml:strong>
</xhtml:div></xhtml:td>
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">xhtml:div </xhtml:div></xhtml:td>
  </xhtml:tr>
  xhtml:tr
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">xhtml:divxhtml:strongZeile2Spalte1</xhtml:strong>
</xhtml:div></xhtml:td>
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">xhtml:div<xhtml:span nowrap="1"/> </xhtml:div></xhtml:td>
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">xhtml:divxhtml:strongZeil2Spalte3</xhtml:strong>
</xhtml:div></xhtml:td>
   <xhtml:td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">xhtml:div </xhtml:div></xhtml:td>
  </xhtml:tr>
  </xhtml:tbody>
 </xhtml:table>
</xhtml:div>xhtml:div
 <xhtml:table class="msoUcTable" style="TABLE-LAYOUT: fixed; WIDTH: 896px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none" tabIndex="-1" cellPadding="0" width="100%" border="1">
  xhtml:tbody
   xhtml:tr
    <xhtml:td style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none">
     xhtml:div
      <xhtml:table class="msoUcTable" style="TABLE-LAYOUT: fixed; WIDTH: 894px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none" tabIndex="-1" cellPadding="0" width="100%" border="1">
       xhtml:tbody
        xhtml:tr
         <xhtml:td bgColor="#006400"><xhtml:font color="#ffffff">xhtml:strongneue TabelleZeile1Spalte1</xhtml:strong></xhtml:font></xhtml:td>
         <xhtml:td bgColor="#006400"><xhtml:font color="#ffffff">xhtml:strongneue Tabelle Zeile1Spalte2</xhtml:strong></xhtml:font></xhtml:td>
        </xhtml:tr>
       </xhtml:tbody>
      </xhtml:table>
     </xhtml:div>
    </xhtml:td>
   </xhtml:tr>
  </xhtml:tbody>
 </xhtml:table>
</xhtml:div>
</meineTabelle>
<meineListe>Hier kommt eine Liste
<xhtml:div xmlns="http://www.w3.org/1999/xhtml">xhtml:ulxhtml:liText</xhtml:li><xhtml:li >Text2 xhtml:br/ aber</xhtml:li><xhtml:li >Text3</xhtml:li></xhtml:ul></xhtml:div></meineListe>
</meineForm>
</data>

mein xsl sieht nun so aus:
----------------------XSL File--------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" >

<xsl:template match="data">
    <html>
      <head>
       <title />
      </head>
      <body>
       xsl:copy
     <xsl:copy-of select="@*" />
        <xsl:apply-templates />
       </xsl:copy>
     </body>
    </html>
  </xsl:template>
  <xsl:template match="xhtml:div">
   <div>
     <xsl:apply-templates />
    </div>
   </xsl:template>
  <xsl:template match="xhtml:div[xhtml:table]">
   <xsl:apply-templates />
  </xsl:template>
  <xsl:template match="xhtml:table | xhtml:table//*[(namespace-uri(.) = 'http://www.w3.org/1999/xhtml') and (not(local-name(.) = 'div'))]">
    <xsl:element name="{local-name(.)}">
      <xsl:for-each select="@*">
       <xsl:attribute name="{local-name(.)}">
         <xsl:value-of select="." />
       </xsl:attribute>
      </xsl:for-each>
      <xsl:apply-templates />
    </xsl:element>
  </xsl:template>
</xsl:transform>

und als Ausgabe bekomme ich das:
-------------------HTML AUSGABE------------------------------------
<html xmlns:xhtml="http://www.w3.org/1999/xhtml">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<data xmlns:deltaxml="http://www.deltaxml.com/ns/well-formed-delta-v1" deltaxml:delta="WFmodify" xml:lang="en-us">
 <table class="dataTableStyle msoUcTable" style="TABLE-LAYOUT: fixed; WIDTH: 895px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none" tabIndex="-1" borderColor="#c0c0c0" cellPadding="0" width="100%" border="1">
<tbody>
<tr>
<td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">
<div> </div>
</td>
<td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">
<div><span nowrap="1"></span></div>
</td>
<td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">
<div><strong>Zeile1Spalte3</strong></div>
</td>
<td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">
<div> </div>
</td>
</tr>
<tr>
<td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">
<div><strong>Zeile2Spalte1</strong></div>
</td>
<td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">
<div><span nowrap="1"></span></div>
</td>
<td style="FONT-SIZE: 11px" class="readonlyGroupDataStyle">
<div><strong>Zeile2Spalte3</strong></div>
</td>
<td style="FONT-SIZE: 11px" class="readonlyGroupLabelStyle">
<div> </div>
</td>
</tr>
</tbody>
</table>
<table class="msoUcTable" style="TABLE-LAYOUT: fixed; WIDTH: 896px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none" tabIndex="-1" cellPadding="0" width="100%" border="1">
<tbody>
<tr>
<td style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none">
<table class="msoUcTable" style="TABLE-LAYOUT: fixed; WIDTH: 894px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none" tabIndex="-1" cellPadding="0" width="100%" border="1">
<tbody>
<tr>
<td bgColor="#006400"><font color="#ffffff"><strong>neueTabelleZeile1Spalte1</strong></font></td>
<td bgColor="#006400"><font color="#ffffff"><strong>neueTabelleZeile1Spalte2</strong></font></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>

<div> </div>Hier kommt eine Liste
<div>TextText2 &lt;br/&gt; aber &lt;ins&gt;Text3&lt;/ins&gt;  </div>
</data>
</body>
</html>

und wenn ich dann noch mein anderes Stylesheet drüber lege dann
zeigt er nichts mehr an, da keine Strukturelemente mehr enthalten sind.

Gruß
Joy