Subject: Re: [xsl] XSL menu using multiple row HTML table From: "Joerg Heinicke" <joerg.heinicke@xxxxxx> Date: Wed, 27 Feb 2002 22:21:51 +0100 |
Hello Lea, you may not do the for-each about all elements, but about every 8th (or $max'th) element. If you know them you have still to loop over the current element and the next 7 ones (or $max -1). <xsl:for-each select="*[position() mod $max = 1]"> <tr> <xsl:for-each select=" . | following-sibling::*[position() < $max]"> <xsl:apply-templates select="NAME"/> </xsl:for-each> </tr> </xsl:for-each> Regards, Joerg ----- Original Message ----- From: "Lea Allison" <Lea.Allison@xxxxxxxxxxxxxx> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, February 27, 2002 4:26 PM Subject: [xsl] XSL menu using multiple row HTML table > Hello > > I've have a problem that has had me up for 2 days, and I've learnt alot, but > now my head is just busting... I need help! > > I am trying to create a template that will convert my XML menu doc (extract > below) into an HTML menu. The menu I wont is the horizontal type, and the > real problem I have is selecting the number of menu items per row. > > I cannot figure out how to get the stylesheet to read the first X number of > items in, then start a new row, and another until complete. I cannot use > "for-each" to split the <TR> and </TR> tags without creating bad XML... and > using named templates recursively loses me when one row is complete and I > want to continue my proccessing on the newxt row. > > OK, here is a snippet of the source XML: > > <LIBRARY> > <WEB> > <HOME isCategory="yes"> > <NAME>Home</NAME> > <DESCRIPTION>Virgin Home page</DESCRIPTION> > </HOME> > <VIRGININFO isCategory="yes" icon="" hide="no"> > <NAME>Virgin Info</NAME> > <DESCRIPTION>Virgin commercial > information</DESCRIPTION> > <CORPORATE isCategory="yes" icon="" > hide="no"> > <NAME>Corporate</NAME> > <DESCRIPTION>Corporate > information</DESCRIPTION> > </CORPORATE> > </VIRGININFO> > ... ... > <TEST> > <NAME>LEA</NAME> > </TEST> > </WEB> > </LIBRARY> > > I don't think this is the best way for trying to do this job, but the reason > is that I'm using XPath from my app to access these items... I'll get round > that, but here's my problem. This what I've got after 2 days deleting and > re-writing so please ignore this if it is completly wrong: > > <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:output method="html"/> > > <xsl:template match="/"> > > <HTML><BODY> > <TABLE border="1" width="100%"> > > <xsl:apply-templates select="LIBRARY/WEB" /> > > </TABLE> > </BODY> > </HTML> > > </xsl:template> > > <xsl:template match="LIBRARY/WEB"> > > <xsl:param name="max">8</xsl:param> <!-- MAX ITEMS PER TABLE ROW --> > > <TR> > <xsl:for-each select="*"> > <xsl:choose> > <xsl:when test="position() -1 < $max"> > > <xsl:apply-templates select="NAME" /> > > </xsl:when> > </xsl:choose> > </xsl:for-each> > </TR> > <!-- xsl:apply-templates select="//LIBRARY/WEB" / > --> <!-- !!!! err ? --> > </xsl:template> > > <xsl:template match="NAME"> > <TD><B><xsl:apply-templates /></B></TD> > </xsl:template> > > <xsl:template match="*" /> > </xsl:stylesheet> > > > Cheers!! > > Lea > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSL menu using multiple row H, Lea Allison | Thread | [xsl] XSL menu using multiple row H, Lea Allison |
Re: [xsl] Looking for a great tutor, Joerg Heinicke | Date | Re: [xsl] Value-of, copy-of, Wendell Piez |
Month |