xsl-list
[Top] [All Lists]

[xsl] <option selected> breaking xsl?

2011-10-06 21:29:15
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>