Birgit: Tabellen in XSL

Hallo zusammen,

nachdem ich letzte Woche so nette und kompetente Hilfe bei meinem Problem bekommen habe, versuche ich es jetzt einfach nochmal (habe wirklich schon alles ausprobiert, aber ich bekomme es nicht hin)! Es geht auch immer noch um die gleiche XML-Datei. Ich versuche mal, es zu erklären:

Hier zunächst wieder der entsprechende Ausschnitt aus der XML-Datei (Codebuch):
.
.
.
<dataDscr>
  <var name="V38">
   <location StartPos="124" width="1"/>
   <labl>Q3 POL DISCUSSION - CONVINCE FRIENDS</labl>
   <qstn ID="Q.3">
    <qstnLit>When you hold a strong opinion, do you ever find yourself persuading your friends, relatives or fellow workers to share your views? Does this happen ...? (READ OUT)</qstnLit>
    <backward>Last trend: EB47.0  Q.3</backward>
   </qstn>
   <catgry>
    <catValu>1</catValu>
    <txt>Often</txt>
   </catgry>
   <catgry>
    <catValu>2</catValu>
    <txt>From time to time</txt>
   </catgry>
   <catgry>
    <catValu>3</catValu>
    <txt>Rarely</txt>
   </catgry>
   <catgry>
    <catValu>4</catValu>
    <txt>Never</txt>
   </catgry>
   <catgry missing="Y">
    <catValu>5</catValu>
    <txt>DK</txt>
   </catgry>
   <catgry missing="Y">
    <catValu>0</catValu>
    <txt>NA</txt>
   </catgry>
   <catgry>
    <catStat>
     <table>
      <tgroup cols="11">
       <colspec colnum="1" colname="Value"/>
       <colspec colnum="2" colname="F"/>
       <colspec colnum="3" colname="B"/>
       <colspec colnum="4" colname="NL"/>
       <colspec colnum="5" colname="D-W"/>
       <colspec colnum="6" colname="I"/>
       <colspec colnum="7" colname="L"/>
       <colspec colnum="8" colname="DK"/>
       <colspec colnum="9" colname="IRL"/>
       <colspec colnum="10" colname="GB"/>
       <colspec colnum="11" colname="NIRL"/>
       <thead>
        <row>
         <entry colname="Value"/>
         <entry colname="F">F</entry>
         <entry colname="B">B</entry>
         <entry colname="NL">NL</entry>
         <entry colname="D-W">D-W</entry>
         <entry colname="I">I</entry>
         <entry colname="L">L</entry>
         <entry colname="DK">DK</entry>
         <entry colname="IRL">IRL</entry>
         <entry colname="GB">GB</entry>
         <entry colname="NIRL">NIRL</entry>
        </row>
       </thead>
       <tbody>
        <row>
         <entry colname="Value">1</entry>
.
.
.

Und hier die dazugehörende XSL-Datei:
.
.
.
<xsl:template match="dataDscr/var">
   <p><u><b><xsl:value-of select="@name" /></b></u></p>
   <p>Location: <i><xsl:value-of select="location/@StartPos" /></i></p>
   <p>Width: <i><xsl:value-of select="location/@width" /></i></p>
   <p>Variable Group Label: <i><xsl:value-of select="labl" /></i></p>
   <p>Literal Question: <i><xsl:value-of select="qstn/qstnLit" /></i></p>
   <p>Backflow: <i><xsl:value-of select="qstn/backward" /></i></p>
<xsl:if test="@name='V38'">
   <xsl:for-each select="catgry">
      <i><xsl:value-of select="concat(catValu, '   ', txt)" /></i><br />
   </xsl:for-each>
   <xsl:apply-templates />
</xsl:if>
.
.
.
<xsl:template match="row">
<table border="1">
<colgroup width="50" span="11">
     </colgroup>
    <tr>
      xsl:apply-templates/
    </tr>
 </table>
</xsl:template>

<xsl:template match="entry">
  <td><b><xsl:value-of select="."/></b></td>
</xsl:template>
</xsl:stylesheet>

Heraus kommt folgendes Ergebnis:

1 Often
2 From time to time
3 Rarely
4 Never
5 DK
0 NA

Q3 POL DISCUSSION - CONVINCE FRIENDSWhen you hold a strong opinion, do you ever find yourself persuading your friends, relatives or fellow workers to share your views? Does this happen ...? (READ OUT)Last trend: EB47.0 Q.31Often2From time to time3Rarely4Never5DK0NA
F B NL D-W I L DK IRL GB NIRL
1 115 102 179 85 126 107 184 89 83 14
% 11.6 10.3 17.8 8.4 12.8 18.3 18.5 9.1 7.7 4.7
2 376 401 550 401 401 289 336 359 330 75
% 37.9 40.3 54.7 39.6 40.7 49.3 33.8 36.5 30.7 25.3
3 242 274 184 363 263 104 241 270 250 83
% 24.4 27.5 18.3 35.8 26.7 17.7 24.2 27.5 23.3 27.9
4 259 218 92 164 195 86 234 265 411 125
% 26.1 21.9 9.2 16.2 19.8 14.7 23.5 27.0 38.3 42.1
5 14M 10M 15M 20M 12M 11M 6M 20M 4M 4M

0    5M

Sum 1006 1005 1020 1038 997 597 1001 1003 1078 301
 GR E P D-E FIN S A
1 106 176 175 82 94 140 119
% 10.5 17.7 17.6 8.2 9.3 14.1 11.6
2 543 401 405 407 291 382 355
% 54.0 40.3 40.7 40.7 28.8 38.5 34.7
3 193 221 176 362 336 274 315
% 19.2 22.2 17.7 36.2 33.3 27.6 30.8
4 164 198 239 149 288 197 234
% 16.3 19.9 24.0 14.9 28.5 19.8 22.9
5 4M 4M 5M 28M 2M 7M 33M

0    3M

Sum 1010 1000 1000 1031 1011 1000 1056

Wie schaffe ich es jetzt, den Text vor der Tabelle (beginnt mit "Q3 POL DISCUSSION..." und endet mit "...1Often2From time to time3Rarely4Never5DK0NA") wegzubekommen und nur die Auflistung der Antworten (1 Often, 2 From time to time etc.) und dann die Tabellen anzuzeigen? War das verständlich erklärt? Ich hoffe auf eine Lösung!

Danke schonmal!
Birgit

  1. Hallo Birgit.
    Wie letzte Woche auch, steh ich mal wieder auf dem Schlauch...
    Was hälst Du davon, wenn mal Dein erwünschtes Ergebnis als reines HTML mit <table> usw. erstellst, so ganz ohne XML/XSL und im www ablegst.
    Derweil ich kapier immer nicht so richtg, wie das bei Dir aussehen soll. Irgendwie xtrem kompliziert.

    bydey

    Ich schau es mir aber frühestens morgen an.

  2. Hallo Brigit,

    Wie schaffe ich es jetzt, den Text vor der Tabelle (beginnt mit "Q3 POL DISCUSSION..." und endet mit "...1Often2From time to time3Rarely4Never5DK0NA") wegzubekommen und nur die Auflistung der Antworten (1 Often, 2 From time to time etc.) und dann die Tabellen anzuzeigen? War das verständlich erklärt? Ich hoffe auf eine Lösung!

    du bekommt alle texte ausgegeben, das ist das normale verhalten des parsers.
    erstelle einen leeren template in irgenbdwo in deinem sheet:

    <xsl:template match="text()"></xsl:template>

    das sollte die textausgabe unterdrücken.

    grüße
    thomas

    1. Hallo Thomas,

      ich danke Dir für Deine Hilfe - genau das war es! Jetzt bin ich endlich fertig mit diesem Codebuch!

      Bis demnächst (wenn ich wieder neue Fragen habe...)
      Birgit

      Hallo Brigit,

      Wie schaffe ich es jetzt, den Text vor der Tabelle (beginnt mit "Q3 POL DISCUSSION..." und endet mit "...1Often2From time to time3Rarely4Never5DK0NA") wegzubekommen und nur die Auflistung der Antworten (1 Often, 2 From time to time etc.) und dann die Tabellen anzuzeigen? War das verständlich erklärt? Ich hoffe auf eine Lösung!

      du bekommt alle texte ausgegeben, das ist das normale verhalten des parsers.
      erstelle einen leeren template in irgenbdwo in deinem sheet:

      <xsl:template match="text()"></xsl:template>

      das sollte die textausgabe unterdrücken.

      grüße
      thomas