xsl-list
[Top] [All Lists]

Another Grouping question

2005-02-17 05:07:14
Hello,

Thank you to those who responded to my previous question.

I now realise that the key to a lot of my current problems are to create the
correct groupings.

Before coming back to the list I spent a lot of time reading Michael Kay's
Programmer Reference but I'm still struggling with constructing the correct
predictate.

I have the following XML:

<frag>
        <p/>
        <p/>
        <table/>
        <list/>
        <marker/>
        <p/>
        <p/>
        <p/>
        <p/>
        <table/>
        <p/>
        <p/>
        <table/>
        <list/>
        <marker/>
        <p/>
        <p/>
        <table/>
        <list/>
</frag>

I need to create a grouping that selects a marker element followed by all
its siblings up but not including to the next marker.

An attempted solution is shown below, but it didn't work. (No chuckling
please).

I've tried to do this by creating a template that matches a marker and then
calculating the position of the following-sibling::marker and placing this
in a variable. I then try to group all the required elements by testing for
the position of the context being less than the next marker.

<xsl:template match="marker">
        <xsl:variable name="next-marker"
select="following-sibling::marker[1]"/>
        <xsl:variable name="chunk" select=". |
following-sibling::*[position()&lt; $next-marker]"/>
        <div>
                <mblock><xsl:apply-templates select="$chunk"/></mblock>
        </div>
</xsl:template>

Thanks

Paul Clarke 





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