Re: [xml] XSLT question
- From: Colin Fox <cfox cfconsulting ca>
- Cc: xml gnome org
- Subject: Re: [xml] XSLT question
- Date: Fri, 12 Mar 2004 21:00:15 -0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Never mind - I just realized that they aren't in the same context. Doh.
cf
Colin Fox wrote:
| I realize this is the XML rather than an XSLT mailing list, but I figure
| this isn't too off topic.
|
| Here is a chunk of an XSLT file:
|
| <xsl:template match="xform:form[ type='batch']">
| ~ <form method="{ method}" action="{ action}" name="{ name}">
| ~ <table class="{ type}">
| <!--
| Here we need to output the titles of each column.
| The logic here is this: Get the first record, and then
| go through and grab all xform:fields that have a 'title'
| element.
| -->
| <tr>
| <xsl:for-each
| select="xform:records/xform:record[position()=1]/xform:field[ title]">
| <th><xsl:value-of select="@title" /></th>
| </xsl:for-each>
| </tr>
|
| <xsl:for-each select="xform:records">
| <!-- Then we need to write out each row. -->
| <xsl:for-each select="xform:record">
| <tr class="row{position() mod 2}">
| <xsl:apply-templates mode="batch" />
| </tr>
| </xsl:for-each> <!-- record -->
| </xsl:for-each> <!-- records -->
|
| <xsl:for-each select="xform:actions">
| <tr><td align='center'
|
|
colspan="{count(xform:records/xform:record[position()=1]/xform:field[ title])}">
|
| <xsl:for-each select="xform:action">
| <input type="submit" name="{ name}" value="{ title}" />
| </xsl:for-each> <!-- action -->
| </td></tr>
| </xsl:for-each> <!-- actions -->
|
| ~ </table>
| ~ </form>
| </xsl:template>
|
| This template does almost exactly what I need except for one thing - The
| first for-each selects on a slightly complicated query, the idea being
| to create one table column title for each form field that has a title.
| This works correctly.
|
| However, the part near the bottom where I'm setting the colspan to be
| the count of the same thing doesn't work - it sets the colspan to be 0.
| The context of both queries should be the same, so why does the first
| query work and the second not?
|
| Thanks,
| ~ cf
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAUpVfoaQ1/feGlJoRAqWdAJ98L4Hqt3LAJNDN3HJvWkly73SJ1ACfUNJ2
SeWxdptT3SYGndk3+nW0oxs=
=5Bzf
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]