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

seemingly simple transform, need idea how to do it.

Subject: seemingly simple transform, need idea how to do it.
From: "Carter, Will" <WCarter@xxxxxxxxxxxxxxxx>
Date: Tue, 8 Oct 2002 08:48:07 -0500
Here is my XML
   <person firstName="Johnny">
      <date day="2002-01-01">
	   <funThing>Ate Pizza</funThing>
	   <badThing>Hit Brother</badThing>
	<date day="2002-02-01">
	   <funThing>Bought Bike</funThing>
	   <badThing>Stole Candy</badThing>
	<date day="2002-03-01">
	   <funThing>Ran in Park</funThing>
	   <badThing>Skipped class</badThing>
   <person firstName="Billy">
      <date day="2002-01-01">
	   <funThing>Swam in lake</funThing>
	   <badThing>Told a lie</badThing>
	<date day="2002-02-01">
	   <funThing>Jumped on Tramp</funThing>
	   <badThing>Hid valuables</badThing>
	<date day="2002-03-01">
	   <funThing>Visited Disney</funThing>

Here is what I want in my output:

		Johnny FunThing 	Johnny BadThing 	Billy FunThing 	Billy BadThing 
2002-01-01 	Ate Pizza 		Hit Brother 	Swam in lake 	Told a lie 
2002-02-01 	Bought Bike 	Stole Candy 	Jumped on Tramp	Hid valuables 
2002-03-01 	Ran in Park 	Skipped class 	Visited Disney 	Cussed 

Here is my xsl that kinda works (shows correct output but sorting doesn't work):
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<table border="1">
	<td>Johnny FunThing</td>
	<td>Johnny BadThing</td>
	<td>Billy FunThing</td>
	<td>Billy BadThing</td>
   <xsl:for-each select="people/person/date[../@firstName = 'Johnny']">
   <xsl:sort select="@day" order="ascending" data-type="text"/>
   <xsl:variable name="pos" select="position()"/>
      <td><xsl:value-of select="@day"/></td>
      <td><xsl:value-of select="funThing"/></td>
      <td><xsl:value-of select="badThing"/></td>
      <td><xsl:for-each select="../../person/date[../@firstName = 'Billy'][position() = $pos]"><xsl:value-of select="funThing"/></xsl:for-each></td>
      <td><xsl:for-each select="../../person/date[../@firstName = 'Billy'][position() = $pos]"><xsl:value-of select="badThing"/></xsl:for-each></td>

I want to be able to sort on the Billy funThing or Billy badThing columns.  Seems like I am doing too much to set variable with position, jump out of that loop to get the Billy contents.

any help would be appreciated.


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

Current Thread


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.
First Name
Last Name
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.