You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Matthew Pocock <tu...@gmail.com> on 2014/02/09 01:16:39 UTC

controlling RDF/XML-ABBREV output

Hi,

I'm using Jena to write out data to file as RDF/XML-ABBREV. I'm using the
prettyTypes property to ensure that my domain objects sit at the top of the
file. This works great. These XML files are eaten both by RDF-aware tools
but also some legacy tooling. The legacy tooling requires xml elements to
arrive sorted in a particular order. At the moment I'm controlling this by
writing them to the Jena model in the reverse order I want them to appear
in the file. However, this is brittle.

Is there some way to control the sorting of things within a block? For
example, by specifying a list of URIs and having Jena emit the XML in that
order.

Thanks,
Matthew

-- 
Dr Matthew Pocock
Turing ate my hamster LTD
mailto: turingatemyhamster@gmail.com

Integrative Bioinformatics Group, School of Computing Science, Newcastle
University
mailto: matthew.pocock@ncl.ac.uk

gchat: turingatemyhamster@gmail.com
msn: matthew_pocock@yahoo.co.uk
irc.freenode.net: drdozer
skype: matthew.pocock
tel: (0191) 2566550
mob: +447535664143

Re: controlling RDF/XML-ABBREV output

Posted by Matthew Pocock <tu...@gmail.com>.
Thanks Andy, I'd been a bit thick and not twigged that I could call
Model.setNsPrefix multiple times. Dho!

Matthew


On 10 February 2014 20:58, Andy Seaborne <an...@apache.org> wrote:

> On 10/02/14 17:38, Matthew Pocock wrote:
>
>> Thanks Andy - I will delve into those.
>>
>> The other thing, and I'm sure I'm just overlooking how to do this, is that
>> I have predicates from several namespaces and these have standardised
>> namespace prefixes. At the moment they are coming out as J.0 and J.1 and
>> so
>> on. How do I tell the writer about multiple prefix/namespace maps?
>>
>> Matthew
>>
>
> Hi Matthew,
>
> The prefix named come from the Model being written (which is a
> PrefixMapping).  Have a check as to whether the prefixes are defined for
> the model being written, not some wrapped encapsulated model.
>
> Are you explicitly creating a writer?
>
> A complete, minimal example would be good, as well as knowing the Jena
> version number.
>
>         Andy
>
>


-- 
Dr Matthew Pocock
Turing ate my hamster LTD
mailto: turingatemyhamster@gmail.com

Integrative Bioinformatics Group, School of Computing Science, Newcastle
University
mailto: matthew.pocock@ncl.ac.uk

gchat: turingatemyhamster@gmail.com
msn: matthew_pocock@yahoo.co.uk
irc.freenode.net: drdozer
skype: matthew.pocock
tel: (0191) 2566550
mob: +447535664143

Re: controlling RDF/XML-ABBREV output

Posted by Andy Seaborne <an...@apache.org>.
On 10/02/14 17:38, Matthew Pocock wrote:
> Thanks Andy - I will delve into those.
>
> The other thing, and I'm sure I'm just overlooking how to do this, is that
> I have predicates from several namespaces and these have standardised
> namespace prefixes. At the moment they are coming out as J.0 and J.1 and so
> on. How do I tell the writer about multiple prefix/namespace maps?
>
> Matthew

Hi Matthew,

The prefix named come from the Model being written (which is a 
PrefixMapping).  Have a check as to whether the prefixes are defined for 
the model being written, not some wrapped encapsulated model.

Are you explicitly creating a writer?

A complete, minimal example would be good, as well as knowing the Jena 
version number.

	Andy


Re: controlling RDF/XML-ABBREV output

Posted by Matthew Pocock <tu...@gmail.com>.
Thanks Andy - I will delve into those.

The other thing, and I'm sure I'm just overlooking how to do this, is that
I have predicates from several namespaces and these have standardised
namespace prefixes. At the moment they are coming out as J.0 and J.1 and so
on. How do I tell the writer about multiple prefix/namespace maps?

Matthew


On 9 February 2014 20:31, Andy Seaborne <an...@apache.org> wrote:

> Hi Matthew,
>
> Post-processing is probably the way - otherwise it's take the "Unparser"
> and "Abbreviated" classes and modify them, (it looks like the method
> wPropertyEltStar in "Unparser" is the relevant one.
>
>         Andy
>
>
>
> On 09/02/14 01:14, Martynas Jusevičius wrote:
>
>> One option is to do post-processing with XSLT. Here's a stylesheet
>> that groups and sorts resource descriptions and properties within
>> them:
>> https://github.com/Graphity/graphity-browser/blob/master/
>> src/main/webapp/static/org/graphity/client/xsl/group-sort-triples.xsl
>>
>> Martynas
>> graphityhq.com
>>
>> On Sun, Feb 9, 2014 at 1:16 AM, Matthew Pocock
>> <tu...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm using Jena to write out data to file as RDF/XML-ABBREV. I'm using the
>>> prettyTypes property to ensure that my domain objects sit at the top of
>>> the
>>> file. This works great. These XML files are eaten both by RDF-aware tools
>>> but also some legacy tooling. The legacy tooling requires xml elements to
>>> arrive sorted in a particular order. At the moment I'm controlling this
>>> by
>>> writing them to the Jena model in the reverse order I want them to appear
>>> in the file. However, this is brittle.
>>>
>>> Is there some way to control the sorting of things within a block? For
>>> example, by specifying a list of URIs and having Jena emit the XML in
>>> that
>>> order.
>>>
>>> Thanks,
>>> Matthew
>>>
>>> --
>>> Dr Matthew Pocock
>>> Turing ate my hamster LTD
>>> mailto: turingatemyhamster@gmail.com
>>>
>>> Integrative Bioinformatics Group, School of Computing Science, Newcastle
>>> University
>>> mailto: matthew.pocock@ncl.ac.uk
>>>
>>> gchat: turingatemyhamster@gmail.com
>>> msn: matthew_pocock@yahoo.co.uk
>>> irc.freenode.net: drdozer
>>> skype: matthew.pocock
>>> tel: (0191) 2566550
>>> mob: +447535664143
>>>
>>
>


-- 
Dr Matthew Pocock
Turing ate my hamster LTD
mailto: turingatemyhamster@gmail.com

Integrative Bioinformatics Group, School of Computing Science, Newcastle
University
mailto: matthew.pocock@ncl.ac.uk

gchat: turingatemyhamster@gmail.com
msn: matthew_pocock@yahoo.co.uk
irc.freenode.net: drdozer
skype: matthew.pocock
tel: (0191) 2566550
mob: +447535664143

Re: controlling RDF/XML-ABBREV output

Posted by Andy Seaborne <an...@apache.org>.
Hi Matthew,

Post-processing is probably the way - otherwise it's take the "Unparser" 
and "Abbreviated" classes and modify them, (it looks like the method 
wPropertyEltStar in "Unparser" is the relevant one.

	Andy


On 09/02/14 01:14, Martynas Jusevičius wrote:
> One option is to do post-processing with XSLT. Here's a stylesheet
> that groups and sorts resource descriptions and properties within
> them:
> https://github.com/Graphity/graphity-browser/blob/master/src/main/webapp/static/org/graphity/client/xsl/group-sort-triples.xsl
>
> Martynas
> graphityhq.com
>
> On Sun, Feb 9, 2014 at 1:16 AM, Matthew Pocock
> <tu...@gmail.com> wrote:
>> Hi,
>>
>> I'm using Jena to write out data to file as RDF/XML-ABBREV. I'm using the
>> prettyTypes property to ensure that my domain objects sit at the top of the
>> file. This works great. These XML files are eaten both by RDF-aware tools
>> but also some legacy tooling. The legacy tooling requires xml elements to
>> arrive sorted in a particular order. At the moment I'm controlling this by
>> writing them to the Jena model in the reverse order I want them to appear
>> in the file. However, this is brittle.
>>
>> Is there some way to control the sorting of things within a block? For
>> example, by specifying a list of URIs and having Jena emit the XML in that
>> order.
>>
>> Thanks,
>> Matthew
>>
>> --
>> Dr Matthew Pocock
>> Turing ate my hamster LTD
>> mailto: turingatemyhamster@gmail.com
>>
>> Integrative Bioinformatics Group, School of Computing Science, Newcastle
>> University
>> mailto: matthew.pocock@ncl.ac.uk
>>
>> gchat: turingatemyhamster@gmail.com
>> msn: matthew_pocock@yahoo.co.uk
>> irc.freenode.net: drdozer
>> skype: matthew.pocock
>> tel: (0191) 2566550
>> mob: +447535664143


Re: controlling RDF/XML-ABBREV output

Posted by Martynas Jusevičius <ma...@graphity.org>.
One option is to do post-processing with XSLT. Here's a stylesheet
that groups and sorts resource descriptions and properties within
them:
https://github.com/Graphity/graphity-browser/blob/master/src/main/webapp/static/org/graphity/client/xsl/group-sort-triples.xsl

Martynas
graphityhq.com

On Sun, Feb 9, 2014 at 1:16 AM, Matthew Pocock
<tu...@gmail.com> wrote:
> Hi,
>
> I'm using Jena to write out data to file as RDF/XML-ABBREV. I'm using the
> prettyTypes property to ensure that my domain objects sit at the top of the
> file. This works great. These XML files are eaten both by RDF-aware tools
> but also some legacy tooling. The legacy tooling requires xml elements to
> arrive sorted in a particular order. At the moment I'm controlling this by
> writing them to the Jena model in the reverse order I want them to appear
> in the file. However, this is brittle.
>
> Is there some way to control the sorting of things within a block? For
> example, by specifying a list of URIs and having Jena emit the XML in that
> order.
>
> Thanks,
> Matthew
>
> --
> Dr Matthew Pocock
> Turing ate my hamster LTD
> mailto: turingatemyhamster@gmail.com
>
> Integrative Bioinformatics Group, School of Computing Science, Newcastle
> University
> mailto: matthew.pocock@ncl.ac.uk
>
> gchat: turingatemyhamster@gmail.com
> msn: matthew_pocock@yahoo.co.uk
> irc.freenode.net: drdozer
> skype: matthew.pocock
> tel: (0191) 2566550
> mob: +447535664143