my problem is very simple:
I have a source my:g1
that contains:
my:a1 my:b "literal 1"
Then I have a second source my:g2
that contains:
my:a2 my:b my:c.
my:c rdfs:label "literal 2"
how can I set a SPARQL query that produces something like:
| ?a | ?b | ?literal |
|-------|-------|-------------|
| my:a1 | my:b | "literal 1" |
| my:a2 | my:b | "literal 2" |
ie. how can i tell sparql to use the same variable for both "literal 1"
and "literal 2"
: I'm looking for something like
Select ?a ?b ?literal
where {
if (?g = my:g1) then
GRAPH ?g { ?a ?b ?literal}
else if (?g = my:g2) then
GRAPH ?g { ?a ?b ?c. ?c rdfs:label ?literal}
}
NOTE: I know that this query is horribly wrong, but is just to clarify my intention
EDIT:
in this specific case a "union" statement like
select ?a ?b ?literal
where {
{
GRAPH my:g1 { ?a ?b ?literal}
}
union
{
GRAPH my:g2 { ?a ?b ?c. ?c rdfs:label ?literal}
}
}
would work, but is not my "real" case. There are any other solutions?