Registry /
data / rdfxml-streaming-parser
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RdfXmlParser
✓ import { RdfXmlParser } from 'rdfxml-streaming-parser';
✗ import RdfXmlParser from 'rdfxml-streaming-parser';
RdfXmlParser is a named export, not a default export.
RdfXmlParser (CommonJS)
✓ const { RdfXmlParser } = require('rdfxml-streaming-parser');
✗ const RdfXmlParser = require('rdfxml-streaming-parser');
CommonJS `require` should destructure the named export RdfXmlParser.
RdfXmlParserOptions (TypeScript)
✓ import type { RdfXmlParserOptions } from 'rdfxml-streaming-parser';
Import types separately for type-only usage in TypeScript.
Demonstrates how to initialize RdfXmlParser, pipe a simulated data stream to it, and listen for 'data' (quads), 'version', 'error', and 'end' events to process the parsed RDF/XML.
import * as fs from 'fs';
import { RdfXmlParser } from 'rdfxml-streaming-parser';
// Create a new parser instance
const myParser = new RdfXmlParser({
baseIRI: 'http://example.org/base/', // Optional: set an initial base IRI
strict: false // Optional: allow non-strict XML parsing
});
// Assuming 'example.rdf' is an RDF/XML file in the same directory
// For a real-world scenario, you might fetch this from a URL or an upload.
// Example content for 'example.rdf':
// <?xml version="1.0"?>
// <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
// xmlns:ex="http://example.org/stuff/1.0/"
// xml:base="http://example.org/triples/">
// <rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
// <ex:prop>value</ex:prop>
// </rdf:Description>
// </rdf:RDF>
const rdfXmlContent = `<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://example.org/stuff/1.0/"
xml:base="http://example.org/triples/">
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
<ex:prop>Some property value</ex:prop>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/another">
<ex:name>Another resource</ex:name>
</rdf:Description>
</rdf:RDF>`;
// For a runnable example, let's simulate a readable stream from a string
// In a real app, you'd use fs.createReadStream or an HTTP response stream
const { Readable } = require('stream');
const stringStream = Readable.from([rdfXmlContent]);
stringStream
.pipe(myParser)
.on('data', (quad) => {
// Each 'data' event emits an RDFJS Quad object
console.log('Parsed Quad:', quad.toString());
})
.on('version', (version) => {
// Optionally listen for rdf:version attributes
console.log('RDF Version Attribute:', version);
})
.on('error', (error) => {
// Handle any parsing errors
console.error('Parsing Error:', error);
})
.on('end', () => {
// Stream has finished parsing all data
console.log('All RDF/XML data parsed successfully!');
});
Errors
Common errors & fixes
Error: Premature end of document
The input RDF/XML stream ended unexpectedly, or the document is malformed/incomplete.
fixEnsure the input stream contains complete and well-formed RDF/XML. Check for truncated files or incomplete HTTP responses. Verify the XML structure manually or with an XML validator.
TypeError: Cannot read property 'pipe' of undefined
Attempting to call `.pipe()` on an object that is not a readable stream, or the stream source (e.g., `fs.createReadStream`) failed to return a stream.
fixVerify that the object you are piping *from* is a valid Node.js Readable stream. For file operations, ensure the file path is correct and the file exists. For network requests, confirm the response object provides a readable stream.
Audit
Dependencies
@rdfjs/data-modelrequiredProvides the default RDFJS DataFactory implementation for constructing terms and quads if not explicitly overridden.