Can someone tell if Sitemap always require a starting root?

R

rlueneberg

Can someone tell if Sitemap always require a starting root? Can it have
more than one root? I am having a problem trying to hide a root node
without hiding its children using a Treeview component. I know you can
do that if you use sitempadatasource. But instead I am forced to use
this tranformation:

xForm.Transform(m_TblMgr.XmlDoc, xslArgs, tmpS)

where tmpS is the sitemap output.

Thank you

Rod
 
A

Alan Silver

Can someone tell if Sitemap always require a starting root?
Yes

Can it have
more than one root?
No

I am having a problem trying to hide a root node
without hiding its children using a Treeview component. I know you can
do that if you use sitempadatasource.

So why not do that then?
 
R

rlueneberg

Thanks Alan. I don't like my solution. I think having to run second
transformation on a large tree with over 2000 items again would affect
performance. It would be better do it right from the beginning don't
you think? Look what I did:


Removing "Categories from Root Node"

// TRANSFORM ROOT NODE TO REMOVE "CATEGORIES"
//load the Xml doc
XslTransform myXslTrans = new XslTransform();
//load the Xsl

myXslTrans.Load(CommonLogic.SafeMapPath("EntityHelper/RemoveRootNode.xslt"));
//create the output stream
StringWriter tmpS2 = new StringWriter();
//do the actual transform of Xml
myXslTrans.Transform(doc, null, tmpS2);

string s = tmpS2.ToString();
s = s.Replace("{","");
s = s.Replace("}","");
s = s.Replace(General.RegexSearch(s, @"<\?xml(.*?)>",
0), "");
s = "<siteMap>"+ s + "</siteMap>";
tmpS2.Close();
Removing "Categories from Root Node"

// TRANSFORM ROOT NODE TO REMOVE "CATEGORIES"
//load the Xml doc
XslTransform myXslTrans = new XslTransform();
//load the Xsl

myXslTrans.Load(CommonLogic.SafeMapPath("EntityHelper/RemoveRootNode.xslt"));
//create the output stream
StringWriter tmpS2 = new StringWriter();
//do the actual transform of Xml
myXslTrans.Transform(doc, null, tmpS2);

string s = tmpS2.ToString();
s = s.Replace("{","");
s = s.Replace("}","");
s = s.Replace(General.RegexSearch(s, @"<\?xml(.*?)>",
0), "");
s = "<siteMap>"+ s + "</siteMap>";
tmpS2.Close();


Rod
 
A

Alan Silver

Thanks Alan. I don't like my solution. I think having to run second
transformation on a large tree with over 2000 items again would affect
performance. It would be better do it right from the beginning don't
you think? Look what I did:
<snip>

This looks very complex for a site map. How often do you do this? Does
your site map change that often?

Why not just write the site map out to a file whenever it changes. That
will give you the advantage of only needing to run the code whenever
changes occur, not whenever you want to get the data, plus it allows you
to use the sitemapprovider, which will give you the extra functionality
you want.

HTH
 
R

rlueneberg

I forgot to post piece RemoveRootNode.XSLT.
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:eek:utput method="xml" indent="yes" />
<xsl:template match="siteMapNode">
<xsl:copy-of select="child::node()" />
</xsl:template>
</xsl:stylesheet>

This looks very complex for a site map. How often do you do this? Does
your site map change that often?

We do change a lot. Our cateogories change every week and we tend to
add and remove frequently.

Why not just write the site map out to a file whenever it changes.
I can't touch the DLL file that generate the nodes it. Yeah I know that
the provider has a property for the starting node where you can specify
the starting point of the tree. But using the provider would still
require mapping it to the Treview Datasource and may be a little bit
slower and work similarly in the same way of a second transform.

Rod

That
 
R

rlueneberg

Alan, I forgot to ask if the fact that the siteMap necessarly needs a
single root not is part of its schema constrain ? I've seen XML with
more than one root. Why is this way if Microsoft want to use for
multiple purposes binding controls, not only for creating site maps? It
doen't make sense? Unless they want it to be used only for Hierarchical
"Site Maps"

Rod
 
A

Alan Silver

Alan, I forgot to ask if the fact that the siteMap necessarly needs a
single root not is part of its schema constrain ? I've seen XML with
more than one root.

I don't think XML requires a single root node, but then I'm not expert,
but sitemap files certainly do.
Why is this way if Microsoft want to use for
multiple purposes binding controls, not only for creating site maps? It
doen't make sense? Unless they want it to be used only for Hierarchical
"Site Maps"

Well, it *is* called a "site map" and they obviously feel that a site
map always has one root node, ie the home page. Logical really.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top