<?xml version="1.0"  encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>Eingabemaske</title>
        <LINK REL="stylesheet" type="text/css" href="../xml/maske_html.css"/>
      </head>
      <body>
      <table class="buttons">
                <tr>
                  
                  <td><a href="../index.htm" target="_parent" title="Zeige Menü">
                    <img src="../images/show_toc.gif" border="0" alt="Zeige Menü" /></a>
                  </td>
			<td>
                    <a href="javascript:history.back();" title="Zurück">
                      <img src="../images/return.gif" border="0"  alt="Zurück" />
                    </a>
                  </td>
 
                  <td>
                    <a href="javascript:document.forms[0].submit();" title="Abschicken">
                    <img src="../images/clone.gif" border="0"  alt="Abschicken"/></a>
                  </td>
                  <td>
                    <img src="../images/help.gif" border="0" />
                  </td>
                  <td>
                    <img src="../images/info.gif" border="0" />
                  </td>
                </tr>
              </table>
<p class="maskentitel">Bearbeiten: <xsl:value-of select="maske/felder/feld/maskenname" /></p>
        <table border="0" width="100%">
          <tr>
            <td valign="top">
              <form name="maske" action="SuperXmlTabelle" method="post">
                <xsl:for-each select="maske/felder">
                 <table border="0">
                    <tr>
                      <td class="themenspalte">
                        <input type="hidden" name="tid">
                          <xsl:attribute name="value">
                            <xsl:value-of select="../../maske/@tid"/>
                          </xsl:attribute>
                        </input>
                      </td>
                      <td/>
                    </tr>
                    <xsl:for-each select="feld">
                      <xsl:call-template name="feld">
                      </xsl:call-template>
                      <!--<xsl:if test="y='0'"></tr></xsl:if>-->
                    </xsl:for-each>
                   <tr>
                      <td class="themenspalte">
                    <input type="hidden" name="UserID">
		        <xsl:attribute name="value"><xsl:value-of select="/maske/UserID"/></xsl:attribute>
			</input>
                      </td>
                      <td>
                        <!--<SELECT NAME="tabellenformat">
  <OPTION VALUE="tabelle_html.xsl" SELECTED="true">Tabelle (html)</OPTION>
  <OPTION VALUE="tabelle_pdf.xsl">Tabelle (pdf)</OPTION>
  <OPTION VALUE="tabelle_xml.xsl">XML-Datei</OPTION>
  <OPTION VALUE="tabelle_svg.xsl">Diagramm (html)</OPTION>
</SELECT>-->
                        <input type="submit" value="Abschicken"/>
                      </td>
                    </tr>
                  </table>
				                 </xsl:for-each>
              </form>
            </td>
          </tr>
          <tr>
            <td/>
          </tr>
        </table>
      </body>
    </html>
  </xsl:template>
  <xsl:template name="feld">
                      <tr>
 
    <xsl:call-template name="inputfeld"/> </tr>
  </xsl:template>
  <xsl:template name="inputfeld">
                          <td class="themenspalte">
      					  	 <xsl:attribute name="width"><xsl:value-of select="buttonbreite"/></xsl:attribute>
                          <xsl:if test="obligatorisch='1'">
                            <b>
                              <xsl:value-of select="name"/>
                            </b>
                          </xsl:if>
                          <xsl:if test="obligatorisch='0'">
                            <xsl:value-of select="name"/>
                          </xsl:if>
                        </td>
                        <td>   
    <xsl:choose>
      <xsl:when test="art='0'">
      <table><tr><td>
        <xsl:if test="zeilenanzahl='1'">
          <input type="text">
            <xsl:attribute name="NAME">
              <xsl:value-of select="name"/>
            </xsl:attribute>
            <xsl:attribute name="id">
              <xsl:value-of select="name"/>
            </xsl:attribute>
            <xsl:attribute name="MAXLENGTH">
              <xsl:value-of select="laenge"/>
            </xsl:attribute>
            <xsl:attribute name="VALUE">
              <xsl:value-of select="defaultwert/sqlerg/row/col0"/>
            </xsl:attribute>
            <xsl:attribute name="size">
              <xsl:value-of select="feldbreite"/>
            </xsl:attribute>
          </input>
        </xsl:if>
        <xsl:if test="zeilenanzahl!='1'">
          <textarea WRAP="on">
            <xsl:attribute name="cols">
              <xsl:value-of select="feldbreite"/>
            </xsl:attribute>
            <xsl:attribute name="rows">
              <xsl:value-of select="zeilenanzahl"/>
            </xsl:attribute>
            <xsl:attribute name="NAME">
              <xsl:value-of select="name"/>
            </xsl:attribute>
            <xsl:value-of select="defaultwert/sqlerg/row/col0"/>
          </textarea>
        </xsl:if>
	</td></tr><tr><td align="bottom">
	<xsl:if test="typ='char'">
		<a>
		<xsl:attribute name="href">javascript:document.forms[0].<xsl:value-of select="name"/>.value='--leer--'; this.focus();</xsl:attribute>
		<img src="../xml/leer.gif" border="0" alt="Feld leeren" /> 
		</a>
        </xsl:if>
	</td></tr></table>
      </xsl:when>
      <xsl:when test="art='1'">
        <SELECT>
          <xsl:attribute name="NAME">
            <xsl:value-of select="name"/>
          </xsl:attribute>
              <OPTION/>
          <xsl:for-each select="relation/sqlerg/row">
            <OPTION>
              <xsl:attribute name="value">
                <xsl:value-of select="col0"/>
              </xsl:attribute>
	  		  <xsl:if test="../../../defaultwert/sqlerg/row/col0=col0">
          		  <xsl:attribute name="selected">
           		  true
          		  </xsl:attribute>
		    </xsl:if>
              <xsl:value-of select="col1"/>
            </OPTION>
          </xsl:for-each>
        </SELECT>
      </xsl:when>
      <xsl:when test="art='2'">
            <SELECT>
          <xsl:attribute name="NAME">
            <xsl:value-of select="name"/>
          </xsl:attribute>
              <OPTION/>
          <xsl:for-each select="relation/sqlerg/row">
            <OPTION>
              <xsl:attribute name="value">
                <xsl:value-of select="col0"/>
              </xsl:attribute>
	  		  <xsl:if test="../../../defaultwert/sqlerg/row/col1=col1">
          		  <xsl:attribute name="selected">
           		  true
          		  </xsl:attribute>
		    </xsl:if>
              <xsl:value-of select="col1"/>
            </OPTION>
          </xsl:for-each>
        </SELECT>
      </xsl:when>
      <xsl:when test="art='3'">
        <input type="file">
          <xsl:attribute name="NAME">
            <xsl:value-of select="name"/>
          </xsl:attribute>
          <xsl:attribute name="size">
            <xsl:value-of select="feldbreite"/>
          </xsl:attribute>
        </input>
      </xsl:when>
      <xsl:when test="art='4'">
         <xsl:call-template name="treeview">
       </xsl:call-template>
  	<input type="hidden" name="Organigramm-Stand" value="1.1.2002"/>
	<input type="hidden" name="erlaubt" value="1"/>
    </xsl:when>
      <xsl:when test="art='6'">
        <xsl:call-template name="treeview">
       </xsl:call-template>
 	<input type="hidden" name="Organigramm-Stand" value="1.1.2002"/>
	<input type="hidden" name="erlaubt" value="1"/>
   </xsl:when>
      <xsl:when test="art='7'">
         <xsl:call-template name="treeview">
       </xsl:call-template>
  	<input type="hidden" name="Organigramm-Stand" value="1.1.2002"/>
	<input type="hidden" name="erlaubt" value="1"/>
   </xsl:when>
      <xsl:when test="art='9'">
        <xsl:call-template name="treeview">
       </xsl:call-template>
      </xsl:when>
        <xsl:when test="art='10'">
           <input type="checkbox" value="true">
            <xsl:attribute name="NAME">
              <xsl:value-of select="name"/>
            </xsl:attribute>
            <xsl:attribute name="checked">
              <xsl:value-of select="defaultwert/sqlerg/row/col0"/>
            </xsl:attribute>
          </input>
       
      </xsl:when>
     <xsl:otherwise>Unbekanntes Feld</xsl:otherwise>
    </xsl:choose>
	</td>
  </xsl:template>
  <xsl:template name="treeview">
  <!--Das Treeview-Control geht davon aus, dass im sqlerg die Felder wie folgt belegt sind:
    col0 enthält den Volltext des Eintrags,
    col1 die nr bzw. key_apnr beim Organigramm
    col2 den parent-Knoten
    -->
      <select>
        <xsl:attribute name="name">
          <xsl:value-of select="name"/>
        </xsl:attribute>
		<option></option>
 		<xsl:variable name="t_root"/>
	  <xsl:for-each select="relation/sqlerg/row">
	  <xsl:if test="((col2='null') or (col2=''))">
		<!--Zuerst wird root eingefügt, und dann alle Kinder von Root -->
	        <OPTION>
          		<xsl:attribute name="value">
            		<xsl:value-of select="col1"/>
          		</xsl:attribute>
		  	<xsl:if test="../../../defaultwert/sqlerg/row/col1=col1">
          		  <xsl:attribute name="selected">
           		  true
          		  </xsl:attribute>
		    	</xsl:if>
 	           <xsl:value-of select="col0"/>
	        </OPTION>

	    <xsl:call-template name="suche_kinder">
          <xsl:with-param name="elter" select="col1"/>
          <xsl:with-param name="ausgewaehlt" select="../../../defaultwert/sqlerg/row/col1"/>
          <xsl:with-param name="ebene" select="0"/>
      </xsl:call-template>
			
	 </xsl:if> 
 
      </xsl:for-each>
	
      </select>
  </xsl:template>
    
  
  <xsl:template name="suche_kinder">
    <xsl:param name="elter"/>
    <xsl:param name="ausgewaehlt"/>
    <xsl:param name="ebene"/>
   <xsl:for-each select="../row">
	
      <xsl:variable name="i" select="col2"/>
	
      <xsl:if test="$i=$elter">
	  		 
        <OPTION>
          <xsl:attribute name="value">
            <xsl:value-of select="col1"/>
          </xsl:attribute>
		  <xsl:if test="$ausgewaehlt=col1">
          		  <xsl:attribute name="selected">
           		  true
          		  </xsl:attribute>
		    </xsl:if>
  		  <xsl:if test="$ebene='1'">
		  		  <xsl:text>&#160;&#160;-</xsl:text>
		  </xsl:if>
 	  	  <xsl:if test="$ebene='2'">
		  		  <xsl:text>&#160;&#160;&#160;&#160;-</xsl:text>
		  </xsl:if>
		 
		  <xsl:if test="$ebene='3'">
		  		  <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;-</xsl:text>
		  </xsl:if>
		  <xsl:if test="$ebene='4'">
		  		  <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-</xsl:text>
		  </xsl:if>
		  <xsl:if test="$ebene='5'">
		  		  <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-</xsl:text>
		  </xsl:if>
		  <xsl:if test="$ebene='6'">
		  		  <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-</xsl:text>
		  </xsl:if>
		
 	           <xsl:value-of select="col0"/>
        </OPTION>
        <xsl:call-template name="suche_kinder">
          <xsl:with-param name="elter" select="col1"/>
          <xsl:with-param name="ausgewaehlt" select="$ausgewaehlt"/>
          <xsl:with-param name="ebene" select="$ebene+1"/>
       </xsl:call-template>
	     </xsl:if>   
 
    </xsl:for-each>
	
  </xsl:template>
</xsl:stylesheet>