how to create in-memory rdf datasource (multi-level) for a XUL tree?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to create in-memory rdf datasource (multi-level) for a XUL tree?

stevengpn
Hi, there

I got problem to populate a XUL tree with an in-memory rdf data source.
All sapmle code I've seen so far were just created a tree with only
just one top level (eg:
http://in.geocities.com/skexz/tuts/xul/in-memory.htm). Is anyone knows
how to create a in-memory rdf datasource with structure like below (two
levels):

<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:ANIMALS="http://www.mediaflex.co.nz/rdf#">

   <!-- resources -->
   <RDF:Description RDF:about="http://www.mediaflex.co.nz/Account">
     <ANIMALS:name>Account</ANIMALS:name>
   </RDF:Description>

   <RDF:Description RDF:about="http://www.mediaflex.co.nz/User">
     <ANIMALS:name>User</ANIMALS:name>
   </RDF:Description>

  <RDF:Description RDF:about="http://www.mediaflex.co.nz/birds/emu">
         <ANIMALS:name>Emu</ANIMALS:name>
  </RDF:Description>

<!-- structure -->
  <RDF:Seq RDF:about="http://www.mediaflex.co.nz/Account">
       <RDF:li>
              <RDF:Seq RDF:about="http://www.mediaflex.co.nz/User">
                        <RDF:li
RDF:resource="http://www.mediaflex.co.nz/birds/emu"/>
              </RDF:Seq>
           </RDF:li>
  </RDF:Seq>
</RDF:RDF>

Big Thank You!
Steve

_______________________________________________
Mozilla-rdf mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-rdf
Reply | Threaded
Open this post in threaded view
|

Re: how to create in-memory rdf datasource (multi-level) for a XUL tree?

Neil-4
[hidden email] wrote:

>I got problem to populate a XUL tree with an in-memory rdf data source. All sapmle code I've seen so far were just created a tree with only just one top level (eg: http://in.geocities.com/skexz/tuts/xul/in-memory.htm). Is anyone knows how to create a in-memory rdf datasource with structure like below (two levels):
>  
>
Well, that example is a bit convoluted, but do you see how it creates a
root node, a Seq container, and appends the elements to it? Well, you
simply do exactly the same thing with the element node - you create a
Seq for it, and append the children to the Seq. Don't forget to create a
new RDFC object for each container, unless you're sure you've finished
with the previous container.

To simplify things you can make the root node the container:

var rootNode = RDF.GetResource("urn:root");

// insert the "top" of the tree, a Seq container
RDFCUtils.MakeSeq(ds, rootNode);
RDFC.Init(ds, rootNode);

You'll also have to change the template:

<conditions>
<treeitem uri="?uri"/>
<member container="?uri" child="?subheading"/>
</conditions>

Which you could then simplify into a basic template:

<template>
<treechildren>
<treeitem uri="rdf:*">
<treerow>
<treecell label="rdf:http://www.bttlindia.com/RDF#id"/>
<treecell label="rdf:http://www.bttlindia.com/RDF#name"/>
<treecell label="rdf:http://www.bttlindia.com/RDF#phone"/>
<treecell label="rdf:http://www.bttlindia.com/RDF#fiscalnumber"/>
</treerow>
</treeitem>
</treechildren>
</template>

Note: this is from memory so I might have some details incorrect.

--
Warning: May contain traces of nuts.
_______________________________________________
Mozilla-rdf mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-rdf
Reply | Threaded
Open this post in threaded view
|

Re: how to create in-memory rdf datasource (multi-level) for a XUL tree?

Axel Hecht-2
In reply to this post by stevengpn
[hidden email] wrote:
> Hi, there
>
> I got problem to populate a XUL tree with an in-memory rdf data source.
> All sapmle code I've seen so far were just created a tree with only
> just one top level (eg:
> http://in.geocities.com/skexz/tuts/xul/in-memory.htm). Is anyone knows
> how to create a in-memory rdf datasource with structure like below (two
> levels):

The other alternative to using containers is to specify the containment
in the template.

http://www.xulplanet.com/references/elemref/ref_XULElement.html#attr_containment

Axel
_______________________________________________
Mozilla-rdf mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-rdf