2016-08-01 53 views
-1

Meine XML sieht wie folgt aus, dessen Name data.xmlwie die Kontrollkästchen überprüfen, ob der Wert in xml ja, und wenn nicht als ungeprüft

<?xml version="1.0" standalone="yes"?> 
<CATALOG> 
    <orderByTitleDesc /> 
    <orderByTitleDesc /> 
    <orderByTitleDesc /> 
    <orderByTitleDesc /> 
    <orderByTitleDesc /> 
    <orderByTitleDesc /> 
    <orderByTitleDesc /> 
    <orderByTitleDesc /> 
    <CD /> 
    <CD> 
    <ID>1</ID> 
    <LocationID>wqe</LocationID> 
    <ChangeValueFor>qwe</ChangeValueFor> 
    <Banner>wew</Banner> 
    <DataEntry>Yes</DataEntry> 
    <LocalView>No</LocalView> 
    <Export>Yes</Export> 
    <View>qwe</View> 
    <ActiveView>wqe</ActiveView> 
    <HelpFile>qwe`qw</HelpFile> 
    <Location01>qwe</Location01> 
    <Location02>eq</Location02> 
    <Location03>we</Location03> 
    <Location04>wqew</Location04> 
    <Location05>qws</Location05> 
    <Location06>sds</Location06> 
    <Location07>wde</Location07> 
    <Location08>sd</Location08> 
    <Location09>sad</Location09> 
    <Server>31 March 2014 testing with font</Server> 
    <Server2>171.21.102.11</Server2> 
    <Server3>171.21.102.11</Server3> 
    <CodeBase>CodeBase2</CodeBase> 
    <CodeBase2>ZaidiTest</CodeBase2> 
    <CodeBase3>test222</CodeBase3> 
    <ClassiscID>ClassID312131313</ClassiscID> 
    <ClassiscID2>31 amrch testing for font</ClassiscID2> 
    <ClassiscID3>ClassID2</ClassiscID3> 
    <Theme>VashnoDevi</Theme> 
    <Theme2>class</Theme2> 
    <Theme3>class</Theme3> 
    <Theme4>Theme2</Theme4> 
    <Theme5>Ser</Theme5> 
    <Theme6>Themes1test</Theme6> 
    </CD> 

ich will, wenn <DataEntry><LocalView> und <Export> ist ja als mein Scheck In der Box ist Y aktiviert und wenn Nein, nicht deaktiviert (so wie es ist).

Meine xslt-Datei ist wie folgt: Ich will nur nur auf die Dateneingabe nur eine Checkbox, fügen Sie bitte mir sagen, wo ich Fehler mache

Myxslt Datei ist wie folgt:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> 
    <xsl:template match="/"> 
    <html> 
     <body style="font-family:Helvetica Neue"> 
     <!--<Div id="ListingScreen" style="display:Yes;">--> 
     <Div id="ListingScreen"> 
      <table border="1" width="1024px" > 
      <tr bgcolor="blue"> 
       <FONT 
      style="BACKGROUND-COLOR: #0000ff"> 
       <FONT color="white"> 
        <STRONG> 
        Maintenance of Parameters for Cube Access 
        </STRONG> 
       </FONT> 
       </FONT> 
      </tr> 
      <tr> 
       <td align="right" colspan="8"> 
       <img src="http://localhost:51242/Images/AFKLLogo.png" alt="Smiley face" width="210"></img> 
       </td> 
      </tr> 
      <tr> 
       <td colspan="8"> 
       <h1>WPTesting - Cube List Web Part</h1> 
       </td> 
      </tr> 
      <tr> 
       <td colspan="8" align="center"> 
       <input type="Button" id="btnAddMasterData" value="Add Master Data" onclick="javascript:AddMasterData()"/> 
       <input type="Button" id="btnAdd" value=" Add " onclick="javascript:location.href='AddMaster.aspx'"/> 
       </td> 
      </tr> 
      <tr> 
       <th id="location">Location ID</th> 
       <th>Data Entry</th> 
       <th>Export</th> 
       <th>Local View</th> 
       <th>Banner</th> 
       <th>Server</th> 
       <th>View</th> 
       <th>Locl</th> 
      </tr> 

      <xsl:choose> 
       <xsl:when test="CATALOG/orderByTitle"> 
       <xsl:for-each select="CATALOG/CD" order-by="+ TITLE"> 
        <tr> 
        <td onclick="javascript:FillEditScreen(this.innerText);"> 
         <a href="javascript:void(0);"> 
         <p style="display:none;"> 
          <xsl:value-of select="ID"/> 
         </p> 
         <xsl:value-of select="LocationID"/>          
         </a> 
         <input type="checkbox" id="chkdataentry" /> 
         <xsl:value-of select='DataEntry'/> 
        </td> 
        <td> 
         <input type="checkbox" id="chkLocalView" /> 
         <xsl:value-of select='LocalView'/> 
        </td> 
        <td> 
         <input type="checkbox" id="chkExport"/> 
         <xsl:value-of select='Export'/> 
        </td> 
        <td> 
         <xsl:value-of select="Banner"/> 
        </td> 
        <td> 
         <xsl:value-of select="Server"/> 
        </td> 
        <td> 
         <xsl:value-of select="View"/> 
        </td> 
        <td> 
         <xsl:value-of select="Location01"/> 
        </td> 
        </tr> 
       </xsl:for-each> 
       </xsl:when> 
       <xsl:when test="CATALOG/orderByTitleDesc"> 
       <xsl:for-each select="CATALOG/CD" order-by="- TITLE"> 
        <tr> 
        <td onclick="javascript:FillEditScreen(this.innerText);"> 
         <a href="javascript:void(0);"> 
         <p style="display:none;"> 
          <xsl:value-of select="ID"/> 
         </p> 
         <xsl:value-of select="LocationID"/> 

         </a> 
        </td> 

        <input type="checkbox" name="DataEntry" value="Milk"> 
         <xsl:if test="CATALOG/CD='Yes'"> 
         <xsl:attribute name="checked">checked</xsl:attribute> 
         </xsl:if> 
        </input> 
        <!--<td> 
         <input type="checkbox" checked="true" id="chk" value="Milk"/> 
        </td>--> 
        <td> 
         <input type="checkbox" checked="true" name="Export" value="export"/> 
        </td> 
        <td> 
         <input type="checkbox" checked="true" name="LocalView" value="export"/> 
        </td> 
        <td> 
         <xsl:value-of select="Banner"/> 
        </td> 
        <td> 
         <xsl:value-of select="Server"/> 
        </td> 
        <td> 
         <xsl:value-of select="View"/> 
        </td> 
        <td> 
         <xsl:value-of select="Location01"/> 
        </td> 
        </tr> 
       </xsl:for-each> 
       </xsl:when> 
       <xsl:when test="CATALOG/orderByArtist"> 
       <xsl:for-each select="CATALOG/CD" order-by="+ ARTIST"> 
        <tr bgcolor="blue"> 
        <td> 
         <input type="Button" id="btnArtist" value="Impala"/> 
        </td> 
        <td> 
         <input type="checkbox" id="chk" value="Milk"/> 
        </td> 
        <td> 
         <input type="checkbox" name="Export" value="export"/> 
        </td> 
        <td> 
         <input type="checkbox" checked="true" name="LocalView" value="export"/> 
        </td> 
        <td> 
         <xsl:value-of select="Banner"/> 
        </td> 
        <td> 
         <xsl:value-of select="Server"/> 
        </td> 
        <td> 
         <xsl:value-of select="View"/> 
        </td> 
        <td> 
         <xsl:value-of select="Locl"/> 
        </td> 
        </tr> 
       </xsl:for-each> 
       </xsl:when> 
      </xsl:choose> 
      </table> 
     </Div> 
     </body> 
    </html> 
    </xsl:template> 
</xsl:stylesheet> 

Die Haupt-Code ist wie thins aber es ist mir eine Fehlermeldung zu geben weiß nicht, warum

<input type="checkbox" name="DataEntry" value="Milk"> 
        <xsl:if test="CATALOG/CD='Yes'"> 
        <xsl:attribute name="checked">checked</xsl:attribute> 
        </xsl:if> 
       </input> 

Antwort

0

Sie haben eigentlich nicht gesagt, was Ihr Fehler ist, oder gezeigt, welche Ausgabe Sie Expe ct, aber ich kann eine Reihe von Problemen sehen.

Erstens ist Ihr XLST Namespace falsch http://www.w3.org/TR/WD-xsl war ein altes von Microsoft verwendet, bevor die formale XSLT-Spezifikation veröffentlicht wurde. Es sollte http://www.w3.org/1999/XSL/Transform sein. Wenn Sie es ändern, müssen Sie einige Änderungen an Ihrem XSLT vornehmen. Statt dies zu tun ...

<xsl:for-each select="CATALOG/CD" order-by="+ TITLE"> 

Sie müssen dies tun, als order-by nicht in der formalen Definition erlaubt ist.

<xsl:for-each select="CATALOG/CD" > 
    <xsl:sort select="TITLE" order="descending" /> 

Zweitens, wenn Ihre aktuelle xsl:if Sie CATALOG/CD='Yes' überprüfen überprüfen, aber Sie sind bereits positioniert auf dem CD so der Ausdruck muss relativ sein, dass zu. Und es sieht so aus, als ob du das Element DataEntry sowieso überprüfen musst, also solltest du dieses in der Bedingung verwenden.

<td> 
    <input type="checkbox" name="DataEntry" value="Milk"> 
    <xsl:if test="DataEntry='Yes'"> 
     <xsl:attribute name="checked">checked</xsl:attribute> 
    </xsl:if> 
    </input> 
</td> 

Beachten Sie auch, dass in Ihrem XSLT-Proben Sie den input Tag in einem td nicht eingeschlossen hatten, die betroffen hätte, wie es auf der Seite gerendert wurde.

Schließlich, obwohl es keinen Fehler verursachen würde, haben Sie viel wiederholten Code in Ihrem XSLT. Erwägen Sie stattdessen, eine Vorlage für das Element CD zu verwenden.

Versuchen Sie, diese XSLT als Beispiel

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 

    <xsl:template match="/"> 
    <html> 
     <body style="font-family:Helvetica Neue"> 
     <Div id="ListingScreen"> 
      <table border="1" width="1024px" > 
      <tr> 
       <th id="location">Location ID</th> 
       <th>Data Entry</th> 
       <th>Export</th> 
       <th>Local View</th> 
       <th>Banner</th> 
       <th>Server</th> 
       <th>View</th> 
       <th>Locl</th> 
      </tr> 
      <xsl:choose> 
       <xsl:when test="CATALOG/orderByTitle"> 
       <xsl:apply-templates select="CATALOG/CD"> 
        <xsl:sort select="TITLE" /> 
       </xsl:apply-templates> 
       </xsl:when> 
       <xsl:when test="CATALOG/orderByTitleDesc"> 
       <xsl:apply-templates select="CATALOG/CD"> 
        <xsl:sort select="TITLE" order="descending" /> 
       </xsl:apply-templates> 
       </xsl:when> 
       <xsl:when test="CATALOG/orderByArtist"> 
       <xsl:apply-templates select="CATALOG/CD"> 
        <xsl:sort select="ARTIST" /> 
       </xsl:apply-templates> 
       </xsl:when> 
      </xsl:choose> 
      </table> 
     </Div> 
     </body> 
    </html> 
    </xsl:template> 

    <xsl:template match="CD"> 
    <tr> 
     <td onclick="javascript:FillEditScreen(this.innerText);"> 
      <a href="javascript:void(0);"> 
      <p style="display:none;"><xsl:value-of select="ID"/></p> 
      <xsl:value-of select="LocationID"/> 
      </a> 
     </td> 
     <td> 
      <input type="checkbox" name="DataEntry" value="dataentry"> 
       <xsl:if test="DataEntry='Yes'"> 
       <xsl:attribute name="checked">checked</xsl:attribute> 
       </xsl:if> 
      </input> 
     </td> 
     <td> 
      <input type="checkbox" name="Export" value="export"> 
       <xsl:if test="Export='Yes'"> 
       <xsl:attribute name="checked">checked</xsl:attribute> 
       </xsl:if> 
      </input> 
     </td> 
     <td> 
      <input type="checkbox" name="LocalView" value="localview"> 
       <xsl:if test="LocalView='Yes'"> 
       <xsl:attribute name="checked">checked</xsl:attribute> 
       </xsl:if> 
      </input> 
     </td> 
     <td><xsl:value-of select="Banner"/></td> 
     <td><xsl:value-of select="Server"/></td> 
     <td><xsl:value-of select="View"/></td> 
     <td><xsl:value-of select="Location01"/></td> 
    </tr> 
    </xsl:template> 
</xsl:stylesheet> 
+0

Seine Arbeit Awsome Tim Dank Sie ein Ton ... –