Subject: [xsl] getting all parent elements for breadcrumb nav From: Nathan Shaw <n8_shaw@xxxxxxxxx> Date: Tue, 16 Dec 2003 08:18:52 -0800 (PST) |
Hi all and happy holidays! I am working on an application that uses the xbel dtd for a set of bookmarks. In the xslt I am writing, I want to create a breadcrumb navigation item at the top so that the user can walk up and down the folders. I pass in a folderID in the xml so that I can show the proper folder and need to somehow grab all of that folder's parent elements and put them into a breadcrumb navigation line (Top folder > sub folder > sub folder). Any ideas on how to do this? Seems to me it will require a named template, but I can't quite seem to wrap my head around it. Thanks in advance for the help! Here are the xml and xslt: XML: <!--<!DOCTYPE xbel SYSTEM "E:\documents\saic\cvs\CodeU\cu_extranet\info\bookmarks\xbel.dtd">--> <xbel xmlns="http://www.python.org/topics/xml/xbel/" id="i29dbb8f93d3f44167ffe" version="1.0"> <folder xmlns="" added="11/01/2003" id="i1a16869f8a24ec9ee8000" folded="no"> <title>Bookmarks</title> <desc>Bookmarks for the Code U Extranet</desc> <folder xmlns="" added="11/01/2003" id="i1a16869f8a24ec9ee8001" folded="no"> <title>Required Bookmarks</title> <bookmark href="http://www.nasa.gov" added="11/01/2003" id="i1a16869f8a24f2aac8000" modified="11/01/2003"> <title>NASA Web Site</title> <info> <metadata owner="http://spaceresearch.nasa.gov/extranet"/> </info> <desc>NASA home page.</desc> </bookmark> <folder xmlns="" added="11/01/2003" id="i1a16869f8a253944f8000" folded="yes"> <title>Code U</title> <bookmark href="http://spaceresearch.nasa.gov" added="11/01/2003" id="i1a16869f8a24fa4708000" modified="11/01/2003"> <title> Public Web Site</title> <info> <metadata owner="http://spaceresearch.nasa.gov/extranet"/> </info> <desc>Code U Public Web Site, or spaceresearch.nasa.gov</desc> </bookmark> <bookmark href="http://research.hq.nasa.gov/code\_u/code\_u.cfm" added="11/01/2003" id="i1a16869f8a24fd38e8000" modified="11/01/2003"> <title>Research Opportunities</title> <info> <metadata owner="http://spaceresearch.nasa.gov/extranet"/> </info> <desc>Code U research opportunities</desc> </bookmark> <bookmark href="http://research.hq.nasa.gov/taskbook.cfm" added="11/01/2003" id="i1a16869f8a24ff83d8000" modified="11/01/2003"> <title>Research Task Book</title> <info> <metadata owner="http://spaceresearch.nasa.gov/extranet"/> </info> <desc>Code U research task book</desc> </bookmark> <bookmark href="http://spd.nasa.gov/sourcebook/" added="11/01/2003" id="i1a16869f8a250146f8000" modified="11/01/2003"> <title>Space Product Development</title> <info> <metadata owner="http://spaceresearch.nasa.gov/extranet"/> </info> <desc>Code U space product development</desc> </bookmark> <bookmark href="http://commercial.hq.nasa.gov/" added="11/01/2003" id="i1a16869f8a25347688000" modified="11/01/2003"> <title>Space Commercialization</title> <info> <metadata owner="http://spaceresearch.nasa.gov/extranet"/> </info> <desc>Code U space commercialization</desc> </bookmark> <bookmark href="http://intranet.hq.nasa.gov/basis\_codeu/main\_LIF.cfm" added="11/01/2003" id="i1a16869f8a259ca668000" modified="11/01/2003"> <title>DMS</title> <info> <metadata owner="http://spaceresearch.nasa.gov/extranet"/> </info> <desc>Code U document management system</desc> </bookmark> </folder> </folder> <folder xmlns="" id="i1ea2dfef93cd9a9d58000" folded="no"> <title>My Bookmarks</title> <folder xmlns="" id="i1ea2dfef93cd9a9d58001" folded="no"> <title>My Bookmarks Subfolder</title> </folder> </folder> </folder> <supplementalData xmlns=""> <imagePath>http://localhost:8080/cu_extranet/resources/images/</imagePath> <reqPermission>false</reqPermission> <webPath>http://localhost:8080/cu_extranet/servlet/cu_extranet/</webPath> <folderID>i1a16869f8a253944f8000</folderID> </supplementalData> </xbel> XSLT: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xbel="http://www.python.org/topics/xml/xbel/"> <xsl:output method="html" version="1.0" encoding="iso-8859-1" indent="yes" omit-xml-declaration="yes" /> <xsl:strip-space elements="*" /> <xsl:variable name="webPath" select="normalize-space(/xbel:xbel/supplementalData/webPath)" /> <xsl:variable name="imagePath" select="normalize-space(/xbel:xbel/supplementalData/imagePath)" /> <xsl:variable name="folderID"> <xsl:choose> <xsl:when test="normalize-space(/xbel:xbel/supplementalData/folderID)"> <xsl:value-of select="normalize-space(/xbel:xbel/supplementalData/folderID)" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="normalize-space(/xbel:xbel/folder[1]/@id)" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="redirectURL" select="normalize-space(concat($webPath,'template/apps,bookmarks,viewFolderBookmarks.vm?folderID=',$folderID))" /> <xsl:variable name="topBannerColor" select="normalize-space(/xbel:xbel/supplementalData/topBannerColor)" /> <xsl:variable name="portletBodyColor" select="normalize-space(/xbel:xbel/supplementalData/portletBodyColor)" /> <xsl:template match="/"> <!--webPath: <xsl:value-of select="$webPath" /><br /> imagePath: <xsl:value-of select="$imagePath" /><br /> folderID: <xsl:value-of select="$folderID" /><br /> redirectURL: <xsl:value-of select="$redirectURL" /><br />--> <xsl:apply-templates select="xbel:xbel" /> </xsl:template> <xsl:template match="xbel:xbel"> <br /> <p>Manage your folders and bookmarks below.</p> <table cellspacing="0" cellpadding="2" border="0" width="90%"> <xsl:apply-templates /> </table> <br /> </xsl:template> <xsl:template match="folder"> <xsl:choose> <xsl:when test="@id=$folderID"> <!-- still have to get parent folders for breadcrumbs here --> <tr><td valign="top" colspan="2" class="bold"><img src="{$imagePath}folder_icon2.gif" alt="Folder" width="13" height="16" border="0" /> <xsl:value-of select="../../folder/title" /> > <xsl:value-of select="title" /></td><td align="right" colspan="2"><a href="{$webPath}template/apps,bookmarks,addUpdateFolder.vm?folderID={$folderID}&redirectURL={$redirectURL}">Add Folder</a> | <a href="{$webPath}template/apps,bookmarks,addUpdateFolder.vm?folderID={$folderID}&redirectURL={$redirectURL}">Add Bookmark</a></td></tr> <!--$session.topBannerColor --> <tr bgcolor="{$topBannerColor}"><th align="left">Name</th><th align="left">Description</th><th align="left"> </th><th align="left">Action</th></tr> </xsl:when> <xsl:when test="parent::folder/@id=$folderID"> <xsl:variable name="fid" select="@id" /> <tr><td valign="top" width="30%"><a href="{$webPath}template/apps,bookmarks,viewFolderBookmarks.vm?folderID={$fid}"><img src="{$imagePath}folder_icon2.gif" alt="Folder" width="13" height="16" border="0" /></a> <a href="{$webPath}template/apps,bookmarks,viewFolderBookmarks.vm?folderID={$fid}"><xsl:value-of select="title" /></a></td><td> </td><td> </td><td align="right" class="small" width="10%"><a href="{$webPath}template/apps,bookmarks,addUpdateFolder.vm?folderID={$fid}&redirectURL={$redirectURL}"><img src="{$imagePath}edit_pencil.gif" alt="Edit Folder" width="12" height="12" border="0" /></a> <a href="{$webPath}template/confirmDelete.vm?folderID={$fid}&message=folder" onclick="rusure('Are you sure you want to delete this folder and all of its bookmarks?','{$webPath}template/confirmDelete.vm?folderID={$fid}&message=folder'); return false;"><img src="{$imagePath}delete_x_red.gif" alt="Delete Folder" width="16" height="12" border="0" /></a></td></tr> </xsl:when> </xsl:choose> <xsl:apply-templates /> </xsl:template> <xsl:template match="bookmark"> <xsl:if test="parent::folder/@id=$folderID"> <xsl:variable name="bid" select="@id" /> <tr><td width="30%"><a href="{@href}" target="_blank"><xsl:value-of select="title" /></a></td><td width="40%"> </td><td width="20%"> </td><td align="right" class="small" width="10%"><a href="{$webPath}template/apps,bookmarks,addUpdateBookmark.vm?bookmarkID={$bid}&redirectURL={$redirectURL}"><img src="{$imagePath}edit_pencil.gif" alt="Edit Bookmark" width="12" height="12" border="0" /></a> <a href="{$webPath}template/confirmDelete.vm?bookmarkID={$bid}&message=bookmark" onclick="rusure('Are you sure you want to delete this bookmark?','{$webPath}template/confirmDelete.vm?bookmarkID={$bid}&message=bookmark'); return false;"><img src="{$imagePath}delete_x_red.gif" alt="Delete Bookmark" width="16" height="12" border="0" /></a></td></tr> </xsl:if> </xsl:template> <xsl:template match="*" /> </xsl:stylesheet> __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Antw: [xsl] Simple Date / Time Outp, agnes . kielen | Thread | Re: [xsl] getting all parent elemen, David Carlisle |
Re: [xsl] Problem sorting alphabeti, David Carlisle | Date | RE: [xsl] getting all parent elemen, Jarno . Elovirta |
Month |