xsl-list
[Top] [All Lists]

Re: fastest way to do projection in xsl

2002-11-07 04:16:26
What can I say Joerg!
Thanks a million this was exactly what I was looking for!

regards
  Kasper
----- Original Message -----
From: "Joerg Heinicke" <joerg(_dot_)heinicke(_at_)gmx(_dot_)de>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, November 07, 2002 2:01 AM
Subject: Re: [xsl] fastest way to do projection in xsl


Hello Kasper,

a nice and short stylesheet already solves your problem. It contains
only of the identity transformation template (copies everyting to the
output, that is matched), a template for all (to not copy the view) and
a template matching on the project elements, that contains the important
logic.

<xsl:template match="all">
     <xsl:apply-templates select="projects"/>
</xsl:template>

<xsl:template match="project">
     <xsl:copy>
         <xsl:variable name="thisProject" select="."/>
         <xsl:for-each select="/all/view/columns/measure">
             <xsl:apply-templates select="$thisProject/measure[(_at_)name =
current()/@name]"/>
         </xsl:for-each>
     </xsl:copy>
</xsl:template>

<xsl:template match="@*|node()">
     <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
</xsl:template>

I think it's easy to understand, isn't it?

Regards,

Joerg

Kasper Nielsen wrote:
Hello,

Basicly what im looking for is how to (fastest possible way) do a
project
(relational algebra) operation on a long list of relations in xsl

Let's say I have this document

<all>

    <view name="economy">
        <columns>
            <measure name="economy_estimate"/>
            <measure name="economy_actual"/>
            <measure name="responsible"/>
        </columns>
    </view>

    <projects>
        <project>
            <measure name="responsible"> kav </measure>
            <measure name="economy_actual">991233</measure>
            <measure name="economy_estimate">881123</measure>
            <measure name="schedule_actual">123</measure>
            <measure name="schedule_estimate">823</measure>
        </project>
        <project>
            <measure name="responsible"> pjc </measure>
            <measure name="economy_actual">77123123</measure>
            <measure name="economy_estimate">44123123</measure>
            <measure name="schedule_actual">723</measure>
            <measure name="schedule_estimate">923</measure>
        </project>
        ..... 100's of other projects....
    </projects>
</all>

how do I transform this document into something like this with xsl
The order between measures is as defined in the view part, ie (estimate
before actual) before responsible

<projects>
  <project>
    <measure name="economy_estimate">881123</measure>
    <measure name="economy_actual">991233</measure>
    <measure name="responsible"> kav </measure>
  </project>
  <project>
    <measure name="economy_estimate">44123123</measure>
    <measure name="economy_actual">77123123</measure>
    <measure name="responsible"> pjc </measure>
  </project>
</projects>


regards
  Kasper




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>