[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSL DATA STRUCTURE PROBLEM

Subject: RE: XSL DATA STRUCTURE PROBLEM
From: Jarno.Elovirta@xxxxxxxxx
Date: Fri, 17 Jan 2003 09:53:38 +0200
xsl data
Hi,

[snip]

> THe problem guys is that i need to have a list of the holiday 
> destination in 
> every user, The data that i need to be produced is

Your problem is a grouping one, and keys will help you:

<xsl:key name="id" match="fmp:ROW" use="fmp:COL[1]/fmp:DATA" />

<xsl:template match="fmp:FMPXMLRESULT">
  <UserProgram xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="C:\xmldocs\csdaschema.xsd">
    <Users>

      <xsl:for-each select="fmp:RESULTSET/fmp:ROW[generate-id() = generate-id(key('id', fmp:COL[1]/fmp:DATA))]">
        <xsl:if test="fmp:COL[1]/fmp:DATA != ''">
          <User>
            <xsl:attribute name="RecordId">
              <xsl:value-of select="fmp:COL[1]/fmp:DATA"/>
            </xsl:attribute>
            <PersonID>
              <xsl:value-of select="fmp:COL[1]/fmp:DATA"/>
            </PersonID>
            <FirstName>
              <xsl:value-of select="fmp:COL[2]/fmp:DATA"/>
            </FirstName>
            <LastName>
              <xsl:value-of select="fmp:COL[3]/fmp:DATA"/>
            </LastName>
            <xsl:call-template name="servicers_builder">
              <xsl:with-param name="i_person_id" select="fmp:COL[1]/fmp:DATA" />
            </xsl:call-template>
          </User>
          <xsl:variable name="vRecordID">
            <xsl:value-of select="fmp:COL[28]/fmp:DATA"/>
          </xsl:variable>
        </xsl:if>
      </xsl:for-each>
    </Users>
  </UserProgram>
</xsl:template>

<xsl:template name="servicers_builder">
  <xsl:param name="i_person_id"/>

  <HolidayDestinations>
    <!-- ...selecting all the records for this user... -->
    <xsl:for-each select="key('id', $i_person_id)">
      <!-- ...and building a service for each -->
      <HolidayDestination>
        <xsl:value-of select="fmp:COL[4]/fmp:DATA"/>
      </HolidayDestination>
    </xsl:for-each>
  </HolidayDestinations>
</xsl:template>

See Jeni's pages for info on Muenchian Grouping.

Cheers,

Jarno - Biotek: Die Sect (VNV Nation Remix)

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.