472,129 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,129 software developers and data experts.

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 2118
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.