Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Node Grouping >Thread Next - Re: Node Grouping Re: Node GroupingTo: NULL Date: 6/3/2004 8:33:00 PM This is a multi-part message in MIME format.
------=_NextPart_000_002E_01C449A9.FF43F180
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
It is possible abter all :)
Following is the simplified example that should give you an idea:
-------------------------------------------------------------------------=
-------
XSL:
<xsl:stylesheet version=3D"1.0"
xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl=3D"urn:schemas-microsoft-com:xslt"
exclude-result-prefixes=3D"msxsl">
<xsl:template match=3D"/root">
<root>
<xsl:variable name=3D"trio">
<xsl:call-template name=3D"doA">
<xsl:with-param name=3D"this" select=3D"a[1]" />
<xsl:with-param name=3D"bCount" select=3D"0" />
</xsl:call-template>
</xsl:variable>
<xsl:for-each select=3D"msxsl:node-set($trio)//trio">
<set>
<xsl:copy-of select=3D"a"/>
</set>
</xsl:for-each>
</root>
</xsl:template>
<xsl:template name=3D"doA">
<xsl:param name=3D"this" />
<xsl:param name=3D"bCount" />
<xsl:if test=3D"$this">
<xsl:choose>
<xsl:when test=3D"count($this/b) < $bCount">
<xsl:copy-of select=3D"$this" />
<xsl:call-template name=3D"doA">
<xsl:with-param name=3D"this" =
select=3D"$this/following-sibling::a[1]" />
<xsl:with-param name=3D"bCount" select=3D"$bCount - count($this/b)" =
/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<trio>
<xsl:call-template name=3D"doA">
<xsl:with-param name=3D"this" select=3D"$this" />
<xsl:with-param name=3D"bCount" select=3D"4" />
</xsl:call-template>
</trio>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
=20
</xsl:stylesheet>
-------------------------------------------------------------------------=
-------
XML:
<root>
<a>
<b>1</b>
<b>2</b>
</a>
<a>
<b>3</b>
<b>4</b>
</a>
<a>
<b>5</b>
<b>6</b>
</a>
<a>
<b>7</b>
</a>
<a>
<b>8</b>
</a>
</root>
-------------------------------------------------------------------------=
-------
Output:
<root>
<set>
<a>
<b>1</b>
<b>2</b>
</a>
</set>
<set>
<a>
<b>3</b>
<b>4</b>
</a>
</set>
<set>
<a>
<b>5</b>
<b>6</b>
</a>
<a>
<b>7</b>
</a>
</set>
<set>
<a>
<b>8</b>
</a>
</set>
</root>
-------------------------------------------------------------------------=
-------
You just need to change a to Products/ProductsItem and b to =
Identifiers/Identifier
Have fun!
------=_NextPart_000_002E_01C449A9.FF43F180
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2096" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>It is possible abter all =
:)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Following is the simplified example =
that should=20
give you an idea:</FONT></DIV><FONT size=3D2>
<DIV><FONT face=3DArial>
<HR>
</FONT></DIV>
<DIV><FONT face=3DArial>XSL:</FONT></DIV>
<DIV></FONT><FONT face=3DArial size=3D2><xsl:stylesheet=20
version=3D"1.0"<BR> xmlns:xsl=3D"</FONT><A=20
href=3D"http://www.w3.org/1999/XSL/Transform"><FONT face=3DArial=20
size=3D2>http://www.w3.org/1999/XSL/Transform</FONT></A><FONT =
face=3DArial=20
size=3D2>"<BR> xmlns:msxsl=3D"urn:schemas-microsoft-com:xslt"<BR>&nb=
sp;exclude-result-prefixes=3D"msxsl"></FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT size=3D2></FONT><FONT size=3D2></FONT><BR><FONT face=3DArial=20
size=3D2><xsl:template=20
match=3D"/root"><BR><root><BR> <xsl:variable=20
name=3D"trio"><BR> <xsl:call-template=20
name=3D"doA"><BR> <xsl:with-param name=3D"this" =
select=3D"a[1]"=20
/><BR> <xsl:with-param name=3D"bCount" =
select=3D"0"=20
/><BR> </xsl:call-template><BR> </xsl:variabl=
e><BR> <xsl:for-each=20
select=3D"msxsl:node-set($trio)//trio"><BR> <set><BR>=
<xsl:copy-of=20
select=3D"a"/><BR> </set><BR> </xsl:for-each&=
gt;<BR></root><BR></xsl:template></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><xsl:template=20
name=3D"doA"><BR> <xsl:param name=3D"this" =
/><BR> <xsl:param=20
name=3D"bCount" /><BR> <xsl:if=20
test=3D"$this"><BR> <xsl:choose><BR>  =
;<xsl:when=20
test=3D"count($this/b) &lt;=20
$bCount"><BR> <xsl:copy-of select=3D"$this" =
/><BR> <xsl:call-template=20
name=3D"doA"><BR> <xsl:with-param =
name=3D"this"=20
select=3D"$this/following-sibling::a[1]"=20
/><BR> <xsl:with-param =
name=3D"bCount"=20
select=3D"$bCount - count($this/b)" </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial=20
size=3D2>/><BR> </xsl:call-template><BR>&=
nbsp; </xsl:when><BR> <xsl:otherwise=
><BR> <trio><BR> &=
nbsp;<xsl:call-template=20
name=3D"doA"><BR> <xsl:with-para=
m=20
name=3D"this" select=3D"$this"=20
/><BR> <xsl:with-param =
name=3D"bCount"=20
select=3D"4"=20
/><BR> </xsl:call-template><BR>&nbs=
p; </trio><BR> </xsl:otherwise=
><BR> </xsl:choose><BR> </xsl:if><BR></=
xsl:template><BR> <BR></xsl:stylesheet></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>
<HR>
XML:</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial><FONT=20
size=3D2><root><BR><a><BR> <b>1</b><BR> =
;<b>2</b><BR></a><BR><a><BR> <b>3</=
b><BR> <b>4</b><BR></a><BR><a><BR> &=
lt;b>5</b><BR> <b>6</b><BR></a><BR><a&=
gt;<BR> <b>7</b><BR></a><BR><a><BR> <=
;b>8</b><BR></a><BR></root><BR></FONT><FONT=20
size=3D2>
<HR>
Output:</FONT></FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT face=3DArial =
size=3D2><root></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
<set></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>1</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>2</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
</a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
</set></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> <set></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>3</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>4</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
</a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
</set></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
<set></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>5</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>6</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
</a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>7</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
</a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
</set></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
<set></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
<b>8</b></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
</a></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
</set></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></root><BR>
<HR>
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT size=3D2><FONT size=3D3>
<DIV><FONT face=3DArial size=3D2>You just need to change a to =
Products/ProductsItem=20
and b to Identifiers/Identifier</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Have=20
fun!</FONT></DIV></FONT></DIV></FONT></DIV></DIV></BODY></HTML>
------=_NextPart_000_002E_01C449A9.FF43F180--
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
