我有一个 HTML 文件,我想将其转换为表单。
<p class="textfield">Text field</p>
<p class="checkboxfield">Check Box field</p>
<p class="drop_downlistfield">Drop-down list field 1</p>
<p class="drop_downlistfield">Drop-down list field 2</p>
<p class="drop_downlistfield">Drop-down list field 3</p>
<p class="radiobuttonfield">Radio Button field 1</p>
<p class="radiobuttonfield">Radio Button field 2</p>
<p class="radiobuttonfield">Radio Button field 3</p>
<p class="submitbuttonfield">Submit button</p>
为此,我必须创建组:带有 class="drop_downlistfield" 的段落必须成为一组:
<select>
<option value="Drop-down list field 1">Drop-down list field 1</option>
<option value="Drop-down list field 2">Drop-down list field 2</option>
<option value="Drop-down list field 3">Drop-down list field 3</option>
</select>
并且 class="radiobuttonfield" 的段落必须成为另一个组,按其 @name 属性分组。
<input type="radio" id="ID_1929_6" name="radiogroup"></input>
<label for="ID_1929_6">Radio Button field 1</label>
<input type="radio" id="ID_1929_7" name="radiogroup"></input>
<label for="ID_1929_7">Radio Button field 2</label>
<input type="radio" id="ID_1929_8" name="radiogroup"></input>
<label for="ID_1929_8">Radio Button field 3</label>
我可以创建一个组:
<xsl:for-each-group select="table|p|ul|ol" group-adjacent="(@class='radiobuttonfield')">
但我很难创建两个。这将创建一个包含以下两者的组:
<xsl:for-each-group select="table|p|ul|ol" group-adjacent="(@class='radiobuttonfield') or (@class='drop_downlistfield')">
如何将此输入片段分成两个单独的组?
只需按该@class-attribute 的值对它们进行分组即可。像这样的东西: