Re: Replacement for org.apache.jena.rdfxml.xmloutput.impl.Basic

2022-12-15 Thread Andy Seaborne

https://github.com/apache/jena/blob/main/jena-examples/src/main/java/arq/examples/riot/ExRIOT_RDFXML_WriteProperties.java

On 15/12/2022 12:49, Martynas Jusevičius wrote:

Hi,

org.apache.jena.rdfxml.xmloutput.impl.Basic is gone in 4.6.1.

How do I rewrite the following code then?

 RDFWriterI writer = new Basic();
 writer.setProperty("allowBadURIs", true); // round-tripping
RDF/POST with user input may contain invalid URIs
writer.write(model, baos, null);

Thanks.


Re: SHACLC and RDFLanguages

2022-12-15 Thread Martynas Jusevičius
I was looking into this again... I see that RDFParserRegistry already
has the required collections langTriples and langQuads.

I think simply adding accessors for them would solve my use case.
Something like this maybe?

public static Set registeredLangTriples()
{
return Collections.unmodifiableSet(langTriples);
}

public static Set registeredLangQuads()
{
return Collections.unmodifiableSet(langQuads);
}


I don't see a similar collection under ResultSetReaderRegistry though?

On Mon, May 23, 2022 at 6:04 PM Andy Seaborne  wrote:
>
> PRs welcome.
>
> On 23/05/2022 08:51, Martynas Jusevičius wrote:
> > Could RDFParserRegistry::getRegistered and
> > ResultSetReaderRegistry::getRegistered be added?
>
> Consistent naming would be registered().
>
>  Andy
>
> > On Fri, May 20, 2022 at 9:01 PM Andy Seaborne  wrote:
> >>
> >>
> >>
> >> On 20/05/2022 14:05, Martynas Jusevičius wrote:
> >>> Andy, is that correct?
> >>
> >> Yes
> >>
> >>   Andy
> >>
> >>>
> >>> On Tue, May 17, 2022 at 1:33 PM Martynas Jusevičius
> >>>  wrote:
> 
>  On Tue, May 17, 2022 at 1:19 PM Andy Seaborne  wrote:
> >
> > RDFLanguages is a general registry of names (Lang's) in the system.
> >
> > It is not for functionality.
> >
> > RDFParserRegistry
> > RDFWriterRegistry
> > RowSetReaderRegistry, ResultSetReaderRegistry
> > RowSetWriterRegistry, ResultSetWriterRegistry
> > StreamRDFWriter
> >
> > A Lang needs looking up in a registry to see if there is support for it.
> 
>  Thanks, I didn't know these existed.
> 
>  But there are no RDFParserRegistry::getRegistered or
>  ResultSetReaderRegistry::getRegistered methods?
> 
>  So do I still need to iterate RDFLanguages::getRegistered and check
>  each Lang against
>  RDFParserRegistry::isRegistered/ResultSetReaderRegistry::isRegistered?
> 
> >
> >Andy
> >
> > On 17/05/2022 09:54, Martynas Jusevičius wrote:
> >> Hi,
> >>
> >> After upgrading from 4.3.2 to 4.5.0, some of our RDF writing code
> >> started failing.
> >>
> >> It seems that this is due to RDFLanguages.isTriples(Lang.SHACLC)
> >> returning true, which messes up our content negotiation as it attempts
> >> to write Models as SHACLC. Can this be rectified?
> >>
> >> The RDFLanguages registry is a bit of an oxymoron in general. Right
> >> now it's a bag of all sorts of syntaxes Jena supports, half of which
> >> are not even "RDF languages". We need to iterate and filter the
> >> languages just to know which ones can be used to read/write Models,
> >> which can be used for ResultSets etc.:
> >> https://github.com/AtomGraph/Core/blob/master/src/main/java/com/atomgraph/core/MediaTypes.java#L86
> >> Wouldn't it make sense to have separate registries depending on the
> >> entity types they apply to?
> >>
> >> Thanks.
> >>
> >> Martynas


Re: Replacement for CSVInput and TSVInput?

2022-12-15 Thread Martynas Jusevičius
Thanks.

On Mon, Dec 12, 2022 at 7:55 PM Andy Seaborne  wrote:
>
> ResultsSetMgr which uses ResultsReader
>
>
> On 12/12/2022 15:45, Martynas Jusevičius wrote:
> > Hi,
> >
> > I'm upgrading Jena 4.5.0 to 4.6.1.
> >
> > I can see that org.apache.jena.sparql.resultset.CSVInput is gone and
> > org.apache.jena.sparql.resultset.TSVInput is deprecated.
> >
> > What are the replacements for them?
> >
> > My code was the following:
> >
> >  if 
> > (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_XML_TYPE))
> >  return
> > ResultSetFactory.makeRewindable(ResultSetFactory.fromXML(in));
> >  if 
> > (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_JSON_TYPE))
> >  return
> > ResultSetFactory.makeRewindable(ResultSetFactory.fromJSON(in));
> >  if 
> > (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_CSV_TYPE))
> >  return ResultSetFactory.makeRewindable(CSVInput.fromCSV(in));
> >  if 
> > (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_CSV_TYPE))
> >  return ResultSetFactory.makeRewindable(TSVInput.fromTSV(in));
> >
> > Thanks.
> >
> > Martynas
> > atomgraph.com


Replacement for org.apache.jena.rdfxml.xmloutput.impl.Basic

2022-12-15 Thread Martynas Jusevičius
Hi,

org.apache.jena.rdfxml.xmloutput.impl.Basic is gone in 4.6.1.

How do I rewrite the following code then?

RDFWriterI writer = new Basic();
writer.setProperty("allowBadURIs", true); // round-tripping
RDF/POST with user input may contain invalid URIs
   writer.write(model, baos, null);

Thanks.