Combine two RDF datasets

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

Combine two RDF datasets

mbn
Hi,

Is there any way to combine two RDF datasets? I have one XML-file
dataset which I load at startup. I want to add additional triples
during runtime. The easiest way for me to create these triples is
using a string, e.g.,

==================================
var strRDFData1 = '\
<?xml version="1.0" encoding="utf-8"?>\
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\
         xmlns:email="abc://my/car#"\
         xmlns:attachment="abc://my/part#">\
<rdf:Description>\
  <car:model>Chevy</car:model>\
  <car:parts>\
    <rdf:Bag>\
      <rdf:li>\
        <rdf:Description>\
          <part:name>Some part name</part:name >\
          <part:size>12</part:size>\
        </rdf:Description>\
      </rdf:li>\
    </rdf:Bag>\
  </car:parts>\
</rdf:Description>\
</rdf:RDF>';
==================================

Then parse the string into a in memory data set. However,  I see no
way how to combine such in memory DS with the XML-file data set (which
is composed of triples like the above).

If I try to use the current XML-file data set as the destination of
the parser, the current data in the XML-file data set is __erased__
before the data in the in-memory dataset is appended. I do not want
such a thing. Could someone please help?

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

Re: Combine two RDF datasets

Axel Hecht-2
You want to put your xml datasource into a composite datasource, and add
your in-memory one to the composite one. The composite datasource well
then have the triples of both, live, as it just wraps both.

HTH

Axel

On 30.01.2009 5:46 Uhr, Mark wrote:

> Hi,
>
> Is there any way to combine two RDF datasets? I have one XML-file
> dataset which I load at startup. I want to add additional triples
> during runtime. The easiest way for me to create these triples is
> using a string, e.g.,
>
> ==================================
> var strRDFData1 = '\
> <?xml version="1.0" encoding="utf-8"?>\
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\
>           xmlns:email="abc://my/car#"\
>           xmlns:attachment="abc://my/part#">\
> <rdf:Description>\
>    <car:model>Chevy</car:model>\
>    <car:parts>\
>      <rdf:Bag>\
>        <rdf:li>\
>          <rdf:Description>\
>            <part:name>Some part name</part:name>\
>            <part:size>12</part:size>\
>          </rdf:Description>\
>        </rdf:li>\
>      </rdf:Bag>\
>    </car:parts>\
> </rdf:Description>\
> </rdf:RDF>';
> ==================================
>
> Then parse the string into a in memory data set. However,  I see no
> way how to combine such in memory DS with the XML-file data set (which
> is composed of triples like the above).
>
> If I try to use the current XML-file data set as the destination of
> the parser, the current data in the XML-file data set is __erased__
> before the data in the in-memory dataset is appended. I do not want
> such a thing. Could someone please help?
>
> Thanks

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

Re: Combine two RDF datasets

Neil-4
Axel Hecht wrote:

> You want to put your xml datasource into a composite datasource, and
> add your in-memory one to the composite one. The composite datasource
> well then have the triples of both, live, as it just wraps both.

Also note that whenever you use an RDF template you get a composite
datasource for free, so to speak.

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

Re: Combine two RDF datasets

mbn
Guys thanks for your answers but the issue is, I cannot use a composite
datasource, since I later need to save the contents of all datasets in
one single file.  That cannot be done with a composite datasource AFAIK.

The idea is as following. At startup, my extension reads an RDF file.
During execution, I need to add triples, and when TB shuts down, I
simply need to dump the xml-datasource to the file (Flush method).

Surely, I can read the whole file at startup in an in-memory dataset and
manage that as well, but that means that I have to manually save the
whole file once in a while. The Flush method only does the saving if
there was a change, and that also occurs automatically when the dataset
is no longer referenced. Doing things manually can be more costly.

My question is, how can I add triples incrementally to the XML-file
datasource, after parsing such triples from a string, or does that only
work with an in-memory dataset?

I am targeting TB 1.5

Thanks in advance


Neil wrote:
> Axel Hecht wrote:
>
>> You want to put your xml datasource into a composite datasource, and
>> add your in-memory one to the composite one. The composite datasource
>> well then have the triples of both, live, as it just wraps both.
>
> Also note that whenever you use an RDF template you get a composite
> datasource for free, so to speak.
>
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf