Forum Moderators: open
<page id="contents.html" value="Contents">
<page id="category.html" value="Category">
<page id="subject1.html" value="Subject 1">
<page id="topic4.html" value="Topic 4"/>
<page id="topic5.html" value="Topic 5"/>
</page>
<page id="subject2.html" value="Subject 2">
<page id="topic6.html" value="Topic 6"/>
</page>
</page>
</page>
I have an XSLT that turns my XML navigation tree into tree-view navigation for a large document-based site. it uses a recursive template for all "page" elements, so if the current node has children, it keeps drilling.
<xsl:when test="count(page) > 0">
What I want to do is selectively display a node's children depending if it is an ancestor a given page - the user's "current page". So, say Mr. User is on "about.html", I would like to show the tree open to the "about.html" node by not displaying any of the cousin or nephew nodes.
is there a "xsl:when test" that can figure out if a current node is an ancestor of a particular node with a given ID?
Another thought is that I should be removing those nodes from the XML using XPathNavigator or some other .NET tool. That way the XML does the selection, and XSL only does the rendering.
I need an XML expert to hold my hand for a few minutes. anyone?
sticky me if you've tried this before
I would rather manipulate the XML object once loaded and discard/ignore unneeded nodes.
I had a good thing going by reading my source XML document (from file), and using that to build a new XML document. then I can do my XSL transformation on that new XML document.
XmlDocument sitemap = new XmlDocument();
Then I ran into a snag: to add new child nodes, I have to getElementById. GetElementById only works when there is a DTD defining an ID attribute. well I haven't found a way to create a DTD for my virtual document.
So far this has been a wickedly difficult plunge into XML programming in .NET - up until now I had used XML extensively in Flash and PHP without nearly this much difficulty.
Are there any XML.NET gurus around here?