Announcement

Collapse
No announcement yet.

Gezielte Ausgabe übergeordneter Knoten

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gezielte Ausgabe übergeordneter Knoten

    Hallo zusammen,

    ich bin noch Newbie und beisse mir gerade an der folgenden Aufgabenstellung die Zähne aus.
    XML:
    Code:
    <fblist>
        <fb id="sb_gl2_a" unit="1" pin="3" x="5" y="1" z="1" state="false" prev_id="sb_gl2_a" desc="sb_gl2_a" show="true" ori="west" iid="" bus="0" action="false" addr="3"/>
        <fb id="sb_gl1_a" unit="1" pin="1" x="5" y="0" z="1" state="false" prev_id="sb_gl1_a" desc="sb_gl1_a" show="true" ori="west" iid="" bus="0" action="false" addr="1"/>
        <fb id="BW_gl1_m" x="16" y="13" z="1" state="false" prev_id="BW_gl1_m" desc="BW_gl1_m" show="true" ori="west" iid="" bus="0" addr="0" action="true" road="false" blockid="" activelow="false">
          <fbaction type="sw" id="SB_gl4_o" cmd="turnout" activate="true"/>
          <fbaction type="sw" id="SB_gl4_w" cmd="straight" activate="true"/>
        </fb>
    </fblist>
    <bklist>
        <bk id="SB_gl3" x="12" y="2" z="1" state="open" prev_id="SB_gl3" desc="" len="0" electrified="false" station="false" wait="false" gomanual="true" acceptghost="false" terminalstation="false" commuter="no" fba="" fbb="" fbi="" fbr="" fbm="" signal="" wsignal="" speed="cruise" type="none" incline="0" waitmode="random" minwaittime="1" maxwaittime="30" waittime="10" evttimer="0" iid="" addr="0" port="0" td="false" locid="BR55" signalR="" wsignalR="" exitspeed="cruise" ttid="">
          <fbevent id="sb_gl3_m" action="enter" from="w_gl2" endpuls="false"/>
          <fbevent id="sb_gl3_b" action="in" from="w_gl2" endpuls="false"/>
          <fbevent id="w_gl2_m" action="enter" from="SB_gl2" endpuls="false"/>
          <fbevent id="sb_gl3_m" action="enter" from="o_gl2" endpuls="false"/>
          <fbevent id="sb_gl3_a" action="in" from="o_gl2" endpuls="false"/>
        </bk>
    <bklist>
    Nun möchte ich eine Tabelle ausgeben mit der folgenden Struktur:

    fb1->id attr1 fb1->attr2 fb1->attr3
    __ fbaction->attr1 fbaction1->attr2
    __ fbaction->attr1 fbaction1->attr2
    -->bis hier kein Problem
    __bk-->id (where fbevent->id = fb1->id) fbevent->action

    fb2->id attr1 fb2->attr2 fb2->attr3
    __ fbaction->attr1 fbaction->attr2
    __ fbaction->attr1 fbaction->attr2
    __ bk-->id (where fbevent->id = fb2->id) fbevent->action

    Die letzte Information bk->id bekomme ich einfach nicht in die Tabelle.

    Hier mein bisher verwendetes XSL:
    Code:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="UTF-8"/>
    <xsl:template match="/">
    <html>
    <head><title>Feedback</title>
    </head>
    <body>
    <h2>Feedback report</h2>
    
    <table border="1" rules="all" cellpadding="4" cellspacing="0" width="80%">
      <THEAD>
    	<TR>
    	   <TH width="20%" height="30" bgcolor="lightgrey">ID</TH>
     	   <TH width="40%" bgcolor="lightgrey">Description</TH>
     	   <TH width="20%" bgcolor="lightgrey">IID</TH>
     	   <TH width="20%" bgcolor="lightgrey">Address</TH>
    	</TR>
      </THEAD> 
      <TBODY>
       <xsl:apply-templates/>
      </TBODY>
    </table>
    </body>
    </html>
    </xsl:template>
    
    <xsl:template match="fblist">  
      <xsl:apply-templates>
       <xsl:sort select="@addr" order="ascending" data-type="number" />
      </xsl:apply-templates>
    </xsl:template>
    
    
    <xsl:template match="fb">  
    	<TR>	
    	   <TD><xsl:value-of select="@id" /></TD>
    	   <xsl:variable name="desc1" select="@desc" />
           <TD>
    	   <xsl:choose>
             <xsl:when test="$desc1 = ''">
             <xsl:text>-</xsl:text>
           </xsl:when>
           <xsl:otherwise>
             <xsl:value-of select="@desc" />
           </xsl:otherwise>
           </xsl:choose>
    	   </TD>
    	   <xsl:variable name="iid1" select="@iid" />
    	   <TD align="center">
    	   <xsl:choose>
             <xsl:when test="$iid1 = ''">
             <xsl:text>-</xsl:text>
           </xsl:when>
           <xsl:otherwise>
             <xsl:value-of select="@iid" />
           </xsl:otherwise>
           </xsl:choose>
    	   </TD>
    	   <TD align="center"><xsl:value-of select="@addr" /></TD>
    	</TR>	   
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="fbaction">  
    	<TR>	
    	   <TD></TD>
    	   <TD colspan="3">
    			<table border="0" rules="all" cellpadding="4" cellspacing="0" width="100%">
    			<tr>
    			<td><b>Action</b></td>
    			<td><xsl:value-of select="@type" />-&gt;<xsl:value-of select="@id" />-&gt;<xsl:value-of select="@cmd" /></td>  	
    			</tr>
    			</table>
    		</TD>	
    	</TR>	   
        <xsl:apply-templates/>
    </xsl:template>
    
    </xsl:stylesheet>
    Kann mir hier bitte jemand einen Tip geben, wie ich diese fehlende Information ausgeben kann?

    Herzlichen Dank im voraus,
    Dirk

  • #2
    Erläutere mal die gesuchte Bedingung genauer. Entweder hab ich diese nicht verstanden oder sie ist im genannten XML-Dokument nicht erfüllt.

    Ansonsten ist bklist parent bezüglich bk und fblist preceding-sibling von bklist.

    Comment


    • #3
      Hallo Thomas,
      sorry, in dem kopierten Ausschnitt der XML-Datei war die Bedingung nicht erfüllt.
      Hier ein korrekter Ausschnitt:
      Code:
      <fblist>
          <fb id="sb_gl2_a" unit="1" pin="3" x="5" y="1" z="1" state="false" prev_id="sb_gl2_a" desc="sb_gl2_a" show="true" ori="west" iid="" bus="0" action="false" addr="3"/>
          <fb id="sb_gl1_a" unit="1" pin="1" x="5" y="0" z="1" state="false" prev_id="sb_gl1_a" desc="sb_gl1_a" show="true" ori="west" iid="" bus="0" action="false" addr="1"/>
          <fb id="sb_gl1_b" x="24" y="0" z="1" state="false" prev_id="sb_gl1_b" desc="sb_gl1_b" show="true" ori="west" iid="" bus="0" unit="1" pin="14" action="false" addr="14"/>
            <fbaction type="sw" id="SB_gl4_o" cmd="turnout" activate="true"/>
            <fbaction type="sw" id="SB_gl4_w" cmd="straight" activate="true"/>
          </fb>
          <fb id="sb_gl1_m" x="16" y="0" z="1" prev_id="sb_gl1_m" desc="sb_gl1_m" show="true" ori="west" iid="" bus="0" unit="1" pin="8" action="false" state="false" addr="8"/>
          <fb id="sb_gl2_m" x="16" y="1" z="1" prev_id="sb_gl2_m" desc="sb_gl2_m" show="true" ori="west" iid="" bus="0" unit="1" pin="6" action="false" state="false" addr="6"/>
          <fb id="sb_gl3_m" x="16" y="2" z="1" prev_id="sb_gl3_m" desc="" show="true" ori="west" iid="" bus="0" unit="1" pin="4" action="false" state="false" addr="4"/>
      </fblist>
        <bklist>
          <bk id="SB_gl3" x="12" y="2" z="1" state="open" prev_id="SB_gl3" desc="" len="0" electrified="false" station="false" wait="false" gomanual="true" acceptghost="false" terminalstation="false" commuter="no" fba="" fbb="" fbi="" fbr="" fbm="" signal="" wsignal="" speed="cruise" type="none" incline="0" waitmode="random" minwaittime="1" maxwaittime="30" waittime="10" evttimer="0" iid="" addr="0" port="0" td="false" locid="BR55" signalR="" wsignalR="" exitspeed="cruise" ttid="">
            <fbevent id="sb_gl3_m" action="enter" from="w_gl2" endpuls="false"/>
            <fbevent id="sb_gl3_b" action="in" from="w_gl2" endpuls="false"/>
            <fbevent id="w_gl2_m" action="enter" from="SB_gl2" endpuls="false"/>
            <fbevent id="sb_gl3_m" action="enter" from="o_gl2" endpuls="false"/>
            <fbevent id="sb_gl3_a" action="in" from="o_gl2" endpuls="false"/>
          </bk>
          <bk id="SB_gl1" x="12" y="0" z="1" state="open" prev_id="SB_gl1" desc="" len="0" electrified="false" station="false" wait="false" gomanual="true" acceptghost="false" terminalstation="false" commuter="no" fba="" fbb="" fbi="" fbr="" fbm="" signal="" wsignal="" speed="min" type="none" incline="0" waitmode="loc" minwaittime="1" maxwaittime="30" waittime="10" evttimer="0" iid="" addr="0" port="0" td="false" locid="" exitspeed="cruise" ttid="" signalR="" wsignalR="">
            <fbevent id="sb_gl1_m" action="enter" from="w_gl1" endpuls="false"/>
            <fbevent id="sb_gl1_b" action="in" from="w_gl1" endpuls="false"/>
            <fbevent id="sb_gl1_m" action="enter" from="BU_gl4" endpuls="false"/>
            <fbevent id="sb_gl1_a" action="in" from="BU_gl4" endpuls="false"/>
            <fbevent id="sb_gl1_m" action="enter" from="o_gl1" endpuls="false"/>
            <fbevent id="sb_gl1_a" action="in" from="o_gl1" endpuls="false"/>
          </bk>
      </bklist>
      Danke für die weiteren Hinweise, mir ist aber leider nichtt klar, wie bzw. wo ich sie im XSL anwenden muss, damit die gewünschte Tabelle herauskommt.

      Gruß,
      Dirk

      Comment


      • #4
        Es wäre hilfreich, wenn das XML-Beispiel und das gesuchte Ergebnis auf das Wesentliche reduziert werden könnten. In dieser Form ist das eher ein Ratespiel.

        Comment


        • #5
          Okay, here we go ...

          Code:
          <fblist>
              <fb id="sb_gl1_b" x="24" y="0" z="1" state="false" prev_id="sb_gl1_b" desc="sb_gl1_b" show="true" ori="west" iid="" bus="0" unit="1" pin="14" action="false" addr="14"/>
                <fbaction type="sw" id="SB_gl4_o" cmd="turnout" activate="true"/>
                <fbaction type="sw" id="SB_gl4_w" cmd="straight" activate="true"/>
              </fb>
          </fblist>
          <bklist>
              <bk id="SB_gl1" x="12" y="0" z="1" state="open" prev_id="SB_gl1" desc="" len="0" electrified="false" station="false" wait="false" gomanual="true" acceptghost="false" terminalstation="false" commuter="no" fba="" fbb="" fbi="" fbr="" fbm="" signal="" wsignal="" speed="min" type="none" incline="0" waitmode="loc" minwaittime="1" maxwaittime="30" waittime="10" evttimer="0" iid="" addr="0" port="0" td="false" locid="" exitspeed="cruise" ttid="" signalR="" wsignalR="">
                <fbevent id="sb_gl1_m" action="enter" from="w_gl1" endpuls="false"/>
                <fbevent id="sb_gl1_b" action="in" from="w_gl1" endpuls="false"/>
                <fbevent id="sb_gl1_m" action="enter" from="BU_gl4" endpuls="false"/>
                <fbevent id="sb_gl1_a" action="in" from="BU_gl4" endpuls="false"/>
                <fbevent id="sb_gl1_m" action="enter" from="o_gl1" endpuls="false"/>
                <fbevent id="sb_gl1_a" action="in" from="o_gl1" endpuls="false"/>
              </bk>
          </bklist>
          Und die Ausgabe sollte in etwas so aussehen:

          Code:
          <table>
          <THEAD>
          	<TR>
          	<TH>ID</TH>
          		<TH>Description</TH>
          		<TH>IID</TH>
          		<TH>Address</TH>
          	</TR>
          </THEAD> 
          <TBODY>
          <tr>
          	<td>sb_gl1_b</td>
          	<td>sb_gl1_b</td>
          	<td></td>
          	<td>14</td>
          </tr>	 
          <TR>	
          	<td></td>
                  <td colspan="3">
                  <table border="0" rules="all" cellpadding="4" cellspacing="0" width="100%">
                       <tr>
                         <td><b>Action</b></td>
                         <td>sw -&gt; SB_gl4_o -&gt; turnout</td>  	
          	     </tr>
          	     <tr>
          		<td><b>Action</b></td>
          		<td>sw -&gt; SB_gl4_w -&gt; straight</td>  	
          	     </tr>
          	</table>
          	</TD>	
          	</TR>	   
                   <TR>	
          	    <td></td>
          	<td colspan="3">
          	<table border="0" rules="all" cellpadding="4" cellspacing="0" width="100%">
          	<tr>
          	   <td><b>Block</b></td>
          	   <td>SB_GL1: Action -&gt; in from Block -&gt; w_gl1 </td>  	
          	</table>
          	</TD>	
          </TR>	   
          </tbody>
          </table>
          Nach der Ausgabe eines <fb> mit den dazugehörigen <fbaction> möchte ich alle <bk @id> ausgeben in deren Child <fbevent> die ID gleich der ID des gerade ausgegebenen <fb> verwendet wird.

          Ich hoffe,dass es hiermit ein wenig klarer wird.

          Gruß,
          Dirk

          Comment


          • #6
            Probiere es im fb-Template hiermit:
            Code:
            <xsl:variable name="id" select="@id"/>
            <xsl:for-each select="../../bklist/bk">
              <xsl:variable name="bkid" select="@id"/>
              <xsl:for-each select="fbevent">
                <xsl:if test="@id=$id">
                  <xsl:value-of select="$bkid"/><br />
                </xsl:if>
              </xsl:for-each>
            </xsl:for-each>

            Comment


            • #7
              Super und herzlichen Dank!

              Das hat problemlos funktioniert und jetzt kann ich mich an die Feinarbeit bzgl. Formatierung begeben.

              Viele Grüße,
              Dirk

              Comment

              Working...
              X