Correct, I've registered only the writer but attempting to read
JSON-LD. That is because content negotiation is based on
RDFLanguages.getRegisteredLanguages() and therefore JSON-LD is
included in Accept headers.

I guess I will need to keep track of actual readable/writable types
separately in order to avoid this situation.

On Tue, Dec 22, 2015 at 1:55 PM, Andy Seaborne <a...@apache.org> wrote:
> On 22/12/15 12:46, Martynas Jusevičius wrote:
>>
>> I'm stuck with this version because the latest SPIN API (1.4.0) is
>> using it and last I heard Holger said he's not planning an upgrade :/
>
>
> Does it matter?
> 2.12.0 has JSON-LD.
>
>>
>> I registered the writer like this:
>>
>> RDFLanguages.register(RDFLanguages.JSONLD);
>> RDFWriterRegistry.register(new RDFFormat(RDFLanguages.JSONLD), new
>
>
> So you have only registered the writer.
>
> (Why are you trying to read JSON-LD?)
>
>> JSONLDWriterFactory(jsonLdTemplates));
>>
>>
>> https://github.com/Graphity/graphity-client/blob/master/src/main/java/org/graphity/client/Application.java#L145
>>
>> I can do a pre-check by attempting
>> ModelFactory.createDefaultModel().getReader() and catching the
>> exception. But it's not very elegant.
>
>
> That seems to be a way of doing it.
>
>
>         Andy
>
>
>>
>> On Tue, Dec 22, 2015 at 1:35 PM, Andy Seaborne <a...@apache.org> wrote:
>>>
>>> Unclear.
>>>
>>> 1/ 2.11.0 is old.  Use a later version with JSON-LD built-in.
>>>
>>> 2/ You may need to use RDFDataMgr.
>>>
>>> Not sure at 2.11.old whether Lang registration interacted with the Jena
>>> RDFReaderFImpl.
>>>
>>> 3/ Not clear what you registered and how.
>>>
>>> 4/ Did you call RIOT.init()? Maybe needed.
>>>
>>>    Andy
>>>
>>>
>>>
>>> On 21/12/15 17:25, Martynas Jusevičius wrote:
>>>>
>>>>
>>>> Hey,
>>>>
>>>> I have a situation where I register a new Lang (JSON-LD) in Jena
>>>> 2.11.0 but I only have a Writer for it, not a Reader. How can I check
>>>> whether Reader exists for a certain Lang before doing the actual read?
>>>>
>>>> Right now I get an exception:
>>>>
>>>> com.hp.hpl.jena.shared.NoReaderForLangException: JSON-LD
>>>> at
>>>>
>>>> com.hp.hpl.jena.rdf.model.impl.RDFReaderFImpl.getReader(RDFReaderFImpl.java:100)
>>>> at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:274)
>>>>
>>>> Thanks,
>>>>
>>>> Martynas
>>>>
>>>
>

Reply via email to