Skip to content

Warning When handling Hex Values #2496

@tobiasschweizer

Description

@tobiasschweizer

Hi there,

I am dealing with some warnings related to hex values.

I don't understand whether this is something which is wrong in the data or a problem in rdflib itself.
Could it be related to the leading # in the data? This seems redundant since the data is annotated as hex.

Any feedback is appreciated! Thanks.

Data (snippet):

    <edm:WebResource
            rdf:about="https://mmb-web.adlibhosting.com/ais6/webapi/wwwopac.ashx?command=getcontent&amp;server=images&amp;value=/Voorwerpen%20Adlib/0-9000/V00000-MT51.jpg">
        <ebucore:hasMimeType>image/jpeg</ebucore:hasMimeType>
        <ebucore:fileByteSize rdf:datatype="http://www.w3.org/2001/XMLSchema#long">100742</ebucore:fileByteSize>
        <ebucore:width rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">900</ebucore:width>
        <ebucore:height rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">675</ebucore:height>
        <edm:hasColorSpace>sRGB</edm:hasColorSpace>
        <edm:componentColor rdf:datatype="http://www.w3.org/2001/XMLSchema#hexBinary">#696969</edm:componentColor>
        <edm:componentColor rdf:datatype="http://www.w3.org/2001/XMLSchema#hexBinary">#C0C0C0</edm:componentColor>
        <edm:componentColor rdf:datatype="http://www.w3.org/2001/XMLSchema#hexBinary">#2F4F4F</edm:componentColor>
        <edm:componentColor rdf:datatype="http://www.w3.org/2001/XMLSchema#hexBinary">#000000</edm:componentColor>
        <edm:componentColor rdf:datatype="http://www.w3.org/2001/XMLSchema#hexBinary">#808080</edm:componentColor>
        <edm:componentColor rdf:datatype="http://www.w3.org/2001/XMLSchema#hexBinary">#A9A9A9</edm:componentColor>
        <ebucore:orientation rdf:datatype="http://www.w3.org/2001/XMLSchema#string">landscape</ebucore:orientation>
    </edm:WebResource>

Warnings:

Failed to convert Literal lexical form to value. Datatype=http://www.w3.org/2001/XMLSchema#hexBinary, Converter=<function _unhexlify at 0x108171280>
Traceback (most recent call last):
File "env/lib/python3.9/site-packages/rdflib/term.py", line 2084, in _castLexicalToPython
return conv_func(lexical) # type: ignore[arg-type]
File "env/lib/python3.9/site-packages/rdflib/term.py", line 1680, in _unhexlify
return unhexlify(value)
binascii.Error: Odd-length string
Failed to convert Literal lexical form to value. Datatype=http://www.w3.org/2001/XMLSchema#hexBinary, Converter=<function _unhexlify at 0x108171280>
Traceback (most recent call last):
File "env/lib/python3.9/site-packages/rdflib/term.py", line 2084, in _castLexicalToPython
return conv_func(lexical) # type: ignore[arg-type]
File "env/lib/python3.9/site-packages/rdflib/term.py", line 1680, in _unhexlify
return unhexlify(value)
binascii.Error: Odd-length string
Failed to convert Literal lexical form to value. Datatype=http://www.w3.org/2001/XMLSchema#hexBinary, Converter=<function _unhexlify at 0x108171280>
Traceback (most recent call last):
File "env/lib/python3.9/site-packages/rdflib/term.py", line 2084, in _castLexicalToPython
return conv_func(lexical) # type: ignore[arg-type]
File "env/lib/python3.9/site-packages/rdflib/term.py", line 1680, in _unhexlify
return unhexlify(value)
binascii.Error: Odd-length string
Failed to convert Literal lexical form to value. Datatype=http://www.w3.org/2001/XMLSchema#hexBinary, Converter=<function _unhexlify at 0x108171280>
Traceback (most recent call last):
File "env/lib/python3.9/site-packages/rdflib/term.py", line 2084, in _castLexicalToPython
return conv_func(lexical) # type: ignore[arg-type]
File "env/lib/python3.9/site-packages/rdflib/term.py", line 1680, in _unhexlify
return unhexlify(value)
binascii.Error: Odd-length string
Failed to convert Literal lexical form to value. Datatype=http://www.w3.org/2001/XMLSchema#hexBinary, Converter=<function _unhexlify at 0x108171280>
Traceback (most recent call last):
File "env/lib/python3.9/site-packages/rdflib/term.py", line 2084, in _castLexicalToPython
return conv_func(lexical) # type: ignore[arg-type]
File "env/lib/python3.9/site-packages/rdflib/term.py", line 1680, in _unhexlify
return unhexlify(value)
binascii.Error: Odd-length string
Failed to convert Literal lexical form to value. Datatype=http://www.w3.org/2001/XMLSchema#hexBinary, Converter=<function _unhexlify at 0x108171280>
Traceback (most recent call last):
File "env/lib/python3.9/site-packages/rdflib/term.py", line 2084, in _castLexicalToPython
return conv_func(lexical) # type: ignore[arg-type]
File "env/lib/python3.9/site-packages/rdflib/term.py", line 1680, in _unhexlify
return unhexlify(value)
binascii.Error: Odd-length string

Steps to reproduce:

  • download out-01.xml.txt
  • rename to xml (remove txt extension)
  • run from REPL:
>>> from rdflib import Graph
>>> g = Graph()
>>> g.parse('out-01.xml')

I originally got this data from an OAI-PMH endpoint with embedded RDF/XML, see https://api.europeana.eu/oai/record?verb=ListRecords&set=79&metadataPrefix=edm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconcept: RDF Literalconfirmation neededThe issue raises a potential bug that needs to be confirmed.format: RDF/XMLRelated to the RDF/XML format.parsingRelated to a parsing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions