Diff for /books/www/chapters/ch10.html between versions 1.11 and 1.12

version 1.11, 2003/03/23 04:54:03 version 1.12, 2003/03/23 05:56:31
Line 869  xmlns:location="fly-location#"> Line 869  xmlns:location="fly-location#">
       </tr>        </tr>
       <tr>        <tr>
         <td>Local datasource</td>          <td>Local datasource</td>
        <td>A local datasource is an RDF graph contained in an        
        RDF/XML file on a local disk. All RDF files in the chrome    <td>A local datasource is an RDF graph contained in an RDF/XML file on a local 
        registry (e.g.,</td>      disk. All RDF files in the chrome directory (e.g., <i>all-packages.rdf</i> 
       in the <i>chrome</i> directory, which keeps track of packages installed 
       in Mozilla) are local datasources.</td>
       </tr>        </tr>
       <tr>        <tr>
         <td>Remote datasource</td>          <td>Remote datasource</td>
Line 881  xmlns:location="fly-location#"&gt; Line 883  xmlns:location="fly-location#"&gt;
       </tr>        </tr>
       <tr>        <tr>
         <td>In-memory datasource</td>          <td>In-memory datasource</td>
        <td>An in-memory datasource exists only in memory during a        
        Mozilla session. In-memory datasources are built with</td>    <td>An in-memory datasource exists only in memory during a Mozilla session. 
       In-memory datasources are built with <i>assertions</i>, statements that 
       build an in-memory data model by adding resources, add properties, and value 
       those.</td>
       </tr>        </tr>
       <tr>        <tr>
         <td>Built-in datasource</td>          <td>Built-in datasource</td>
        <td>These unique, prefabricated datasources represent        
        something used often in Mozilla, such as a built-in</td>    <td>These unique, prefabricated datasources represent something used often 
       in Mozilla, such as a built-in <i>filesystem</i> datasource and a <i>history</i> 
       datasource.</td>
       </tr>        </tr>
       <tr>        <tr>
         <td>Composite datasource</td>          <td>Composite datasource</td>
Line 1006  searchDS.RememberLastSearchText(escapedS Line 1013  searchDS.RememberLastSearchText(escapedS
 <pre>  <pre>
 rdf:SomeName  rdf:SomeName
 </pre>  </pre>
      The URI is also accessible as a datasource property:      
      <hr>  <p>The URI, such as <i>rdf:someName</i>, is also accessible as a datasource 
     property: </p>
   <pre>foo-ds.URI</pre>
   <hr>
     </blockquote>      </blockquote>
     foo-ds.URI   
     <h3><a name="77083"></a> What Are RDF Interfaces?</h3>      <h3><a name="77083"></a> What Are RDF Interfaces?</h3>
     <p>RDF interfaces       <p>RDF interfaces 
     <!--INDEX RDF (Resource Description Framework):interfaces:overview -->      <!--INDEX RDF (Resource Description Framework):interfaces:overview -->
Line 1024  rdf:SomeName Line 1033  rdf:SomeName
     node</i></p>      node</i></p>
 <pre>  <pre>
  // get the nsIRDFService interface and assign it to RDF   // get the nsIRDFService interface and assign it to RDF
 RDF = Components.classes&lt;/td&gt;<a href= RDF = Components.classes.["@mozilla.org/rdf/rdf-service;1"].
"MAILTO:[`@mozilla.org/rdf/rdf-service;1">[`@mozilla.org/rdf/rdf-service;1</a>']. 
        getService(Components.interfaces.nsIRDFService);         getService(Components.interfaces.nsIRDFService);
  // call the GetResource method from the interface   // call the GetResource method from the interface
  rootResource = RDF.GetResource('urn:root');   rootResource = RDF.GetResource('urn:root');
Line 1066  rdf:SomeName Line 1074  rdf:SomeName
       </tr>        </tr>
       <tr>        <tr>
         <td>nsIRDFNode, nsIRDFResource, nsIRDFLiteral</td>          <td>nsIRDFNode, nsIRDFResource, nsIRDFLiteral</td>
        <td>Provide an equality function. Values for resources and        
        literals can be retrieved. Objects of these types are    <td>Provide an equality function. Values for resources and literals can be 
        retrieved from</td>      retrieved. Objects of these types are retrieved from nsIRDFService.</td>
       </tr>        </tr>
       <tr>        <tr>
         <td>nsIRDFContainer</td>          <td>nsIRDFContainer</td>
Line 1557  aValue = literal.Value; Line 1565  aValue = literal.Value;
     only <tt>sequence</tt> is covered here.) To create an instance      only <tt>sequence</tt> is covered here.) To create an instance
     of <i>nsIRDFContainerUtils</i>, use the following:</p>      of <i>nsIRDFContainerUtils</i>, use the following:</p>
 <pre>  <pre>
containerUtils = Components.classes['@mozilla.org/rdf/container-utils;1'containerUtils = Components.classes['@mozilla.org/rdf/container-utils;1'].
 getService(Components.interfaces.nsIRDFContainerUtils);  getService(Components.interfaces.nsIRDFContainerUtils);
 </pre>  </pre>
     <p>Once you create an anonymous resource, you can create a      <p>Once you create an anonymous resource, you can create a
Line 1809  tree.builder.rebuild( ); Line 1817  tree.builder.rebuild( );
 <pre>  <pre>
 &lt;people names="Brian King,Eric Murphy,Ian Oeschger,Pete Collins,David Boswell"/&gt;  &lt;people names="Brian King,Eric Murphy,Ian Oeschger,Pete Collins,David Boswell"/&gt;
 </pre>  </pre>
    <p>Obviously, the comma is used as the delimiter for this list.    
    The constructor element in <a href="#77046">Example 10-11</a><p>Obviously, the comma is used as the delimiter for this list. The constructor 
    uses JavaScript to break up this string. Example 10-11<a name=  element in <a href="#77046">Example 10-11</a> uses JavaScript to break up this 
    "77046"></a> <i>Binding with in-memory datasource and  string. </p>
    &lt;listbox&gt; template</i></p><p>Example 10-11<a name=
     "77046"></a> <i>Binding with in-memory datasource and &lt;listbox&gt; template</i></p>
 <pre>  <pre>
  &lt;?xml version="1.0"?&gt;   &lt;?xml version="1.0"?&gt;
  &lt;bindings xmlns ="<a href=   &lt;bindings xmlns ="<a href=
Line 1876  tree.builder.rebuild( ); Line 1885  tree.builder.rebuild( );
              &lt;xul:conditions&gt;               &lt;xul:conditions&gt;
                &lt;xul:content uri="?uri"/&gt;                 &lt;xul:content uri="?uri"/&gt;
                &lt;xul:triple subject="?uri"                 &lt;xul:triple subject="?uri"
                        predicate="<a href=                           predicate="<a href=
"http://www.mozdev.org/rdf">http://www.mozdev.org/rdf</a>#people"                              object="?people"/&gt;"http://www.mozdev.org/rdf">http://www.mozdev.org/rdf</a>#people"
                            object="?people"/&gt;
                &lt;xul:member container="?people" child="?person"/&gt;                 &lt;xul:member container="?people" child="?person"/&gt;
                &lt;xul:triple subject="?person"                 &lt;xul:triple subject="?person"
                        predicate="<a href=                           predicate="<a href=
"http://www.mozdev.org/rdf">http://www.mozdev.org/rdf</a>#name"                         object="?name"/&gt;"http://www.mozdev.org/rdf">http://www.mozdev.org/rdf</a>#name"
                            object="?name"/&gt;
              &lt;/xul:conditions&gt;               &lt;/xul:conditions&gt;
              &lt;xul:action&gt;               &lt;xul:action&gt;
                &lt;xul:listitem uri="?person"&gt;                 &lt;xul:listitem uri="?person"&gt;
Line 1908  tree.builder.rebuild( ); Line 1919  tree.builder.rebuild( );
     displayed dynamically in the UI with templates in this      displayed dynamically in the UI with templates in this
     manner.</p>      manner.</p>
     <h2><a name="77112"></a> JSLib RDF Files</h2>      <h2><a name="77112"></a> JSLib RDF Files</h2>
    <p>Working     
    <!--INDEX STARTRANGE==RDF (Resource Description Framework):files:JSLib --><p>Working 
    <!--INDEX STARTRANGE==JSLib libraries:RDF files -->   <!--INDEX STARTRANGE==RDF (Resource Description Framework):files:JSLib -->
    <!--INDEX STARTRANGE==files:RDF:JSLib --> with actual RDF files  <!--INDEX STARTRANGE==JSLib libraries:RDF files -->
    is not easy. However, JSLib (<i><a href=  <!--INDEX STARTRANGE==files:RDF:JSLib -->
    "http://jslib.mozdev.org">http://jslib.mozdev.org</a></i>)  with actual RDF files is not easy. However, JSLib (<i><a href=
    provides an RDF file library that can help you develop an    "http://jslib.mozdev.org">http://jslib.mozdev.org</a></i>) provides an RDF 
    RDF-based application. The library provides many types of error  file library that can help you develop an RDF-based application. The library 
    checking, as well as a friendly abstraction away from the  provides many types of error checking, as well as a friendly abstraction away 
    RDF/XML interfaces of Mozilla (see <a href="#77107">"nsIRDFXML  from the RDF/XML interfaces of Mozilla (see <a href="#77107">"nsIRDFXML Interfaces</a>," 
    Interfaces</a>," later in this chapter). <a href=  later in this chapter). <a href=
    "#77048">Example 10-12</a> shows some common uses of the    "#77048">Example 10-12</a> shows some common uses of the <tt>RDFFile</tt> 
    <tt>RDFFile</tt> class in JSLib. This functionality can be used  class in JSLib. This functionality can be used in situations in which you have 
    in situations in which you have data in RDF that you want to  data in RDF that you want to pull out "manually" and use piece by piece (rather 
    pull out "manually" and use piece by piece (rather than as a  than as a whole datasource in a template). </p>
    whole datasource in a template). Example 10-12<a name=<p>Example 10-12<a name=
    "77048"></a> <i>Creating and modifying an RDF file using    "77048"></a> <i>Creating and modifying an RDF file using JSLib</i></p>
    JSLib</i></p> 
 <pre>  <pre>
  var rdfFileURL = 'chrome://jarfly/content/jar.rdf';   var rdfFileURL = 'chrome://jarfly/content/jar.rdf';
  var gTreeBody = null;   var gTreeBody = null;
Line 2058  tree.builder.rebuild( ); Line 2068  tree.builder.rebuild( );
     <tt>FileUtils</tt> is initialized, which will create a path to      <tt>FileUtils</tt> is initialized, which will create a path to
     the RDF file. If the file doesn't already exist, JSLib      the RDF file. If the file doesn't already exist, JSLib
     automatically creates it.</p>      automatically creates it.</p>
    <p>Finally, the <tt>RDFFile</tt> is created by using the path    
    and a root resource identifier, and the "xFly" namespace is<p>Finally, the <tt>RDFFile</tt> is created by using the path and a root resource 
    used for the data references. <a href="#77052">Example  identifier, and the "xFly" namespace is used for the data references. <a href="#77052">Example 
    10-14</a> shows that the RDF file is ready to have its data  10-14</a> shows that the RDF file is ready to have its data added and deleted. 
    added and deleted. Example 10-14<a name="77052"></a> <i>Data</p>
    updating</i></p><p>Example 10-14<a name="77052"></a> <i>Data updating</i></p>
 <pre>  <pre>
  function update( )   function update( )
  {   {
Line 2072  tree.builder.rebuild( ); Line 2082  tree.builder.rebuild( );
    if(gRDF.doesSeqExist('types'))     if(gRDF.doesSeqExist('types'))
    {     {
      seqLength = gRDF.getSeqSubNodes('types').length;       seqLength = gRDF.getSeqSubNodes('types').length;
     //if(del)gRDF.removeSeq('types',false);
    }     }
    else     else
      gRDF.addSeq('types');       gRDF.addSeq('types');
Line 2136  tree.builder.rebuild( ); Line 2146  tree.builder.rebuild( );
     Mozilla. They can be added seamlessly because RDF provides a      Mozilla. They can be added seamlessly because RDF provides a
     platform-like environment that facilitates the installation and      platform-like environment that facilitates the installation and
     use of new Mozilla software.</p>      use of new Mozilla software.</p>
    <p>All packages, including the ones that come preinstalled with    
    Mozilla (such as the browser, the MailNews component, and the<p>All packages, including the ones that come preinstalled with Mozilla (such 
    en-US language pack), have manifests describing them in terms  as the browser, the MailNews component, and the en-US language pack), have manifests 
    of their relation to other packages. The manifests are  describing them in terms of their relation to other packages. The manifests 
    typically files called <i>contents.rdf</i>, but they may also  are typically files called <i>contents.rdf</i>, but they may also be called 
    be called <i>manifest.rdf</i>. <a href="#77054">Example  <i>manifest.rdf</i>. <a href="#77054">Example 10-15</a> presents a <i>contents.rdf</i> 
    10-15</a> presents a <i>contents.rdf</i> file that describes a  file that describes a new skin for Mozilla. </p>
    new skin for Mozilla. Example 10-15<a name="77054"></a> <i>Skin<p>Example 10-15<a name="77054"></a> <i>Skin manifest</i></p>
    manifest</i></p> 
 <pre>  <pre>
  &lt;?xml version="1.0"?&gt;   &lt;?xml version="1.0"?&gt;
  &lt;RDF:RDF xmlns:RDF="&lt;/td&gt;<i><a href=   &lt;RDF:RDF xmlns:RDF="&lt;/td&gt;<i><a href=
Line 2215  tree.builder.rebuild( ); Line 2224  tree.builder.rebuild( );
     runtime. This latter method will be used here to add an "xFly"      runtime. This latter method will be used here to add an "xFly"
     item to the Tools menu of the Mozilla suite of      item to the Tools menu of the Mozilla suite of
     applications.</p>      applications.</p>
    <p><a href="#77056">Example 10-16</a> shows the    
    <i>contents.rdf</i> manifest format that alerts Mozilla of the<p><a href="#77056">Example 10-16</a> shows the <i>contents.rdf</i> manifest format 
    presence of an overlay, its target in the Mozilla application,  that alerts Mozilla of the presence of an overlay, its target in the Mozilla 
    and the package of which it is a part. Example 10-16<a name=  application, and the package of which it is a part. </p>
 <p>Example 10-16<a name=
     "77056"></a> <i>Overlay for a sample application menu</i></p>      "77056"></a> <i>Overlay for a sample application menu</i></p>
 <pre>  <pre>
  &lt;?xml version="1.0"?&gt;   &lt;?xml version="1.0"?&gt;

Removed from v.1.11  
changed lines
  Added in v.1.12


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>