سؤال

From the docs, XSL processor can be used to dynamically generate href links (or other HTML content):

<xhtml:tr>
<xhtml:td>
    <xsl:for-each select="{instance('fr-form-instance')/form/retrievalSection/retrievalControl">
        <xhtml:a href="http://somewhere/">
            <xsl:value-of select="SomeData"/>
            <xsl:if test="position() lt last()">
                <br/>
            </xsl:if>
        </xhtml:a>
    </xsl:for-each>
</xhtml:td>

The above is just rough example code, that href is static in above can be ignored.

The problem is this (xslt generated link text) does not get updated automatically upon instance update; how to achieve that?

هل كانت مفيدة؟

المحلول

XSLT processing is done once and for all when the page loads. You can see the XSLT step as a template or preprocessing step. Once that's done, XForms processes the result, and then things get dynamically updated.

You can mix XSLT and XForms this way, but it's not trivial and if you can it's probably best to avoid it.

I would try using XForms exclusively to achieve this instead, something like:

<xhtml:td>
    <xforms:repeat nodeset="instance('fr-form-instance')/form/retrievalSection/retrievalControl">
        <xhtml:a href="http://somewhere/">
            <xforms:output value="SomeData"/>
            <xhtml:br/>
        </xhtml:a>
    </xforms:repeat>
</xhtml:td>

If you want the href to be dynamic, use an AVT like in XSLT:

href="{expression}"

Finally, you could put the <br/> within an <xforms:group> to make it conditional, but it's probably better to use CSS in this case if you can.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top