[xsl] <option selected> breaking xsl?

Subject: [xsl] <option selected> breaking xsl?
From: elizabeth Hostetter <aellath@xxxxxxxxxxxxx>
Date: Thu, 6 Oct 2011 10:31:27 -0700
i'm creating a dropdown that is populated by page numbers determined by xsl and a number of items per page. i've got the dropdown working with the js and xsl, but now i'm trying to have the *current* page be the one that displays when the dropdown is created (so if i'm on page 4, "4" is the pre-selected option in the dropdown.

i know the attribute in html is <option selected> -- but it causes an xsl transform error every time. i know this, because i've taken just that one attribute out of my code, and the code doesn't break.

<code>
<!-- dropdown page menu -->
<select id="pageMenu" onChange="turnPage();">
<xsl:for-each select="//PageOffset">
<xsl:choose>
<xsl:when test=". != ../CurrentItemOffset">
<option><xsl:value-of select="position()"/></option>
</xsl:when>
<xsl:otherwise>
<option selected><xsl:value-of select="position()" /></ option>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</select>
</code>


If i take out the 'selected' attribute in the <xsl:otherwise> clause, the page loads normally. Obviously, the choose block is pointless if i do that, though!

i'm positing that the transform is choking on the 'selected' because it looks like the 'select' attribute in xsl - but it's not in an xsl tag, so why?

Of course, just like last time, the error message is not helpful:
<blockquote>
XSL Transform Error:
java.lang.Exception: org.xml.sax.SAXParseException: character not allowed
Message:org.xml.sax.SAXParseException: character not allowed
</blockquote>


can anyone tell me why 'selected' is breaking the page, and if there's a way to do this?

thank you!
aellath

Current Thread