Subject: [xsl] Tranforming XML into heirarchy XML and use it for tree menu From: Radoslav Kolarov <roonex@xxxxxxxxx> Date: Sat, 22 Jul 2006 15:41:17 -0700 (PDT) |
I have idea to resolve the problem, but I'm not sure is it possible. For tree menu I will use http://www.codeproject.com/soap/treefromxmlusingxslt.asp, but to use it first have to tranform XML from this: <?xml version="1.0" ?> - <records> - <record> <keynum>-1</keynum> <keyname>2 CLIENTS HAVE A NEGATIVE BALANCE</keyname> <parentkeynum>-100000</parentkeynum> <rowcnt>2</rowcnt> <balance>0</balance> </record> - <record> <keynum>35</keynum> <keyname>35 MR. MICHAEL NOLAN</keyname> <parentkeynum>-1</parentkeynum> <rowcnt>1</rowcnt> <balance>-275</balance> </record> - <record> <keynum>142</keynum> <keyname>142 MR. JOHN CALINSKI</keyname> <parentkeynum>-1</parentkeynum> <rowcnt>1</rowcnt> <balance>-11</balance> </record> - <record> <keynum>-3</keynum> <keyname>42 CLIENTS CREDIT IS GREATER THAN BALANCE</keyname> <parentkeynum>-100000</parentkeynum> <rowcnt>42</rowcnt> <balance>0</balance> </record> ........ ........ ........ - <record> <keynum>10006</keynum> <keyname>10006 MR. DALE SPONSEL 2003-04-24</keyname> <parentkeynum>-16</parentkeynum> <rowcnt>1</rowcnt> <balance>0</balance> </record> - <record> <keynum>-100003</keynum> <keyname>APPOINTMENT ALERTS (1)</keyname> <parentkeynum>0</parentkeynum> <rowcnt>1</rowcnt> <balance>0</balance> </record> - <record> <keynum>-100002</keynum> <keyname>HAIR SYSTEM ALERTS (2)</keyname> <parentkeynum>0</parentkeynum> <rowcnt>2</rowcnt> <balance>0</balance> </record> - <record> <keynum>-100001</keynum> <keyname>PROGRAM ALERTS (2)</keyname> <parentkeynum>0</parentkeynum> <rowcnt>2</rowcnt> <balance>0</balance> </record> - <record> <keynum>-100000</keynum> <keyname>FINANCIAL ALERTS (5)</keyname> <parentkeynum>0</parentkeynum> <rowcnt>5</rowcnt> <balance>0</balance> </record> </records> to this: <?xml version="1.0" ?> - <records> - <record> <keynum>-100003</keynum> <keyname>APPOINTMENT ALERTS (1)</keyname> <parentkeynum>0</parentkeynum> <rowcnt>1</rowcnt> <balance>0</balance> - <record> <keynum>-16</keynum> <keyname>16 CLIENTS HAVE NOT VISITED IN THE LAST 90 days</keyname> <parentkeynum>-100003</parentkeynum> <rowcnt>16</rowcnt> <balance>0</balance> - <record> <keynum>141</keynum> <keyname>141 MR. SCOTT CRAMER 2003-04-19</keyname> <parentkeynum>-16</parentkeynum> <rowcnt>1</rowcnt> <balance>0</balance> </record> - <record> <keynum>176</keynum> <keyname>176 MR. WILLIAM CUEVAS 2003-05-01</keyname> <parentkeynum>-16</parentkeynum> <rowcnt>1</rowcnt> <balance>430</balance> </record> </record> </record> </records> Where XML is now 3 level heirarchy XML - First level records with perenkeynum 0, second level with parenkeynum=keynum furst level, and third level with parentkeynum=keynum second level. This is my idea for xsl file: <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/records"> ........ <!--This template transform XML into heirarchy XML--> ........ <!--And now i want to use heirarchy XML to make dynamic tree menu--> <xsl:call-template name="one"> </xsl:call-template> </xsl:template> <xsl:template name="one"> <xsl:for-each select="//records/record"> <xsl:call-template name="SubMenu"> <xsl:with-param name="strCSS">Parent IsVisible</xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template name="SubMenu"> <xsl:param name="strCSS" /> <div class="{$strCSS}"> <xsl:choose> <xsl:when test="count(record) > 0"> <!-- Element has children, it can be expanded --> <input type="hidden" id="hidIsExpanded" value="0" /> <label id="lblExpand" class="Expander" onclick="ExpanderClicked()">+ </label> </xsl:when> <xsl:otherwise> <label class="Expander">  </label> </xsl:otherwise> </xsl:choose> <a><xsl:value-of select="keyname" /></a> <xsl:for-each select="record"> <xsl:call-template name="SubMenu"> <xsl:with-param name="strCSS">NotVisible</xsl:with-param> </xsl:call-template> </xsl:for-each> </div> </xsl:template> </xsl:stylesheet> And with ASP file I can make dynamic tree menu. The ASP file you can see at http://www.codeproject.com/soap/treefromxmlusingxslt.asp I have 2 questions: Is it possible this idea? How to write first tepmlate who makes heirarchy XML? Please help me __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to make tree menu from fl, Radoslav Kolarov | Thread | [xsl] Convert an HTML DOM node to X, Lindsey Simon |
[xsl] Multiple Grouping & Muenchian, Steve Sze | Date | Re: [xsl] How to make tree menu fro, Mukul Gandhi |
Month |