{"library":"rdfxml-streaming-parser","title":"RDF/XML Streaming Parser","description":"rdfxml-streaming-parser is a JavaScript library designed for efficient, streaming parsing of RDF/XML documents into RDFJS-compliant quads. Currently at version 3.2.0, it maintains an active release schedule with minor updates. Its core functionality revolves around acting as a Node.js Transform stream, allowing developers to pipe data streams directly or feed XML string chunks manually. This streaming approach is a key differentiator, enabling the processing of large RDF/XML datasets without requiring the entire document to be loaded into memory. The library also integrates with the broader RDF.js ecosystem by implementing the Sink interface, providing flexibility in how streams are consumed. It ships with comprehensive TypeScript types and configurable options for data factory, base IRI, default graph, and XML parsing strictness.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install rdfxml-streaming-parser"],"cli":null},"imports":["import { RdfXmlParser } from 'rdfxml-streaming-parser';","const { RdfXmlParser } = require('rdfxml-streaming-parser');","import type { RdfXmlParserOptions } from 'rdfxml-streaming-parser';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as fs from 'fs';\nimport { RdfXmlParser } from 'rdfxml-streaming-parser';\n\n// Create a new parser instance\nconst myParser = new RdfXmlParser({\n  baseIRI: 'http://example.org/base/', // Optional: set an initial base IRI\n  strict: false // Optional: allow non-strict XML parsing\n});\n\n// Assuming 'example.rdf' is an RDF/XML file in the same directory\n// For a real-world scenario, you might fetch this from a URL or an upload.\n// Example content for 'example.rdf':\n// <?xml version=\"1.0\"?>\n// <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n//          xmlns:ex=\"http://example.org/stuff/1.0/\"\n//          xml:base=\"http://example.org/triples/\">\n//   <rdf:Description rdf:about=\"http://www.w3.org/TR/rdf-syntax-grammar\">\n//     <ex:prop>value</ex:prop>\n//   </rdf:Description>\n// </rdf:RDF>\n\nconst rdfXmlContent = `<?xml version=\"1.0\"?>\n<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n         xmlns:ex=\"http://example.org/stuff/1.0/\"\n         xml:base=\"http://example.org/triples/\">\n  <rdf:Description rdf:about=\"http://www.w3.org/TR/rdf-syntax-grammar\">\n    <ex:prop>Some property value</ex:prop>\n  </rdf:Description>\n  <rdf:Description rdf:about=\"http://example.org/another\">\n    <ex:name>Another resource</ex:name>\n  </rdf:Description>\n</rdf:RDF>`;\n\n// For a runnable example, let's simulate a readable stream from a string\n// In a real app, you'd use fs.createReadStream or an HTTP response stream\nconst { Readable } = require('stream');\nconst stringStream = Readable.from([rdfXmlContent]);\n\nstringStream\n  .pipe(myParser)\n  .on('data', (quad) => {\n    // Each 'data' event emits an RDFJS Quad object\n    console.log('Parsed Quad:', quad.toString());\n  })\n  .on('version', (version) => {\n    // Optionally listen for rdf:version attributes\n    console.log('RDF Version Attribute:', version);\n  })\n  .on('error', (error) => {\n    // Handle any parsing errors\n    console.error('Parsing Error:', error);\n  })\n  .on('end', () => {\n    // Stream has finished parsing all data\n    console.log('All RDF/XML data parsed successfully!');\n  });","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}