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

Re: XSLT real time use of XML to XML Transformation (U

Subject: Re: XSLT real time use of XML to XML Transformation (Updated Querry)
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 10 Jun 2003 18:18:54 -0400
Re:  XSLT real time use of XML to XML Transformation (U
Hi Heath (Allison?),

I'm afraid I can't debug your code since the approach you take is so far from the one I would prefer ... which is simpler and easier, but which might come across as an "advanced" technique to an XSLT newcomer.

Briefly, it is to see your problem as a grouping problem (which it is). If it were me, I'd make a key like so:

<xsl:key name="data-by-agent" match="CLIENTDATA" use="generate-id(preceding-sibling::USER[1])"/>

Then I'd do something like:

<xsl:template match="CLIENTDATA"/>
<!-- suppresses processing of CLIENTDATA nodes on regular traversal -->

<xsl:template match="USER">
  <AGENT>
    <xsl:variable name="thisagentdata"
      select="key('data-by-agent', generate-id())"/>
    <!-- the variable is bound to the three CLIENTDATA nodes belonging to
         this USER -->
    <AGENTNAME><xsl:value-of select="."/></AGENTNAME>
    <AGENTID>
      <xsl:value-of select="$thisagentdata[1]"/>
    </AGENTID>
    <AGENTAGE>
      <xsl:value-of select="$thisagentdata[2]"/>
    </AGENTAGE>
    <AGENTSTATUS>
      <xsl:value-of select="$thisagentdata[3]"/>
    </AGENTSTATUS>
  </AGENT>
</xsl:template>

An excellent guide to grouping problems may be found at www.jenitennison.com. Using keys (the <xsl:key/> declaration and the key() function) are documented in the spec and in any reasonably decent how-to book on XSLT.

I hope this helps,
Wendell

At 04:29 PM 6/10/2003, you wrote:
I've made some progress hacking away at my problem using information I found in the archives, but I'm still stuck on a few points....



====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


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.