[Home] [By Thread] [By Date] [Recent Entries]
At 2006-07-18 17:24 -0400, Steve wrote:
Well after success with my first recursive template I was all set to make one of my own, but now shamefully am coming to the list for advice over something that appears quite simple.
. . . . . . . . . Ken T:\ftemp>type steve.xml
<?xml version="1.0" encoding="US-ASCII"?>
<data>
<options>
<o type="A">who</o>
<o type="A">what</o>
<o type="A">when</o>
<o type="B">how</o>
<o type="B">nexus</o>
<o type="B">triumph</o>
<o type="C">alligator</o>
<o type="C">spurn</o>
</options>
<people>
<person pref="who" />
<person pref="nexus" />
<person pref="how" />
<person pref="alligator" />
<person pref="spurn" />
<person pref="triumph" />
.... etc ....
</people>
</data>T:\ftemp>type steve.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:steve="urn:x-steve"
version="1.0"><xsl:output indent="yes"/> <xsl:template match="/data"> <xsl:variable name="people" select="people/person"/> <xsl:variable name="options" select="options/o"/> <output>
<xsl:for-each select="$options">
<xsl:sort select="@type"/>
<xsl:if test="generate-id(.)=
generate-id($options[@type=current()/@type][1])">
<out type="{@type}"
count="{count($people[@pref=$options[@type=current()/@type]])}"
/>
</xsl:if>
</xsl:for-each>
</output>
</xsl:template></xsl:stylesheet> T:\ftemp>xslt steve.xml steve.xsl con <?xml version="1.0" encoding="utf-8"?> <output xmlns:steve="urn:x-steve"> <out type="A" count="1"/> <out type="B" count="3"/> <out type="C" count="2"/> </output> T:\ftemp>
|

Cart



