|
Subject: Re: [xsl] Dmoz xml structure sort From: Robert Koberg <rob@xxxxxxxxxx> Date: Sun, 18 Apr 2004 07:15:07 -0700 |
<topic id="t123" name="Base">
<Title local="en-US">Home</Title>
<topic id="t234" name="General_Information">
<topic id="t345" name="About_us"> </
<topic id="t346" name="Contact_us"></ </ </
<xsl:variable
name="focus_topic"
select="key('topics', $focus_topic_id)"/><xsl:variable
name="focus_parent"
select="key('topics', $focus_parent_id)"/><xsl:template match="/">
<html>
<xsl:call-template name="head"/>
<body>
<div id="pageBody">
<xsl:call-template name="banner"/> <xsl:apply-templates
select="$focus_parent/*"
mode="navigation"/> <div id="contentWrapper">
<xsl:appl
<xsl:call-template name="footer"/>
</div>
</body>
</html>
</xsl:template>
<!-- match the children of the focus parent--> <xsl:template match="*" mode="navigation">
<xsl:variable name="href">
<xsl:call-template name="topic_path_builder"/>
</ <xsl:choose>
<xsl:when test="not(@id=$focus_topic_id)">
<div>
<a href="{$href}">
<xsl:value-of select="@label"/>
</a>
</div>
</
<xsl:otherwise>
<div class="selected">
<a href="{$href}">
<xsl:value-of select="@label"/>
</a>
</div>
</
</
</<xsl:template name="topic_path_builder"> <xsl:call-template name="ancestor_path"/> <xsl:text>/</xsl:text> <xsl:value-of select="@name"/> </xsl:template>
<!-- root relative paths, you could do document relative paths too-->
<xsl:template name="ancestor_path">
<xsl:for-each select="ancestor::*">
<xsl:text>/</xsl:text>
<xsl:value-of select="@name"/>
</xsl:for-each>
</xsl:template>best, -Rob
Hi all. I have a navigational site tree xml page similar to Dmoz.org. And its made up like this below. I am new to xpath and am having problems finding a solution to this.
My file looks similar to this.
<Topic id="Base"> <tag catid="1"/> <Title local="en-US">Home</Title> <narrow resource="Base/General_Information"/> <narrow resource="Base/StudentLife"/> <narrow resource="Base/Missions"/> <narrow resource="Base/Community"/> <narrow resource="Base/Academics"/> <narrow resource="Base/News"/> </Topic> <Topic id="Base/General_Information"> <tag catid="2"/> <Title local="en-US">General Information</Title> <narrow resource="Base/General_Information/About_us"/> <narrow resource="Base/General_Information/Contact_us"/> <narrow resource="Base/General_Information/Directors_Letter"/> <narrow resource="Base/General_Information/History"/> <narrow resource="Base/General_Information/What_We_Beleive"/> <narrow resource="Base/General_Information/Staff_Directory"/> </Topic> <Topic id="Base/General_Information/About_us"> <tag catid="8"/> <Title local="en-US">About Us</Title> </Topic> <Topic id="Base/General_Information/Contact_us"> <tag catid="9"/> <Title local="en-US">Contact Us</Title> </Topic> ... ... ...
And I want to acheave results like this if I had a dynamic variable like "Base/General_Information/About_us"
<Topic id="Base/General_Information/About_us"> <tag catid="8"/> <Title local="en-US">About Us</Title> </Topic> <Topic id="Base/General_Information/Contact_us"> <tag catid="9"/> <Title local="en-US">Contact Us</Title> </Topic> <Topic id="Base/General_Information/Directors_Letter"> <tag catid="10"/> <Title local="en-US">Letter From the Director</Title> </Topic> <Topic id="Base/General_Information/History"> <tag catid="11"/> <Title local="en-US">History</Title> </Topic> <Topic id="Base/General_Information/What_We_Beleive"> <tag catid="12"/> <Title local="en-US">What We Beleive</Title> </Topic> <Topic id="Base/General_Information/Staff_Directory"> <tag catid="13"/> <Title local="en-US">Staff Directory</Title> </Topic>
Can someone point me in the right direction? john
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Dmoz xml structure sort, John Hamman | Thread | [xsl] Ideal XML Site tree layout, John Hamman |
| RE: [xsl] Dmoz xml structure sort, John Hamman | Date | [xsl] select unique name, Sylwester Lesniak |
| Month |