Announcement Announcement Module
Collapse
No announcement yet.
Using XSL; Binding arrays, indexing from 1 instead of 0? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using XSL; Binding arrays, indexing from 1 instead of 0?

    Hello,

    I'm using the XSTL view resolver in my pages. One of the niggles I have with it so far (not necessarily Spring's fault) is that XSL starts indexing sets of things at 1 instead of 0. So, I end up with code like this in my stylesheet:

    <xsl:call-template name="inputRow">
    <xsl:with-param name="rowName" select="'Physical Address 1'"/>
    <xsl:with-param name="formPath" select="'physicalAddress.addressLine[0]'"/>
    <xsl:with-param name="value" select="/model/buyer/physicalAddress/addressLine[1]"/>
    </xsl:call-template>

    This is a call to an xsl template which renders (among other things) a form <input...> field; formPath is pushed into the "name" attribute, and is the spring expression used to bind to the bean, while value is pushed into the "value" attribute, and is the xpath expression used to pull the value out of the xml model that's being transformed. As you can see, in the spring variant, we're addressing element 0, while in the xml variant element 1.

    Can you think of a (not too nasty) workaround so that I can keep these is check with each other? I can foresee that building the app out with this inconsistency could be messy.

    Thanks
Working...
X