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

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 00:51:01 UTC