Using XML to define a Web Menu object

CollapsableMenu Single Line Menu
WebMenu Documentation >>  Using XML to define a Web Menu object
QuickNavigationMenu QuickParentNavigationMenu
<< >> << ^ >>
MultiLineMenu
Introduction | Creating Menus in Python | The WebPage Class | The HiddenPage Class | The WebMenu Class | Using XML to define a Web Menu object | Q&A | CSS Declarations

In order to make the creation of a WebMenu object easier, the WebMenu module also includes a xml.dom.minidom parser that reads and xml file and returns a WebMenu object. The Web Content Management System expects the menu structure for the site to be an XML document.

The XML document that describes the menu structure for this minisite is:

<?xml version="1.0" ?>
<!DOCTYPE WEBNAVIGATION SYSTEM "http://www.spiritone.com/~english/code/webnavigation.dtd">
<webnavigation title="WebMenu Documentation" href="webmenu.html" key="home">
<global separator=" | " useLower="1" useNoBreak="0" menutag="span" 
	singlelineseperator = " >>">
<menuclass>menu</menuclass>
<linkclass>link</linkclass>
<pageclass>page</pageclass>
<hereclass>here</hereclass>
</global>
<page title="Introduction" href = "intro.html" key ="intro"/>
<menu title="Creating Menus in Python" href="python.html" key="python">
	<page title="Setting the Defaults" href="default.html" key="default"/>
	<page title="Adding Pages and Menus" href="adding.html" key="adding"/>
</menu>
<page title="The WebPage Class" href="webpageclass.html" key="webpage"/>
<page title="The WebMenu Class" href="webmenuclass.html" key="webmenu"/>
<page title="Using XML to define a Web Menu object" href = "xml.html" key="xml"/>
<page title="Questions about WebMenu" href="questions.html" key="qna"/>
</webnavigation>

Step by step, here are the sections:

The webnavigation node
This is the main menu and the WebMenuParser creates a WebMenu object. It's three attributes are title , href , and key . These are used to in the Add function.
The global node
This node sets the preferences for how the menu looks. It's attributes are separator , useLower , useNoBreak , menutag , and singlelineseperator .
The menuclass , linkclass , pageclass , hereclass nodes
The contents of these node are used to assign the base classes.
The page and menu nodes.
The rest of the XML file shold be a list of page and menu declarations. They have the same three attributes as the webnavigation node.
WebMenu.WebMenuParser(path)
WebMenuParser takes the path to the XML declaration file and parses it using the xml.dom.minidom package. Calling the WebMenu() method returns a WebMenu object

Back to my code page Back to my home page ©2003 english@spiritone.com