Markus B.: Variabeln zusammenfassen, --> Unexpected tocken....

Beitrag lesen

Ich sehe keine Abfrage/Verwendung von $countInt im Template, also kann ich dazu nichts sagen.

Im untern code so geändert wie icc es dachte

Wenn du nicht willst, dass das Template für alle Intervalle gilt, sage es doch dem Template: entweder durch: <xsl:template match="/Intervall[1]"> oder besser durch: <xsl:apply-templates select="Intervall[1]" />

Also es soll für alle INtervalle gültig sein, heisst: Nachdem er jeden value durchgegangen ist hört auf. Mit deinem Vorschlag, geschieht zwar das es nur einmal alle durchgeht heist: 14 Intervall dann 13 Intervalle dann 12 Intervalle dann 11Intervall

Ohne diese [1]  passiert dies

44Intervalle 34 Intervalle usw.

Ich will jedeoch, dass er einmal alle 4(zurzeit) Intervalle druchgeht.

Die derzeitige Ausgabe ist diese hier:

   <line x1="5.625%" y1="69.23076923076923%" x2="11.25%" y2="84.61538461538461%"/>
   <line x1="11.25%" y1="84.61538461538461%" x2="16.875%" y2="61.53846153846153%"/>
   <line x1="16.875%" y1="61.53846153846153%" x2="22.5%" y2="57.69230769230769%"/>
   <line x1="22.5%" y1="57.69230769230769%" x2="28.125%" y2="53.84615384615385%"/>
   <line x1="28.125%" y1="53.84615384615385%" x2="33.75%" y2="50%"/>
   <line x1="33.75%" y1="50%" x2="39.375%" y2="46.15384615384615%"/>
   <line x1="39.375%" y1="46.15384615384615%" x2="45%" y2="42.30769230769231%"/>
   <line x1="45%" y1="42.30769230769231%" x2="50.625%" y2="38.46153846153846%"/>
   <line x1="50.625%" y1="38.46153846153846%" x2="56.25%" y2="30.76923076923076%"/>
   <line x1="56.25%" y1="30.76923076923076%" x2="61.875%" y2="30.76923076923076%"/>
   <line x1="61.875%" y1="30.76923076923076%" x2="67.5%" y2="26.92307692307692%"/>
   <line x1="67.5%" y1="26.92307692307692%" x2="73.125%" y2="23.076923076923066%"/>
   <line x1="73.125%" y1="23.076923076923066%" x2="78.75%" y2="19.230769230769226%"/>
   <line x1="78.75%" y1="19.230769230769226%" x2="84.375%" y2="15.384615384615387%"/>
   <line x1="84.375%" y1="15.384615384615387%" x2="90%" y2="30.76923076923076%"/>


<-- Hier soll eig Ende sein -->

   <line x1="5.625%" y1="84.61538461538461%" x2="11.25%" y2="61.53846153846153%"/>
   <line x1="11.25%" y1="61.53846153846153%" x2="16.875%" y2="57.69230769230769%"/>
   <line x1="16.875%" y1="57.69230769230769%" x2="22.5%" y2="53.84615384615385%"/>
   <line x1="22.5%" y1="53.84615384615385%" x2="28.125%" y2="50%"/>
   <line x1="28.125%" y1="50%" x2="33.75%" y2="46.15384615384615%"/>
   <line x1="33.75%" y1="46.15384615384615%" x2="39.375%" y2="42.30769230769231%"/>
...
...
...
   

Jetzt zum 1ten Punkt: (erst der relevante teil und dann später kommt der ganze code)

   <xsl:template match="/data/Intervall/value" name="Temp1">
        <xsl:param name="add" select="$add.GRAPH"/>
        <xsl:param name="knoten" select="."/>
        <xsl:param name="countInt" select="$CountforInt"/>
        <xsl:for-each select="$knoten/descendant-or-self::value">
            <xsl:choose>
                <xsl:when test="following-sibling::value[position() = 1]">
                    <g class="Lines1">
                        <line x1="{$add}%" y1="{100-(((.) - $MinV)*(100 div ($MaxV - $MinV)))}%"
                            x2="{$add+$add.GRAPH}%"
                            y2="{100-(((following-sibling::value[position() = 1]) - $MinV)*(100 div ($MaxV - $MinV)))}%"
                        />
                    </g>
                   <-- <xsl:if test="$countInt &lt; $Length"> -->
                        <xsl:call-template name="Temp1">
                            <xsl:with-param name="countInt" select="$countInt+$CountforInt"/>
                            <xsl:with-param name="add" select="$add+$add.GRAPH"/>
                            <xsl:with-param name="knoten"
                                select="following-sibling::value[position() = 1]"/>
                       <-- </xsl:call-template> -->
                    </xsl:if>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if
                        test="parent::Intervall/following-sibling::Intervall[position() = 1]/value[position() = 1]">
                        <g class="Lines1">
                            <line x1="{$add}%" y1="{100-(((.) - $MinV)*(100 div $Delta))}%"
                                x2="{$add+$add.GRAPH}%"
                                y2="{100-(((parent::Intervall/following-sibling::Intervall[position() = 1]/value[position() = 1]) - $MinV)*(100 div ($MaxV - $MinV)))}%"
                            />
                        </g>
                   </xsl:if>
                    <-- <xsl:if test="$countInt &lt; $Length"> -->
                        <xsl:call-template name="Temp1">
                            <xsl:with-param name="countInt" select="$countInt+$CountforInt"/>
                            <xsl:with-param name="add" select="$add+$add.GRAPH"/>
                            <xsl:with-param name="knoten"
                                select="parent::Intervall/following-sibling::Intervall[position() = 1]/value[position() = 1]"
                            />
                        </xsl:call-template>
                  <--  </xsl:if> -->
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>

So hatte ich mir das gedacht.

eine Lösung die halbwegs funktioniert ist, wenn ihc die position abfrage und wenn er dann bei 1ten duch ist wird ja position 2 und dann hört er auf.

also:

 <xsl:param name="test" select="position()"/>
        <xsl:if test="$test &lt; 2">
            <xsl:for-each select="$knoten/descendant-or-self::value">

und halt am ende

</xsl:if>

jedoch ist bei der ausgabe in xml dann dies hier:

g class="Lines1">
      <line x1="84.375%" y1="15.384615384615387%" x2="90%" y2="30.76923076923076%"/>
   </g><-- 120125130135140150150155160165170150 Das sol da eig. nicht sein --><g class="Num-left">
      <text x="10.625%" y="95%">30.05.2003</text>


Xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns="http://www.w3.org/2000/svg">
    <xsl:output method="xml" omit-xml-declaration="no" indent="yes" version="1.0"
        doctype-system="-//W3C//DTD SVG 1.1//EN"
        doctype-public="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"/>
    <xsl:variable name="Length" select="count(/data/Intervall)"> </xsl:variable>
    <xsl:variable name="Lenghteach" select="count(/data/Intervall/value)"/>
    <xsl:variable name="add.GRAPH" select="(90 div $Length div ($Lenghteach div $Length))"/>
    <xsl:variable name="MaxV">
        <xsl:for-each select=" descendant-or-self::value">
            <xsl:sort data-type="number" order="descending"/>
            <xsl:if test="position()=1">
                <xsl:value-of select="(.)+20"/>
            </xsl:if>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="MinV">
        <xsl:for-each select=" descendant-or-self::value">
            <xsl:sort data-type="number" order="ascending"/>
            <xsl:if test="position()=1">
                <xsl:value-of select="(.)-20"/>
            </xsl:if>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="Delta" select="$MaxV - $MinV"/>
    <xsl:variable name="Linecount">
        <xsl:choose>
            <xsl:when test="$Delta &lt;= 20">
                <xsl:value-of select="5"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="6"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="CountforInt" select="$Length div $Lenghteach"/>
    <xsl:variable name="LgthforIntvll" select="(90 div $Length)"/>
    <xsl:template match="/data">
        <xsl:processing-instruction name="xml-stylesheet">type="text/css"
            href="/Users/Azubi/Desktop/Unbenannt1.css"</xsl:processing-instruction>
        <svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="50%" height="50%">
            <g class="Background-rect">
                <rect width="100%" height="100%"/>
            </g>
            <g class="Num-left">
                <g class="Lines3">
                    <xsl:call-template name="BuildLines"> </xsl:call-template>
                </g>
            </g>
            <g class="Lines2">
                <line x1="5%" y1="90%" x2="95%" y2="90%"/>
            </g>
            <xsl:apply-templates select="Intervall/value"/>
            <xsl:call-template name="Temp2"/>
        </svg>
    </xsl:template>
    <xsl:template name="BuildLines">
        <xsl:param name="counter">0</xsl:param>
        <text x="3%" y="{100-((x - $MinV)*(100 div ($MaxV - $MinV)))}">
            <xsl:value-of select="x"/>
        </text>
        <line x1="5%" y="{100-((x - $MinV)*(100 div ($MaxV - $MinV)))}" x2="95%"
            y2="{100-((x - $MinV)*(100 div ($MaxV - $MinV)))}"/>
        <xsl:if test="$counter &lt; $Linecount">
            <xsl:call-template name="BuildLines">
                <xsl:with-param name="counter" select="$counter+1"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>

<--Hier der Obere Code rein-->

    </xsl:template>
</xsl:stylesheet>