storing in-memory RDF

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

storing in-memory RDF

pawel-12
hi,
i've found in mozilla XPFE toolkit (http://www.mozilla.org/xpfe/xulrdf.htm)
a few words about storing RDF to XUL
"[...]If the XUL stream came from a remote site, then RDF has no choice
but to make a local annotation on the graph. If the XUL stream came from
a local file, then RDF can either locally annotate the graph (just as
before), or it can serialize the XUL and write over the original file
(thus allowing local changes to a local file to be reflected right in
the XUL).[...]".

Could You explain me how to get to RDF created by XUL file loaded to chrome.

this is my sample code. what's wrong

-- start here --
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="w1" align="start"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

     <script type="application/x-javascript">
<![CDATA[
     var file_to_save='d:\\test001.xul';

     function m1(event)
     {
         var file =
Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
         file.initWithPath(plik_do_zapisu);
         if(!file.exists()) {
             file.create(
Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
         }
         var output =
Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(
Components.interfaces.nsIFileOutputStream );
         output.init( file, 0x04 | 0x08 | 0x20, 420, 0 );

         var
RDF=Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(Components.interfaces.nsIRDFService);

         serializer = '@mozilla.org/rdf/xml-serializer;1';
         s =
Components.classes[serializer].createInstance(Components.interfaces.nsIRDFXMLSerializer);
         s.init(RDF);
 
s.QueryInterface(Components.interfaces.nsIRDFXMLSource).Serialize(output);

         output.close();
     }
]]>
</script>
     <button label="{button label}" onclick="m1(event);"/>
</window>

-- cut here --

thanks

        regards

                pawel
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: storing in-memory RDF

pawel-12
in previous message was small error (not in oryginal program)
file_to_save == plik_do_zapisu (in polish, error from translation of
source code)

  -- start here --
  <?xml version="1.0"?>
  <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  <window id="w1" align="start"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

      <script type="application/x-javascript">
  <![CDATA[
      var file_to_save='d:\\test001.xul';

      function m1(event)
      {
          var file =
 
Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);


          file.initWithPath(file_to_save);
          if(!file.exists()) {
              file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE,
  420 );
          }
          var output =
 
Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(

  Components.interfaces.nsIFileOutputStream );
          output.init( file, 0x04 | 0x08 | 0x20, 420, 0 );

          var
 
RDF=Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(Components.interfaces.nsIRDFService);



          serializer = '@mozilla.org/rdf/xml-serializer;1';
          s =
 
Components.classes[serializer].createInstance(Components.interfaces.nsIRDFXMLSerializer);


          s.init(RDF);

  s.QueryInterface(Components.interfaces.nsIRDFXMLSource).Serialize(output);

          output.close();
      }
  ]]>
  </script>
      <button label="{button label}" onclick="m1(event);"/>
  </window>

  -- cut here --

  thanks

      regards

          pawel
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: storing in-memory RDF

Neil-4
In reply to this post by pawel-12
[hidden email] wrote:

> Could You explain me how to get to RDF created by XUL file loaded to
> chrome.

Not sure what you're trying to achieve, but if you use RDF.GetDataSource
with a file URL and then modify the RDF you can update the file by
calling
ds.QueryInterface(Components.interfaces.nsIRemoteDataSource).Flush();

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

Re: storing in-memory RDF

pawel-12
Neil wrote:

> [hidden email] wrote:
>
>> Could You explain me how to get to RDF created by XUL file loaded to
>> chrome.
>
> Not sure what you're trying to achieve, but if you use RDF.GetDataSource
> with a file URL and then modify the RDF you can update the file by
> calling
> ds.QueryInterface(Components.interfaces.nsIRemoteDataSource).Flush();
>
hi,
I'm trying to write simple RAD IDE app for XUL.I've found problem how to
flush XUL back to file.
let's take 2 files main_ide.xul and app.xul.
problem is how or can i open app.xul to app_RDF and main_ide_RDF created
from main_ide.xul. Next those two RDF (app_RDF and main_ide_RDF i'd like
to aggregate in one app).After all i'd like to flush back part of RDF
tree which belongs to app_RDF back to app.XUL.
Does it clear what i'm trying to achieve?

        Regards
                pawel
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: storing in-memory RDF

pawel-12
i've found solution without playing with RDF.
answer is:
1) create new document
2) copy fragment of XUL tree to document created at 1)
3) serialize new created document do XUL
i know that this is partial solution (only storing part of XUL tree to file)

thanks for help

        best regards

                pawel
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf