xsl-list
[Top] [All Lists]

[xsl] using position() inside Muenchian groups?

2008-10-13 21:15:33
I've got data that looks like this:

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult";>
<RESULTSET FOUND="3">
    <ROW MODID="0" RECORDID="1">
        <COL><DATA>1</DATA></COL>
        <COL><DATA>The Alice</DATA></COL>
        <COL>
            <DATA>PRDC</DATA>
            <DATA>EXCP</DATA>
            <DATA>DRCT</DATA>
            <DATA>DOPH</DATA>
            <DATA>EXCP</DATA>
            <DATA>PRDC</DATA>
            <DATA>WRTR</DATA>
        </COL>
        <COL>
            <DATA>Alan Jones</DATA>
            <DATA>Big Cheese</DATA>
            <DATA>Bill Smith</DATA>
            <DATA>Camera Guy</DATA>
            <DATA>Little Cheese</DATA>
            <DATA>Zachary Azimuth</DATA>
            <DATA>Dicky Dickens</DATA>
        </COL>
        <COL>
            <DATA></DATA>
            <DATA></DATA>
            <DATA>Yes</DATA>
            <DATA></DATA>
            <DATA></DATA>
            <DATA></DATA>
            <DATA></DATA>
        </COL>
    </ROW>
    <ROW MODID="0" RECORDID="3">
        <COL><DATA>3</DATA></COL>
        <COL><DATA>Mini Mini</DATA></COL>
        <COL>

            <DATA>DRCT</DATA>
            <DATA>PRDC</DATA>
            <DATA>WRTR</DATA>
        </COL>
        <COL>
            <DATA>Wal Walliams</DATA>
            <DATA>Wal Walliams</DATA>
            <DATA>Wal Walliams</DATA>
        </COL>
        <COL>
            <DATA>Yes</DATA>
            <DATA>Yes</DATA>
            <DATA>Yes</DATA>
        </COL>
    </ROW>
</RESULTSET>
</FMPXMLRESULT>

There are always five columns (which for convenience I refer to by variable
names, see following), but the number of <DATA> elements in columns #3-5 can
vary per record.

    <xsl:variable select="1"  name="title_id" />
    <xsl:variable select="2"  name="title" />
    <xsl:variable select="3"  name="crew_role" />
    <xsl:variable select="4"  name="crew_name" />
    <xsl:variable select="5"  name="crew_flag" />

I want to produce output that looks like this:

Title: The Alice
Producer: Alan Jones*, Zachary Azimuth
Director: Bill Smith
Writer: Dicky Dickens

Title: Mini Mini
Producer: Wal Walliams*
Director: Wal Walliams*
Writer: Wal Walliams*

I'm thinking I could use Muenchian grouping to pull out all the PRDC
sub-fields for a record (and then all the DRCT, WRTR, etc), and I also know
how to use position() to access the corresponding sibling...

 <xsl:variable name="p" select="position()"/>
 <xsl:if test="$p>1"><xsl:text>, </xsl:text></xsl:if>
 <xsl:value-of select="ancestor::fmp:ROW/fmp:COL[$crew_name]/fmp:DATA[$p]"/>

... but I suspect these won't play together nicely because (eg) the
position() of the second producer (PRDC) in the first title would be "2",
and not "6", and thus ancestor::fmp:ROW/fmp:COL[$crew_name]/fmp:DATA[$p]
would grab the 2nd $crew_name of *all* the siblings, not the 2nd producer's
$crew_name.

Am I right? If so, how would I go about doing this?

e.

(ps, yes, I am really starting to hate Filemaker's XML export format)


-- 
Ironclad Networks
Information Architecture
http://www.ironclad.com.au/

"Providing tactical IA services to web agencies"


--~------------------------------------------------------------------
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>
--~--