Re: Empty <bnode/> and validating SPARQL XML results

I think the informal intent is that it is not empty but empty would work 
just the same.

The content is the document scoped label for the bnode.

It could be the empty string (as in weird, but possible) and it would be 
the label for one bnode, so not Turtle like [] generaing a fresh one 
each time.

If there are two uses of "" as the label, then they are the same bnode,

<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
   <head>
     <variable name="s"/>
   </head>
   <results>
     <result>
       <binding name="s">
         <bnode/>
       </binding>
     </result>
     <result>
       <binding name="s">
         <bnode/>
       </binding>
     </result>
   </results>
</sparql>

--------
| s    |
========
| _:b0 |
| _:b0 |
--------

Two rows, each with the same bnode in it.

That does not make it a good idea!

     Andy

On 08/10/2020 01:50, Jeen Broekstra wrote:
> I'm a bit rusty on my XML Schema, but the (normative) definition (see 
> https://www.w3.org/2007/SPARQL/result.xsd) of the <bnode> element is 
> that it is of type string:
> 
>     <xs:element name="bnode" type="xs:string"/>
> 
> I'm reasonably sure this requires a non-empty value. IIRC a non-empty 
> element is only allowed if the element is defined as a complex type, 
> with a restriction.
> 
> So I agree that the informal intent in the spec and the normative 
> definition both say that a bnode element should always have a label 
> value, and cannot be an empty element.
> 
> Cheers,
> 
> Jeen
> 
> 
> On Wed, Oct 7, 2020, at 21:45, Martynas Jusevičius wrote:
>> Hi,
>>
>> I'm getting some SPARQL XML results from Dydra with empty
>> <bnode></bnode> elements.
>>
>> This is something I hadn't encountered before, and also impractical if
>> the nodes do not have the labels ready.
>>
>> I looked at the spec but found only
>> "<binding><bnode>I</bnode></binding>" which kind of suggests there
>> should be a label.
>>
>> To be sure, I decided to try validating the XML results against the
>> schema. I downloaded both
>> https://www.w3.org/2007/SPARQL/result.xsd
>> https://www.w3.org/2007/SPARQL/result.rng
>>
>> and a random test file sq02.srx and attempted to validate against the
>> RNG and the XSD, but both failed inexplicably:
>>
>> $ xmlstarlet val -r result.rng -e sq02.srx
>> sq02.srx:12.10: Did not expect element sparql there
>> sq02.srx:12.10: Did not expect element head there
>> sq02.srx:12.10: Did not expect element variable there
>> sq02.srx:12.10: Did not expect element variable there
>> sq02.srx:12.10: Did not expect element results there
>> sq02.srx:12.10: Did not expect element result there
>> sq02.srx:12.10: Did not expect element binding there
>> sq02.srx:12.10: Did not expect element uri there
>> sq02.srx:12.10: Did not expect text in element  TODO  content
>> sq02.srx:12.10: Did not expect element binding there
>> sq02.srx:12.10: Did not expect element uri there
>> sq02.srx:12.10: Did not expect text in element  TODO  content
>> sq02.srx - invalid
>>
>> $ xmlstarlet val -s result.xsd -e sq02.srx
>> sq02.srx:1.55: Element
>> '{http://www.w3.org/2005/sparql-results#}sparql': No matching global
>> declaration available for the validation root.
>> sq02.srx - invalid
>>
>> So the questions:
>> - is <bnode/> allowed?
>> - how does one validate? What are the schemas for if they don't work
>> -- or is it xmlstarlet?
>>
>>
>> Martynas
>>
>>
> 

Received on Thursday, 8 October 2020 12:13:51 UTC