XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Ben BabicsSubject: Creating HTML Unordered LIsts. HELP!
Author: Ben Babics
Date: 27 Apr 2009 07:02 AM
Originally Posted: 26 Apr 2009 10:53 PM
Hello,

I'm having a bit of trouble with this one. Although, I'm sure it may not be too difficult for some XSL guru's. Anyways, I'm hoping I can get some answers; any help is much appreciated. :)

I'm working on a project where I need a navigation (2-tier, sub-menu's etc.), a sectional navigation on each page (this is for user's who have JavaScript disabled and need to view the submenu for the section relative to the page their currently on), a footer and a sitemap.

I decided to circumvent a maintenance nightmare by using a single XML file to hold the data and write XSL Style Sheets for each section: navigation.xsl, subnav.xsl (subnavigation on each page), footer.xsl and sitemap.xsl. Hopefully you're still with me.

Really each XSL will be generating an HTML unordered list(s), but each list will be slightly different from the other list(s)- there in lies the problem. :)

***********************
**** site_data.xml ****
***********************
<sitemap>
<pages>
<page title="Home" src="/www/" />
<page title="Business" src="/www/business/">
<pages>
<page title="Business 1" src="business1.html" />
<page title="Business 2" src="business2.html" />
</pages>
</page>
</pages>
<page title="About Us" src="/www/about/">
<pages>
<page title="About 1" src="about1.html" />
<page title="About 2" src="about2.html" />
</pages>
</page>
<page title="Contact Us" src="/www/contact/" />
</pages>
</sitemap>

The issue I'm having is that for the navigation, I need to derive two unordered lists from this. The first: Home and Business. The second: About Us and Contact Us.

**********************
****navigation.xsl****
**********************
<xsl:template match="pages">
<xsl:choose>
<xsl:when test="page[@title = 'About Us' or @title = 'Contact Us']">
<ul>
<xsl:apply-templates select="page" />
</ul>
</xsl:when>
<xsl:otherwise>
<ul>
<xsl:apply-templates select="page" />
</ul>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="page">
<xsl:variable name="path">
<xsl:value-of select="../../@src" /><xsl:value-of select="@src" />
</xsl:variable>

<li>
<a href="{$path}"><xsl:value-of select="@title" /></a>
<xsl:apply-templates select="pages" />
</li>
</xsl:template>

You'll notice that I am traversing the node list to do proper nesting. However, I'm having a very difficult time determining how to initially create two separate unordered lists and have the proper nodes be populated within their respective list.

PLEASE HELP!!! :)

Thanks,
Ben


Documentsite_data.xml
site_data.xml

Documentnavigation.xsl
navigation.xsl

Posttop
Tony LavinioSubject: Creating HTML Unordered LIsts. HELP!
Author: Tony Lavinio
Date: 27 Apr 2009 08:19 AM
General XSLT questions are better asked on the xsl-list forum run by
Mulberry Technologies. There is a wider audience, since this list here
is only for Stylus Studio customers, but the xsl-list includes ourselves
and the XSLT community at large.

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.