You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Bardo Nelgen <ma...@bnnperformances.de> on 2014/05/20 12:29:11 UTC
Language-Matching A Literal
Hi all,
it shall be really kind if someone might have a look into my following
matching issue:
I am trying to filter out a language-specific XMLLiteral using SPARQL,
cannot get the literals language property matched by the filter – and
don't have a clue why so.
Any suggestions welcome !!
This is the RDF.
<rdf:RDF xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd= "http://www.w3.org/2001/XMLSchema#"
xmlns:xliff= "urn:oasis:names:tc:xliff:document:1.2"
xmlns:timed= "http://namespaces.semaworx.org/timed#"
>
<rdf:Description rdf:about= "http://resources.semaworx.eu/timed/elements/contentincrediblyuniqueid003">
<rdf:type rdf:resource= "http://namespaces.semaworx.org/timed#versionedPayload" />
<xliff:target rdf:parseType="Literal" xml:lang="de-de"><i18n21:message key="cityAPI_teaser_subhead">Airlines, Kneipen, U-Bahn, Coffee Shops, Beauty-Stores, Heimdekor-Läden,
Sportveranstaltungen…</i18n21:message></xliff:target>
</rdf:Description>
And this the SPARQL trying to match the literal as a whole:
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX timed:<http://namespaces.semaworx.org/timed#>
PREFIX xliff:<urn:oasis:names:tc:xliff:document:1.2>
CONSTRUCT{
?versionPayload rdf:type timed:versionedPayload .
?versionPayload xliff:target ?nationalString .
}
WHERE{
?versionPayload rdf:type timed:versionedPayload .
?versionPayload xliff:target ?nationalString .
FILTER ( isLiteral(?nationalString) && langMatches( lang(?nationalString), "de-de" ) )
}
The query as above delivers no result at all.
Despite that, besides the language-matching, the rest of the query
appers to work properly:
As soon as I remove the language filter, I get a proper result; though
including matching XMLLiterals for *all* available languages – which of
course is not intended.
What am I missing !??
– Bardo
Re: Language-Matching A Literal
Posted by Joshua TAYLOR <jo...@gmail.com>.
On Tue, May 20, 2014 at 6:29 AM, Bardo Nelgen
<ma...@bnnperformances.de> wrote:
> What am I missing !??
First, your data isn't a complete RDF document, (e.g., the namespace
for i18n21 isn't declared, and there's no closing for the rdf:RDF
element. It's much easier to diagnose problems when you provide
complete working data. That said, it's easy enough to fix to get
something like this:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:i18n21="urn:foo:"
xmlns:timed="http://namespaces.semaworx.org/timed#"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<timed:versionedPayload
rdf:about="http://resources.semaworx.eu/timed/elements/contentincrediblyuniqueid003">
<xliff:target rdf:parseType="Literal"><i18n21:message
xmlns:i18n21="urn:foo:" key="cityAPI_teaser_subhead">Airlines,
Kneipen, U-Bahn, Coffee Shops, Beauty-Stores, Heimdekor-Läden,
Sportveranstaltungen…</i18n21:message></xliff:target>
</timed:versionedPayload>
</rdf:RDF>
It might be better to look at that in the Turtle serialization,
because any literals will be written in a way that's closer to what
you'd write in SPARQL, if not the same, and things like language tags
will be much more explicit.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xliff: <urn:oasis:names:tc:xliff:document:1.2> .
@prefix timed: <http://namespaces.semaworx.org/timed#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix i18n21: <urn:foo:> .
<http://resources.semaworx.eu/timed/elements/contentincrediblyuniqueid003>
a timed:versionedPayload ;
xliff:target "<i18n21:message xmlns:i18n21=\"urn:foo:\"
key=\"cityAPI_teaser_subhead\">Airlines, Kneipen, U-Bahn, Coffee
Shops, Beauty-Stores, Heimdekor-Läden,
Sportveranstaltungen…</i18n21:message>"^^rdf:XMLLiteral .
Notice that the value of the `xliff:target` property isn't a language
tagged string, but a literal of type rdf:XMLLiteral. That means that
the SPARQL function lang() will return "" for it. If you just want
the string "Airlines, Kneipen, U-Bahn, Coffee Shops, Beauty-Stores,
Heimdekor-Läden, Sportveranstaltungen…" with the language tag "de-de",
you'd instead use the code:
<http://resources.semaworx.eu/timed/elements/contentincrediblyuniqueid003>
a timed:versionedPayload ;
xliff:target "Airlines, Kneipen, U-Bahn, Coffee Shops,
Beauty-Stores, Heimdekor-Läden, Sportveranstaltungen…"@de-de .
In RDF/XML, that would be
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:i18n21="urn:foo:"
xmlns:timed="http://namespaces.semaworx.org/timed#"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<timed:versionedPayload
rdf:about="http://resources.semaworx.eu/timed/elements/contentincrediblyuniqueid003">
<xliff:target xml:lang="de-de">Airlines, Kneipen, U-Bahn, Coffee
Shops, Beauty-Stores, Heimdekor-Läden,
Sportveranstaltungen…</i18n21:message></xliff:target>
</timed:versionedPayload>
</rdf:RDF>
//JT
--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
Re: Language-Matching A Literal
Posted by Rob Vesse <rv...@dotnetrdf.org>.
An XML Literal is a Typed Literal and typed literals can't also have a
language tag
So as far as Jena (or any RDF framework for that matter is concerned) your
XML Literals do not have any language tag so you can't match on them
Rob
On 20/05/2014 11:29, "Bardo Nelgen"
<ma...@bnnperformances.de> wrote:
>
>Hi all,
>
>it shall be really kind if someone might have a look into my following
>matching issue:
>
>I am trying to filter out a language-specific XMLLiteral using SPARQL,
>cannot get the literals language property matched by the filter – and
>don't have a clue why so.
>
>Any suggestions welcome !!
>
>This is the RDF.
>
><rdf:RDF xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
> xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#"
>
> xmlns:xsd= "http://www.w3.org/2001/XMLSchema#"
>
> xmlns:xliff= "urn:oasis:names:tc:xliff:document:1.2"
>
> xmlns:timed= "http://namespaces.semaworx.org/timed#"
>
> >
>
><rdf:Description rdf:about=
>"http://resources.semaworx.eu/timed/elements/contentincrediblyuniqueid003"
>>
>
><rdf:type rdf:resource=
>"http://namespaces.semaworx.org/timed#versionedPayload" />
>
><xliff:target rdf:parseType="Literal" xml:lang="de-de"><i18n21:message
>key="cityAPI_teaser_subhead">Airlines, Kneipen, U-Bahn, Coffee Shops,
>Beauty-Stores, Heimdekor-Läden,
>
>Sportveranstaltungen…</i18n21:message></xliff:target>
>
></rdf:Description>
>
>
>And this the SPARQL trying to match the literal as a whole:
>
>PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
>PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
>PREFIX timed:<http://namespaces.semaworx.org/timed#>
>PREFIX xliff:<urn:oasis:names:tc:xliff:document:1.2>
>
>CONSTRUCT{
>
>?versionPayload rdf:type timed:versionedPayload .
>
>?versionPayload xliff:target ?nationalString .
>
>}
>
>WHERE{
>
>?versionPayload rdf:type timed:versionedPayload .
>
>?versionPayload xliff:target ?nationalString .
>
>FILTER ( isLiteral(?nationalString) && langMatches(
>lang(?nationalString), "de-de" ) )
>
>}
>
>
>The query as above delivers no result at all.
>
>Despite that, besides the language-matching, the rest of the query
>appers to work properly:
>
>As soon as I remove the language filter, I get a proper result; though
>including matching XMLLiterals for *all* available languages – which of
>course is not intended.
>
>
>What am I missing !??
>
>– Bardo
>