if-each中if语句的简单xsl问题

时间:2017-08-30 19:41:17

标签: xslt

这是我的代码

    <table cellspacing="0" cellpadding="0"><tbody>
    <tr>
    <xsl:for-each select="/*/nearme/location">
    <td>
    <input type="radio" name="rf" id="rf" class="page_checkbox"/><label for="rf1"><span></span><xsl:value-of select="."/></label>
    </td>
    <xsl:if test="position() mod 5=0">
    </tr><tr>
    </xsl:if>
    </xsl:for-each>
    </tr>
    </tbody></table>

如果您看到有一个xsl if test确定该位置是否为模数5.如果是,我想结束tr并开始一个新的tr但是它会打破这个当前的代码。

知道如何解决这个问题吗?

更新:

这是我的xml:

     <nearme>

     <location id="538">Pleasures</location>

     <location id="541">Baby Dolls</location>

     <location id="1521">Michelle's Beach House</location>

     <location id="1886">Wild Wild West Gentlemen's Club</location>

     <location id="993">Sadies</location>

     <location id="5381">ABC</location>

     <location id="541">DEF</location>

     <location id="1521">ghi</location>

     <location id="1886">FDFFDSFD</location>

     <location id="993">HGHHFH</location>

    </nearme>

这是我的预期输出:

<table cellspacing="0" cellpadding="0"><tbody>
        <tr>
        <td>
        <input type="radio" name="rf" id="rf1" class="page_checkbox"/><label for="rf1"><span></span>Pleasures</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf2" class="page_checkbox"/><label for="rf2"><span></span>Baby Dolls</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf3" class="page_checkbox"/><label for="rf3"><span></span>Michelle's Beach House</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf4" class="page_checkbox"/><label for="rf4"><span></span>Wild Wild West Gentlemen's Club</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf5" class="page_checkbox"/><label for="rf5"><span></span>Sadies</label>
        </td>
        </tr>
        <tr>        
        <td>
        <input type="radio" name="rf" id="rf6" class="page_checkbox"/><label for="rf6"><span></span>ABC</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf7" class="page_checkbox"/><label for="rf7"><span></span>DEF</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf8" class="page_checkbox"/><label for="rf8"><span></span>ghi</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf9" class="page_checkbox"/><label for="rf9"><span></span>FDFFDSFD</label>
        </td>
        <td>
        <input type="radio" name="rf" id="rf10" class="page_checkbox"/><label for="rf10"><span></span>HGHHFH</label>
        </td>
        </tr>
        </tbody></table>

2 个答案:

答案 0 :(得分:1)

To simplify the example to the minimum necessary to demonstrate the problem, consider the following:

XML

PictureBox

XSLT 1.0

Bitmap screenshot = TakeScreenshot();
pictureBox1.Image = screenshot;

Result

___

答案 1 :(得分:0)

You have to use grouping.

In XSLT 2.0 you can use #headerimg { background: url(http://www.adamoxenhamsmith.co.uk/site/img/NewYork.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; , grouping by 5 adjacent #include <bits/stdc++.h> using namespace std; #define ii pair<int,int> bool modified_sort(const pair<int,int> &a, const pair<int,int> &b) { if (a.first == b.first) { return (a.second <b.second); } return (a.first <b.first); } int main() { // your code goes here vector<ii> blocks; int n; // no of blocks int a,b; cin>>n; for (int i=0;i<n;i++) { cin>>a>>b; blocks.push_back(ii(a,b)); } sort(blocks.begin(), blocks.end(), modified_sort); int start=0,end=0; int max_height=0; while(end<n) { while(start<end && blocks[start].second <= blocks[end].first) { start++; } max_height = max(max_height,(end-start+1)); end++; } cout<<max_height<<endl; return 0; } elements.

For each of the above groups generate a if (!this.IsHandleCreated) this.CreateControl(); this.Invoke((MethodInvoker)delegate { //do so }); element.

Inside it you must place a loop iterating through the current group, generating for-each-group elements, with location and tr inside.

Below you have an example code:

td