From: "Dmitry B." <[EMAIL PROTECTED]>
Subject: Can't upload RDF data to Tree from C++
Date: Monday, October 20, 2003 8:09 PM

Hello, i have the xul demo "things" from XULPlanet which describe in the
bottom of this page.

And i need dynamicaly upload  RDF data to tree from C++ code.
This is my C++ function:

nsresult __loadRDFDataToTree(nsIDOMXULElement *tree, const char *uri,
nsIString *RDFDataAsString)
{
  nsCOMPtr<nsIRDFDataSource> dataSource;
  dataSource =
do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource")
;
  if (!dataSource)
    return "Error: Can't create instance of datasource.";
  nsCOMPtr<nsIRDFXMLParser> parser =
do_CreateInstance("@mozilla.org/rdf/xml-parser;1");
   if (!parser)
    return "Error: Can't create instance of RDF parser.";
  nsCOMPtr<nsIURI> mURI;
  // In this point uri = for example 'file:///things.rdf'
  rv = NS_NewURI(getter_AddRefs(mURI), nsDependentCString(uri));
  if (NS_FAILED(rv))
    return "Error: Can't create mURI";
  parser->ParseString(dataSource, mURI, RDFDataAsString);

 nsCOMPtr<nsIXULTemplateBuilder> tempBuiler;
  element->GetBuilder(getter_AddRefs(tempBuiler));
  if (!tempBuiler)
    return "Error: Can't get builder for tree";
  nsCOMPtr<nsIRDFCompositeDataSource> compositeDataSource;
  element->GetDatabase(getter_AddRefs(compositeDataSource));
  if (!compositeDataSource)
    return "Error: Can't get composite DataSource for tree";
  compositeDataSource->AddDataSource(dataSource);
  tempBuiler->Rebuild();
}

I am execute this procedure but my tree always is empty :(
Where is my mistake?

Regards, Dmitriy


<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="treeRDF" title="RDF Tree"

xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";>
<label value="Things in my house:"/>
 <tree flex="1" width="350" height="200" id="testTree"
      datasources="rdf:null" ref="urn:things:root">
  <treecols>
    <treecol id="name" label="Name" primary="true" flex="1"/>
    <treecol id="material" label="Material" flex="1"/>
  </treecols>
  <template>
    <treechildren>
      <treeitem uri="rdf:*">
        <treerow>
          <treecell label="rdf:http://www.xulplanet.com/rdf/example#name"/>
          <treecell
label="rdf:http://www.xulplanet.com/rdf/example#material"/>
        </treerow>
      </treeitem>
    </treechildren>
  </template>
</tree>

</window>

<?xml version="1.0"?>

<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
         xmlns:things="http://www.xulplanet.com/rdf/example#";>

   <RDF:Description about="urn:things:kitchen" things:name="Kitchen"/>
   <RDF:Description about="urn:things:bedroom" things:name="Bedroom"/>
   <RDF:Description about="urn:things:basement" things:name="Basement"/>

   <RDF:Description about="urn:things:toaster" things:name="Toaster"
things:material="Aluminum"/>
   <RDF:Description about="urn:things:sink" things:name="Sink"
things:material="Steel"/>
   <RDF:Description about="urn:things:spicerack" things:name="Spice Rack"
things:material="Cedar"/>
   <RDF:Description about="urn:things:bed" things:name="Bed"
things:material="Oaks"/>
   <RDF:Description about="urn:things:lavalamp" things:name="Lava Lamp"
things:material="Lava"/>
   <RDF:Description about="urn:things:junk" things:name="Junk"
things:material="Unknown"/>
   <RDF:Description about="urn:things:morejunk" things:name="More Junk"
things:material="Unknown"/>
   <RDF:Description about="urn:things:coffin" things:name="Coffin"
things:material="Pine"/>

  <RDF:Seq about="urn:things:root">
    <RDF:li>
      <RDF:Seq about="urn:things:kitchen">
        <RDF:li resource="urn:things:toaster"/>
        <RDF:li resource="urn:things:sink"/>
        <RDF:li resource="urn:things:spicerack"/>
       </RDF:Seq>
       <RDF:Seq about="urn:things:bedroom">
         <RDF:li resource="urn:things:bed"/>
         <RDF:li resource="urn:things:lavalamp"/>
       </RDF:Seq>
       <RDF:Seq about="urn:things:basement">
         <RDF:li resource="urn:things:junk"/>
         <RDF:li resource="urn:things:morejunk"/>
         <RDF:li resource="urn:things:coffin"/>
       </RDF:Seq>
    </RDF:li>
  </RDF:Seq>

</RDF:RDF>





_______________________________________________
mozilla-embedding mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-embedding

Reply via email to