[Jslib] question on construct of RDF using rdf.js module.

Frank Koenen fkoenen at virtualmonet.com
Wed Mar 17 01:39:14 EST 2004


This is a follow up on my own question. The following javascript code
worked for me. I've also included the sample RDF output. If anyone has
comment on my approach, please let me know. Thanks.

javascript:

     1     include('chrome://jslib/content/rdf/rdfFile.js');
     2
     3     var rdf = new RDFFile("/tmp/5.rdf", null, 'http://www.frank.com/me#', 'medrepublic');
     4     if ( rdf.loaded ) {
     5        var node = rdf.getNode("urn:me");
     6        var ccc = node.addContainer('medrepublic:links');
     7        var na = ccc.addNode('urn:a'); na.setAttribute('medrepublic:name','afrank');
     8        var nb = ccc.addNode('urn:b'); nb.setAttribute('medrepublic:name','blarry');
     9        var nc = ccc.addNode('urn:c'); nc.setAttribute('medrepublic:name','cschemp');
    10        rdf.flush();
    11     }

resulting RDF output:

     1  <?xml version="1.0"?>
     2  <RDF:RDF xmlns:medrepublic="http://www.frank.com/me#"
     3           xmlns:NC="http://home.netscape.com/NC-rdf#"
     4           xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
     5    <RDF:Description about="urn:me">
     6      <medrepublic:links resource="rdf:#$O3hjH1"/>
     7    </RDF:Description>
     8    <RDF:Seq about="rdf:#$O3hjH1">
     9      <RDF:li resource="rdf:#$O3hjH1:urn:a"/>
    10      <RDF:li resource="rdf:#$O3hjH1:urn:b"/>
    11      <RDF:li resource="rdf:#$O3hjH1:urn:c"/>
    12    </RDF:Seq>
    13    <RDF:Description about="rdf:#$O3hjH1:urn:c" medrepublic:name="cschemp" />
    14    <RDF:Description about="rdf:#$O3hjH1:urn:a" medrepublic:name="afrank" />
    15    <RDF:Description about="rdf:#$O3hjH1:urn:b" medrepublic:name="blarry" />
    16  </RDF:RDF>


BTW, this is the XUL template code that I'm using this RDF with, all for reference:

     1   <vbox datasources="OUTPUT.rdf" ref="urn:me">
     2     <template><rule>
     3          <conditions>
     4             <content uri="?uri" />
     5             <triple subject="?uri" predicate="http://www.frank.com/me#links" object="?links" />
     6             <member container="?links" child="?child" />
     7             <triple subject="?child" predicate="http://www.frank.com/me#name" object="?name" />
     8          </conditions>
     9          <action>
    10           <hbox>
    11              <text uri="?child" value="aaa ?name" />
    12           </hbox>
    13          </action>
    14     </rule></template>
    15   </vbox>


long live jslib! 

-- 
Frank Koenen
Dir. of Tech. Services
Monet Technologies Inc.
Email: fkoenen at virtualmonet.com Voice:1-312-372-7500 x204 Fax:1-312-372-6020
Visit us on the web: WWW.VIRTUALMONET.COM



More information about the Jslib mailing list