Subject: RE: [xsl] XSL-T should naturally loop? not grabbing all the children node-sets.. From: "Dan Acuff" <dacuff@xxxxxxxxxxxxxx> Date: Tue, 22 Apr 2008 11:57:58 -0400 |
Ok let me try again and I will once again post the test xml at the end. When they use the left menu and it has a flyout menu, that means there are children. So when the Click the parent on the first menu level that means we want them to land on a category page where we creat an independent div for EACH child category. As you can see in the example XML this occurs 3 distinct times. 2 times at the Sub category level. And once, at the sub-sub-category level. For now we don't have to worry about a sub-sub-sub potential flyout in future designs... The value that is passed in $paraCatagory for the very first sub menu is "c1_products" This means I am able to "FIND" the category PARENT node-set in the XML. from their I simple want to traverse through all children elements and create div's for them. HOw is this done in XSLT 1.0? Thanks so much. Daniel <?xml version="1.0" encoding="iso-8859-1"?> <menu id="menuData"> <!--™ trademark--> <!--® registered--> <category name="c1_products" display_name="Category One"> <info> <keyword>C1</keyword> <link>/category/c1_products</link> <titletag>C1 Products from our store - 9 Words for best SEO</titletag> <images> <image/> </images> </info> <category name="c1_sub1_products" display_name="sub-Category c1_sub1"> <info> <keyword>C1SUB1</keyword> <link>/products/c1_products/c1_sub1_products</link> <titletag>C1SUB1 Products from our store - 9 Words for best SEO</titletag> <images> <image>/imagesEdp/default_sm.jpg</image> </images> </info> </category> </category> <category name="c2_products" display_name="Category Two"> <info> <keyword>C2</keyword> <link>/category/c2_products</link> <titletag>C2 Products from our store - 9 Words for best SEO</titletag> <images> <image/> </images> </info> <category name="c2_sub1_products" display_name="sub-Category c2_sub1"> <info> <keyword>C2SUB1</keyword> <link>/products/c2_products/c2_sub1_products</link> <titletag>C2SUB1 Products from our store - 9 Words for best SEO</titletag> <images> <image>/imagesEdp/default_sm.jpg</image> </images> </info> </category> <category name="c2_sub2_products" display_name="sub-Category c2_sub2"> <info> <keyword>C2SUB2</keyword> <link>/products/c2_products/c2_sub2_products</link> <titletag>C2SUB2 Products from our store - 9 Words for best SEO</titletag> <images> <image>/imagesEdp/default_sm.jpg</image> </images> </info> </category> <category name="c2_sub3_products" display_name="sub-Category c2_sub3"> <info> <keyword>C2SUB3</keyword> <link>/category/c2_products/c2_sub3_products</link> <titletag>C2SUB3 Products from our store - 9 Words for best SEO</titletag> <images> <image>/imagesEdp/default_sm.jpg</image> </images> </info> <category name="c2_sub_sub1_products" display_name="sub-sub-Category c2_sub_sub1"> <info> <keyword>C2SUBSUB1</keyword> <link>/products/c2_products/c2_sub3_products/c2_sub_sub1_products</link> <titletag>C2SUBSUB1 Products from our store - 9 Words for best SEO</titletag> <images> <image>/imagesEdp/default_sm.jpg</image> </images> </info> </category> <category name="c2_sub_sub2_products" display_name="sub-sub-Category c2_sub_sub2"> <info> <keyword>C2SUBSUB2</keyword> <link>/products/c2_products/c2_sub3_products/c2_sub_sub2_products</link> <titletag>C2SUBSUB2 Products from our store - 9 Words for best SEO</titletag> <images> <image>/imagesEdp/default_sm.jpg</image> </images> </info> </category> </category> </category> <category name="c3_products" display_name="Category Three"> <info> <keyword>C3</keyword> <link>/products/c3_products</link> <titletag>C3 Products from our store - 9 Words for best SEO</titletag> <images> <image/> </images> </info> </category> <category name="c4_products" display_name="Category Four"> <info> <keyword>C4</keyword> <link>/products/c4_products</link> <titletag>C4 Products from our store - 9 Words for best SEO</titletag> <images> <image/> </images> </info> </category> <category name="c5_products" display_name="Category Five"> <info> <keyword>C5</keyword> <link>/products/c5_products</link> <titletag>C5 Products from our store - 9 Words for best SEO</titletag> <images> <image/> </images> </info> </category> <category name="c6_products" display_name="Category Six" display="no"> <info> <keyword>C6</keyword> <link>/products/c6_products</link> <titletag>C6 Products from our store - 9 Words for best SEO</titletag> <images> <image/> </images> </info> </category> </menu> -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Tuesday, April 22, 2008 11:49 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] XSL-T should naturally loop? not grabbing all the children node-sets.. > What do I need to do differently that I am not understanding? <xsl:template match="category"> <xsl:choose> <xsl:when test="(@name=$paraCatagory)"> <div class="cat_block"> <div class="cat_module"> <xsl:value-of select="category/@display_name"/> here you have match="category"> so the current node is a categoiry element so the select="category is selecting child nodes of category that are also called category, You select all such children but (in xslt 1) value-of will just give you the string value of the first node selected. Noweher do yo iterate through the child catagories with xsl:apply-templates or xsl:for-each, so it's not clear why you expect to loop over these, probably you want to apply-templates to the child elemsnts but not knowing what output you want I can't really suggest any code changes. As Michael said this will do nothing if the global parameter does not match the name on the outer element, David
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL-T should naturally lo, David Carlisle | Thread | Re: [xsl] XSL-T should naturally lo, David Carlisle |
RE: [xsl] XSL-T should naturally lo, Dan Acuff | Date | Re: [xsl] XSL-T should naturally lo, David Carlisle |
Month |