Hi to every one,
I need some help with this simple (actually not so simple for me..) tranformation.
I've got something like this:
...and I'd like to obtain this:
I've tried this, but does not work properly, optgroup's just
at option's same level:
Any suggest is welcome!!
I need some help with this simple (actually not so simple for me..) tranformation.
I've got something like this:
Code:
<ul> <li class="chapter">Chapter1</li> <li class="sub">subchap1.1</li> <li class="sub">subchap1.2</li> <li class="chapter">Chapter2</li> <li class="sub">subchap2.1</li> <li class="sub">subchap2.2</li> </ul>
Code:
<select> <optgroup label="Chapter1"> <option>subchap1.1</option> <option>subchap1.2</option> </optgroup> <optgroup label="Chapter2"> <option>subchap2.1</option> <option>subchap2.2</option> </optgroup> </select>
at option's same level:
Code:
<xsl:template match="ul"> <select> <xsl:for-each select="li[@class='chapter']"> <optgroup> <xsl:attribute name="label"> <xsl:value-of select="current()"/> </xsl:attribute> <xsl:for-each select="li[@class='sub']"> <option> <xsl:attribute name="value"> <xsl:value-of select="current()"/> </xsl:attribute> <xsl:value-of select="current()"/> </option> </xsl:for-each> </optgroup> </xsl:for-each> </select> </xsl:template> </xsl:stylesheet>
Comment