Home Search Member List Faq Register Login  
UltimateSitemap
Re: web.sitemap, AspNet Sitemap Providers and UltimateSitemap

Thread Starter: HarpInteractiveDeveloper   Started: 03-21-2007 7:08 PM   Replies: 3
 Karamasoft Support Forums » General Discussions » UltimateSitemap » Re: web.sitemap, AspNet Sitemap Providers and UltimateSitemap
 Printable Version    « Previous Thread   Next Thread »
  21 Mar 2007, 7:08 PM
HarpInteractiveDeveloper is not online. Last active: 8/13/2009 2:01:24 PM HarpInteractiveDeveloper

Top 10 Posts
Joined on 03-21-2007
Chicago, IL
Posts 6
web.sitemap, AspNet Sitemap Providers and UltimateSitemap
#1.
I've been using UltimateSitemap (USM) on a client project and have a mixed bag of success and frustration. Achieving simple success using the AspNet web.sitemap file was not overly difficult. One annoyance is that the XML namespace attribute of the sitemap's 'siteMap' node seems to break USM.

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">

With this attribute intact USM prodiuces no errors or output. The USM designer does not seem to work correctly either, clicking on a node to edit its position or cssclass causes the window to close without notification.

Removing the namespace reference fixes USM, the designer works and the component produces the expected output. Unfortunately with the attribute removed Visual Studio 2005 (VS05) will no longer offer syntax hints. This became a minor annoyance once I figured out the problem, though I would prefer to see an update that allows USM to work with this attribute intact.

#2
Any comment in the web.sitemap will prevent USM from opening the designer with a somewhat cryptic error merssage:
'Object reference not set to an instance of an object'
Again, not the end of the world but a bit aggrevating until you figure out what is going on.

#3.
My site has sections that I have additional SitemapProviders configured to handle; web.sitemap includes these with SiteMapNodes using the Provider or siteMapFile attributes to pull in the various child nodes from the other providers. USM does not seem to support this functionality. It does 'fail gracefully' in that it does display all the other nodes, the provider node just shows up empty, even without a nodeId.

My workaround at this time is looking like I will iterate over the nodes of the root SiteMapProvider and build an XML string that I will pass to USM. (I might do it in a cooler way that that but you get the basic idea). USM performs perfectly well with XML strings, haven't had any problems with hooking it up to an XmlDataProvider (which is also incapable of following the provider nodes in a sitemap file); so, I do expect that this issue can be worked around without a lot of programming.

I can't fault USM for not following these provider nodes, since USM only claims to interpret XML and  not AspNet SiteMapProviders (big difference), but I would like to add the abillity to hook up USM to a sitemapprovider to the feature wish list.

Is there a recomendation regarding the handling of providers?

-----

Overall I'm so far pleased with UISuite, its a nice suite for the price.
UltimateSearch is the best value so far in my opinion, it was the search component that 'Ultimately' convinced me to recommend picking up the UISuite.

-----

Steve L
Developer
Harp Interactive

  
  22 Mar 2007, 2:44 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: web.sitemap, AspNet Sitemap Providers and UltimateSitemap
Thank you for all your comments and feedback. We will look into some of the issues such as breaking with comments, but we're not planning to do any further improvement for data providers at this point. However, we will add all your points into our enhancements list for future reference.
  
  26 Mar 2007, 11:06 AM
HarpInteractiveDeveloper is not online. Last active: 8/13/2009 2:01:24 PM HarpInteractiveDeveloper

Top 10 Posts
Joined on 03-21-2007
Chicago, IL
Posts 6
Re: web.sitemap, AspNet Sitemap Providers and UltimateSitemap

My workaround, which anyone is welcome to try out or modify for their needs is posted below. This code segment is by no means ideal or robust, but it is enough to get me over the current hump.

One item that is frustrating about working with SiteMapNodes is that there seems to be no way to list all attributes in a sitemapnode object. SiteMapNodeAttributeList below provides the workaround for this, you have to explicitly state the attributes you want transposed to the output xml. In the case of UltimateSitemap I feed the list of UltimateSitemap specific variables. Attributes not present in the source will not be output.

The listing below will start from the SiteMap RootNode and map SiteMapNodes to XML Nodes through recursion. This will produce output that incorporates additional SiteMapProviders included in the web.sitemap.

This works well in my present scenario, larger implementations may want to incorporate caching - for now I'm using the heavy handed aproach of generating the output with each call.





New">ImportsNew"> Microsoft.VisualBasicPublic ClassNew"> AspNetSiteMapXmlDocumentAdapter   Private _XmlDocument AsNew"> System.Xml.XmlDocument   Private _SiteMapNodeAttributeList As NewNew"> ArrayList   Private XmlTextWriter AsNew" size="2"> System.Xml.XmlTextWriterNew">   PublicNew"> ReadOnly Property XmlDocument() AsNew" size="2"> System.Xml.XmlDocumentNew" color="#0000ff" size="2">      GetNew">         XmlDocument = _XmlDocument      End New">Get   End New" color="#0000ff" size="2">PropertyNew">   ReadOnlyNew"> Property XmlString() As New" color="#0000ff" size="2">String      New" color="#0000ff" size="2">GetNew">         XmlString = XmlDocument.OuterXml      End New">Get   End New" color="#0000ff" size="2">PropertyNew">   PublicNew"> Property SiteMapNodeAttributeList() AsNew" size="2"> ArrayListNew" color="#0000ff" size="2">      GetNew">         SiteMapNodeAttributeList = _SiteMapNodeAttributeList      End New">Get      Set(ByVal AttributeArrayList AsNew"> ArrayList)         _SiteMapNodeAttributeList = AttributeArrayList      End New">Set   End New" color="#0000ff" size="2">PropertyNew">   SubNew"> Execute()      Dim StringWriter As NewNew"> System.IO.StringWriter      Dim SiteMapNode AsNew"> SiteMapNode = SiteMap.RootNode            XmlTextWriter = NewNew"> System.Xml.XmlTextWriter(StringWriter)      XmlTextWriter.WriteStartDocument()      XmlTextWriter.WriteStartElement("siteMap"New">)      SiteMapNodeToXMLNodeRecursion(SiteMapNode)      XmlTextWriter.WriteEndElement()      XmlTextWriter.WriteEndDocument()      XmlTextWriter.Flush()      XmlTextWriter.Close()      _XmlDocument = NewNew"> System.Xml.XmlDocument      _XmlDocument.LoadXml(StringWriter.ToString())      StringWriter.Flush()      StringWriter.Close()   End New" color="#0000ff" size="2">SubNew">   PrivateNew"> Sub SiteMapNodeToXMLNodeRecursion(ByVal SiteMapNode AsNew"> SiteMapNode)      XmlTextWriter.WriteStartElement("siteMapNode"New">)      XmlTextWriter.WriteAttributeString("url"New">, SiteMapNode.Url)      XmlTextWriter.WriteAttributeString("title"New">, SiteMapNode.Title)      XmlTextWriter.WriteAttributeString("description"New" size="2">, SiteMapNode.Description)New">            If SiteMapNode.Roles.Count > 0 New">Then         Dim SiteMapNodeRoles As String = New">""         Dim Role As New" color="#0000ff" size="2">StringNew">         ForNew"> Each Role InNew" size="2"> SiteMapNode.Roles            SiteMapNodeRoles = SiteMapNodeRoles & Role & New" color="#a31515" size="2">","New" color="#0000ff" size="2">         NextNew">         SiteMapNodeRoles = Left(SiteMapNodeRoles, Len(SiteMapNodeRoles) - 1)         XmlTextWriter.WriteAttributeString("Roles"New">, SiteMapNodeRoles)      End New" color="#0000ff" size="2">IfNew">      IfNew"> SiteMapNode.ResourceKey <> "" New">Then         XmlTextWriter.WriteAttributeString("ResourceKey"New">, SiteMapNode.ResourceKey)      End New">If      If _SiteMapNodeAttributeList.Count > 0 New">Then         Dim SiteMapAttribute As New">String         For Each SiteMapAttribute InNew"> _SiteMapNodeAttributeList            If SiteMapNode.Item(SiteMapAttribute) <> "" New" color="#0000ff" size="2">ThenNew">               XmlTextWriter.WriteAttributeString(SiteMapAttribute, SiteMapNode.Item(SiteMapAttribute))            End New" color="#0000ff" size="2">IfNew">         Next      End New">If      If SiteMapNode.HasChildNodes = True New">Then         Dim ChildSiteMapNode AsNew" size="2"> SiteMapNodeNew">                  For Each ChildSiteMapNode InNew" size="2"> SiteMapNode.ChildNodes            SiteMapNodeToXMLNodeRecursion(ChildSiteMapNode)New" color="#0000ff" size="2">         NextNew">            End New" color="#0000ff" size="2">IfNew">      XmlTextWriter.WriteEndElement()   End New">SubEnd New">Class
 



New">ProtectedNew"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)New">   DimNew"> Adapter As NewNew"> AspNetSiteMapXmlDocumentAdapter   Adapter.SiteMapNodeAttributeList.Add("nodeID"New">)   Adapter.SiteMapNodeAttributeList.Add("nodeCssClass"New">)   Adapter.SiteMapNodeAttributeList.Add("childNodeCssClass"New">)   Adapter.SiteMapNodeAttributeList.Add("nodePrefix"New">)      Adapter.SiteMapNodeAttributeList.Add("nodeSuffix"New">)   Adapter.SiteMapNodeAttributeList.Add("childNodePrefix"New">)      Adapter.SiteMapNodeAttributeList.Add("childNodeSuffix"New">)   Adapter.SiteMapNodeAttributeList.Add("folderClosedImage"New">)      Adapter.SiteMapNodeAttributeList.Add("folderOpenImage"New">)   Adapter.SiteMapNodeAttributeList.Add("columnIndex"New">)   Adapter.SiteMapNodeAttributeList.Add("rowIndex"New">)   Adapter.SiteMapNodeAttributeList.Add("allowedUsers"New">)   Adapter.Execute()      UltimateSitemap1.SitemapSourceXml = Adapter.XmlString

New">

New">End New">Sub

New">
 


  
  26 Mar 2007, 11:09 AM
HarpInteractiveDeveloper is not online. Last active: 8/13/2009 2:01:24 PM HarpInteractiveDeveloper

Top 10 Posts
Joined on 03-21-2007
Chicago, IL
Posts 6
Re: web.sitemap, AspNet Sitemap Providers and UltimateSitemap
ok then. I'm obviously having some technical problems with posting my code.


Imports Microsoft.VisualBasic

Public Class AspNetSiteMapXmlDocumentAdapter

Private _XmlDocument As System.Xml.XmlDocument

Private _SiteMapNodeAttributeList As New ArrayList

Private XmlTextWriter As System.Xml.XmlTextWriter

Public ReadOnly Property XmlDocument() As System.Xml.XmlDocument

Get

XmlDocument = _XmlDocument

End Get

End Property

ReadOnly Property XmlString() As String

Get

XmlString = XmlDocument.OuterXml

End Get

End Property

 

Public Property SiteMapNodeAttributeList() As ArrayList

Get

SiteMapNodeAttributeList = _SiteMapNodeAttributeList

End Get

Set(ByVal AttributeArrayList As ArrayList)

_SiteMapNodeAttributeList = AttributeArrayList

End Set

End Property

 

Sub Execute()

Dim StringWriter As New System.IO.StringWriter

Dim SiteMapNode As SiteMapNode = SiteMap.RootNode

XmlTextWriter = New System.Xml.XmlTextWriter(StringWriter)

XmlTextWriter.WriteStartDocument()

XmlTextWriter.WriteStartElement("siteMap")

SiteMapNodeToXMLNodeRecursion(SiteMapNode)

XmlTextWriter.WriteEndElement()

XmlTextWriter.WriteEndDocument()

XmlTextWriter.Flush()

XmlTextWriter.Close()

_XmlDocument = New System.Xml.XmlDocument

_XmlDocument.LoadXml(StringWriter.ToString())

StringWriter.Flush()

StringWriter.Close()

End Sub

Private Sub SiteMapNodeToXMLNodeRecursion(ByVal SiteMapNode As SiteMapNode)

XmlTextWriter.WriteStartElement("siteMapNode")

XmlTextWriter.WriteAttributeString("url", SiteMapNode.Url)

XmlTextWriter.WriteAttributeString("title", SiteMapNode.Title)

XmlTextWriter.WriteAttributeString("description", SiteMapNode.Description)

If SiteMapNode.Roles.Count > 0 Then

Dim SiteMapNodeRoles As String = ""

Dim Role As String

For Each Role In SiteMapNode.Roles

SiteMapNodeRoles = SiteMapNodeRoles & Role & ","

Next

SiteMapNodeRoles = Left(SiteMapNodeRoles, Len(SiteMapNodeRoles) - 1)

XmlTextWriter.WriteAttributeString("Roles", SiteMapNodeRoles)

End If

If SiteMapNode.ResourceKey <> "" Then

XmlTextWriter.WriteAttributeString("ResourceKey", SiteMapNode.ResourceKey)

End If

If _SiteMapNodeAttributeList.Count > 0 Then

Dim SiteMapAttribute As String

For Each SiteMapAttribute In _SiteMapNodeAttributeList

If SiteMapNode.Item(SiteMapAttribute) <> "" Then

XmlTextWriter.WriteAttributeString(SiteMapAttribute, SiteMapNode.Item(SiteMapAttribute))

End If

Next

End If

If SiteMapNode.HasChildNodes = True Then

Dim ChildSiteMapNode As SiteMapNode

For Each ChildSiteMapNode In SiteMapNode.ChildNodes

SiteMapNodeToXMLNodeRecursion(ChildSiteMapNode)

Next

End If

XmlTextWriter.WriteEndElement()

End Sub

 

End Class


 




Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

Dim Adapter As New AspNetSiteMapXmlDocumentAdapter

Adapter.SiteMapNodeAttributeList.Add("nodeID")

Adapter.SiteMapNodeAttributeList.Add("nodeCssClass")

Adapter.SiteMapNodeAttributeList.Add("childNodeCssClass")

Adapter.SiteMapNodeAttributeList.Add("nodePrefix")

Adapter.SiteMapNodeAttributeList.Add("nodeSuffix")

Adapter.SiteMapNodeAttributeList.Add("childNodePrefix")

Adapter.SiteMapNodeAttributeList.Add("childNodeSuffix")

Adapter.SiteMapNodeAttributeList.Add("folderClosedImage")

Adapter.SiteMapNodeAttributeList.Add("folderOpenImage")

Adapter.SiteMapNodeAttributeList.Add("columnIndex")

Adapter.SiteMapNodeAttributeList.Add("rowIndex")

Adapter.SiteMapNodeAttributeList.Add("allowedUsers")

Adapter.Execute()

UltimateSitemap1.SitemapSourceXml = Adapter.XmlString

End Sub


 

  
 Page 1 of 1 (4 items)
Karamasoft Support Forums » General Discussions » UltimateSitemap » Re: web.sitemap, AspNet Sitemap Providers and UltimateSitemap

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.