RDF/XML Format
Description
RDF/XML is an XML-based serialization format for RDF (Resource Description Framework) data. It represents RDF triples (subject-predicate-object) in XML format. RDF/XML is one of the standard RDF serialization formats.
File Extensions
.rdf- RDF/XML files.rdf.xml- RDF/XML files (alias)
Implementation Details
Reading
The RDF/XML implementation:
- Uses
lxmllibrary for XML parsing - Parses RDF Description elements
- Extracts RDF triples (subject-predicate-object)
- Groups triples by subject
- Converts RDF data to dictionaries
Writing
Writing support:
- Writes RDF
Descriptionelements (simplified RDF/XML) - Triple-oriented records use
subjectplus atripleslist
Key Features
- RDF format: Represents RDF data in XML
- Triple extraction: Extracts RDF triples
- Subject grouping: Groups triples by subject
- Nested data: Supports complex RDF structures
- XML parsing: Uses XML parsing for RDF data
Usage
from iterable import open_iterable
# Basic reading
with open_iterable('data.rdf') as source:
for row in source:
print(row) # Contains RDF triples grouped by subject
# Writing
with open_iterable('output.rdf', mode='w') as dest:
dest.write({'subject': 'http://example.org/alice', 'name': 'Alice'})
Parameters
encoding(str): File encoding (default:utf8)
Limitations
- lxml dependency: Requires
lxmlpackage - Memory usage: Entire RDF graph may be loaded into memory
- RDF complexity: Complex RDF structures may be difficult to work with
- XML complexity: Complex XML namespaces may require manual handling
Compression Support
RDF/XML files can be compressed with all supported codecs:
- GZip (
.rdf.gz) - BZip2 (
.rdf.bz2) - LZMA (
.rdf.xz) - LZ4 (
.rdf.lz4) - ZIP (
.rdf.zip) - Brotli (
.rdf.br) - ZStandard (
.rdf.zst)
Use Cases
- Semantic web: Working with semantic web data
- Linked data: Processing linked data
- Knowledge graphs: Building and querying knowledge graphs
- Metadata: Working with RDF metadata
Error Handling
- Missing dependency: optional libraries raise
ImportErrorwith an install hint (pip install 'iterabledata[<extra>]'when an extra exists). - Write mode: read-only formats raise
WriteNotSupportedErrororValueErrorwhen opened withmode="w". - Bad or unsupported input: may raise
ValueError,OSError, or library-specific errors. - See Troubleshooting for decoding, detection, and engine issues.