469,332 Members | 6,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Filter XML to pass to XSL and import into my control?

I'm still struggling to figure out the big-picture concept of how to go
about building a web site menu from an xml file.

The XML file contains the full site structure (the site map, so-to-speak).
Based on the current page of the site, I want to be able to do the
following:

get node that pertains to current page
get node's siblings
get node's parents
get node's parents siblings
repeat until top node...
Pass this filtered XML to an XSLT file
import xhtml result into my usercontrol to display on page

I asked this yesterday but was a bit too wordy I think. Does the above sound
like the correct way to go about doing things? If so, how dows one best sort
the XML to pull out a subset?

-Darrel
Nov 12 '05 #1
3 2051
If in your Xml each node that corresponds to a page has a unique id you
should be able to do the "filtering" along with the transformation all in
the XSLT.

For example.
Step 1: Pass unique Id of the current page to the Xslt as a parameter.
Step 2: Using the parameter in XPath to find the node corresponding to
current page & do <xsl:apply-templates> on it.
Step 3: In the <xsl:template> node for the current page, generate HTML for
menu of current page. Then use the "parent() " XPath function, to locate the
parent node & do <xsl:apply-templates> on the parent.
Step 4: In the <xsl:template> for parent, generate HTML for menu of the
parent & recursively use the "parent()" function to do <xsl:apply-templates>

-Naraen
---------------------------------------------
"darrel" <no*****@hotmail.com> wrote in message
news:Oz**************@TK2MSFTNGP10.phx.gbl...
I'm still struggling to figure out the big-picture concept of how to go
about building a web site menu from an xml file.

The XML file contains the full site structure (the site map, so-to-speak).
Based on the current page of the site, I want to be able to do the
following:

get node that pertains to current page
get node's siblings
get node's parents
get node's parents siblings
repeat until top node...
Pass this filtered XML to an XSLT file
import xhtml result into my usercontrol to display on page

I asked this yesterday but was a bit too wordy I think. Does the above sound like the correct way to go about doing things? If so, how dows one best sort the XML to pull out a subset?

-Darrel

Nov 12 '05 #2
> If in your Xml each node that corresponds to a page has a unique id you
should be able to do the "filtering" along with the transformation all in
the XSLT.


Ah! That certainly sounds like the most streamlined way to go about it.

Now, the getParent thing makes sense...specifically for whipping out a
breadcrumb trail. Is there a way to pull out siblings as well? I see ways to
get next and previous sibling. Is there a way to simply do a 'if sibling of
[ID]' type of loop?

-Darrel
Nov 12 '05 #3
One alternative would be to get children of the parent of the current node,
something like ../child:: ...

A less messy approach is possible if the ID is unique in the scope of the
document. Then you can use <xsl:key> & the key().

-Naraen

-------------
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
If in your Xml each node that corresponds to a page has a unique id you
should be able to do the "filtering" along with the transformation all in the XSLT.
Ah! That certainly sounds like the most streamlined way to go about it.

Now, the getParent thing makes sense...specifically for whipping out a
breadcrumb trail. Is there a way to pull out siblings as well? I see ways

to get next and previous sibling. Is there a way to simply do a 'if sibling of [ID]' type of loop?

-Darrel

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Robin Cull | last post: by
3 posts views Thread by George Ter-Saakov | last post: by
7 posts views Thread by Mike | last post: by
1 post views Thread by LabWINC | last post: by
1 post views Thread by TheSaint | last post: by
bartonc
reply views Thread by bartonc | last post: by
reply views Thread by Chris Curvey | last post: by
3 posts views Thread by Mr 200 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.