home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 December / PCWorld_2000-12_cd.bin / Komunikace / mozilla / mozilla-win32-M18-mathml-svg-xslt.exe / res / rdf / dom-test-3.xul < prev    next >
Extensible Markup Language  |  2000-09-20  |  2KB  |  70 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.  
  4. This test exercises creation of DOM elements from the XUL document. It
  5. creates a bookmark element and tries to insert it.
  6.  
  7. -->
  8. <?xml-stylesheet href="resource:/res/samples/xul.css" type="text/css"?>
  9.  
  10. <window
  11.   xmlns:html="http://www.w3.org/1999/xhtml"
  12.   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  13.   xmlns:nc="http://home.netscape.com/NC-rdf#"
  14.   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  15.  
  16. <html:script>
  17. function AddBookmark()
  18. {
  19.   // get the personal toolbar folder, which'll be constructed
  20.   // automagically by RDF
  21.   var folder = document.getElementById("NC:PersonalToolbarFolder");
  22.   dump("folder = " + folder + "\n");
  23.   if (folder == null)
  24.     return;
  25.  
  26.   var treechildren = null;
  27.   for (var i = folder.childNodes.length - 1; i >= 0; --i) {
  28.     dump('folder.childNodes[' + i + '].nodeName = ' + folder.childNodes[i].nodeName + '\n');
  29.     if (folder.childNodes[i].nodeName == 'treechildren') {
  30.       treechildren = folder.childNodes[i];
  31.       break;
  32.     }
  33.   }
  34.  
  35.   dump("treechildren = " + treechildren + "\n");
  36.   if (treechildren == null) {
  37.     treechildren = document.createElement('treechildren');
  38.     folder.appendChild(treechildren);
  39.   }
  40.  
  41.   var newItem = document.createElement('treeitem');
  42.   newItem.setAttribute('id', 'http://home.netscape.com/people/waterson');
  43.   newItem.setAttribute('type', 'http://home.netscape.com/NC-rdf#Bookmark');
  44.   newItem.setAttribute('nc:Name', 'My Home Page');
  45.   newItem.setAttribute('rdf:property', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_5');
  46.  
  47.   treechildren.appendChild(newItem);
  48. }
  49. </html:script>
  50.  
  51. <html:button onclick="AddBookmark();">Add Bookmark</html:button>
  52.  
  53. <tree id="tree" datasources="rdf:bookmarks" onclick="return OpenURL(event,event.target.parentNode);">
  54.   <treecolgroup>
  55.     <treecol resource="http://home.netscape.com/NC-rdf#Name" flex="1"/>
  56.     <treecol resource="http://home.netscape.com/NC-rdf#URL" flex="1"/>
  57.   </treecolgroup>
  58.   <treehead>
  59.     <treeitem>
  60.       <treecell>Name</treecell>
  61.       <treecell>URL</treecell>
  62.     </treeitem>
  63.   </treehead>
  64.  
  65.   <treebody id="NC:BookmarksRoot">
  66.   </treebody>
  67. </tree>
  68.  
  69. </window>
  70.