{"id":20564026,"url":"https://github.com/comake/rmlmapper-js","last_synced_at":"2026-02-28T22:31:55.114Z","repository":{"id":44559486,"uuid":"512585739","full_name":"comake/rmlmapper-js","owner":"comake","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-07T21:20:46.000Z","size":3209,"stargazers_count":6,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-28T07:55:50.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/comake.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-11T01:59:19.000Z","updated_at":"2024-12-02T06:20:21.000Z","dependencies_parsed_at":"2024-06-21T15:34:01.829Z","dependency_job_id":"4d28b332-0650-4c82-b0a1-1669493805ea","html_url":"https://github.com/comake/rmlmapper-js","commit_stats":{"total_commits":322,"total_committers":11,"mean_commits":"29.272727272727273","dds":0.4565217391304348,"last_synced_commit":"42212c7e8a3335ddcd239dba5296d92c6f27c0df"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/comake/rmlmapper-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comake%2Frmlmapper-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comake%2Frmlmapper-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comake%2Frmlmapper-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comake%2Frmlmapper-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/comake","download_url":"https://codeload.github.com/comake/rmlmapper-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comake%2Frmlmapper-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29953287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T18:42:55.706Z","status":"ssl_error","status_checked_at":"2026-02-28T18:42:48.811Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T04:23:32.189Z","updated_at":"2026-02-28T22:31:55.091Z","avatar_url":"https://github.com/comake.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RML Mapper JS\n\nThis library is a javascript implementation of a mapper for the [RDF Mapping Language (RML)](http://rml.io/spec.html).\n\nAs of now, this library is almost an exact copy of an old javascript RML mapper, [RocketRML](https://github.com/semantifyit/RocketRML). RocketRML is not actively maintained aside from occasional bug fixes and could benefit from improvements to code quality and the addition of typesafety (eg. via Typescript). To that effect, we are planning lots of refactoring and/or a complete rewrite of this library.\n\nThe major difference between this library and RocketRML is a change to make it browser compatible. This includes the removal of the dependency on Node.js native modules like `fs` and `path`.\n\n## Installation\n\nVia npm or yarn:\n\n```shell\nnpm install @comake/rmlmapper-js\n```\n```shell\nyarn add @comake/rmlmapper-js\n```\n\n## Support\n\n\n⚠️ **Note**: The documentation below is directly copied from the RocketRML repo. Some of it may be out of date.\n\n\n## RML Vocabulary\nthe following list contains the current supported classes.\n\n\n    rr:TriplesMap is the class of triples maps as defined by R2RML.\n    rml:LogicalSource is the class of logical sources.\n    rr:SubjectMap is the class of subject maps.\n    rr:PredicateMap is the class of predicate maps.\n    rr:ObjectMap is the class of object maps.\n    rr:PredicateObjectMap is the class of predicate-object maps.\n    rr:RefObjectMap is the class of referencing object maps.\n    rml:referenceFormulation is the class of supported reference formulations.\n    rr:Join is the class of join conditions.\n\nMissing:\n\n    rr:R2RMLView is the class of R2RML views.\n    rr:BaseTableOrView is the class of SQL base tables or views.\n    rr:GraphMap is the class of graph maps.\n\n\n\n## Querying languages\n\nThe mapper supports XML, JSON and CSV as input format. For querying the data, [JSONPath](https://www.npmjs.com/package/jsonpath-plus) (json), [XPath](https://www.npmjs.com/package/xpath) (xml) and [csvjson](https://www.npmjs.com/package/csvjson) (csv) are used. Since JSON is supported natively by javascript, it has a huge speed benefit compared to XML.\n\nTherefore, the mapper also contains a [C++ version](https://github.com/ThibaultGerrier/XpathIterator) (which uses [pugixml](https://pugixml.org/)) of the XML-parser which is disabled by default, but can be enabled via the options parameter `xpathLib: 'pugixml'`.\n\nXPath 3.1 is available through [fontoxpath](https://www.npmjs.com/package/fontoxpath) and must be enabled through the option: `xpathLib: 'fontoxpath'`\n\n## How it works\n\nThis library has two main entry point functions: the `parseTurtle` function and the `parseJsonLd` function. There is also a deprecated `parse` function for backwards compatibility. It is an alias for `parseTurtle`.\n\n#### `parseTurtle`\n\n**Parameters**\n\n| Parameter | Type | Required | Description |\n| :--- | :--- | :--- | :--- |\n| `mapping` | `string` | Required | An RML Mapping serialized as a string in the [Turtle](https://www.w3.org/TR/turtle/) format. |\n| `inputFiles` | `object` | Required | A collection of files keyed on the filename they represent in the mapping.  |\n| `options` | `object` |   | A ParserOptions object (defined below). |\n\n#### `parseJsonLd`\n\n**Parameters**\n\n| Parameter | Type | Required | Description |\n| :--- | :--- | :--- | :--- |\n| `mapping` | `string` | Required | An RML Mapping serialized as a JSON object in the [JSON-LD](https://json-ld.org/) format. |\n| `inputFiles` | `object` | Required | A collection of files keyed on the filename they represent in the mapping.  |\n| `options` | `object` |   | A ParserOptions object (defined below). |\n\n\nBoth `parseTurtle` and `parseJsonLd` return a promise, which resolves to the resulting output.\n\n**ParserOptions**\n\nThese are the available options for parsing mappings (in Typescript):\n\n```typescript\nexport interface ParseOptions {\n  /**\n   * A JSON-LD context to compact the output with\n   */\n  compact?: ContextDefinition;\n  /**\n   * Option to output triples as N-Quads instead of JSON-LD\n   */\n  toRDF?: boolean;\n  /**\n   * Replaces \"\\@id\" references with nested elements. JSON-LD only.\n   */\n  replace?: boolean;\n  /**\n   * Remove xmlns in xml documents (for easier xPaths)\n   */\n  removeNameSpace?: Record\u003cstring, string\u003e;\n  /**\n   * Xpath evaluator library\n   */\n  xpathLib?: 'default' | 'xpath' | 'pugixml' | 'fontoxpath';\n  /**\n   * Predefined functions which can be used in mappings\n   */\n  functions?: Record\u003cstring, (args: any | any[]) =\u003e any\u003e;\n  /**\n   * Do not add triples for empty strings\n   */\n  ignoreEmptyStrings?: boolean;\n  /**\n   * Ignore values from the input\n   */\n  ignoreValues?: string[];\n  /**\n   * CSV options\n   */\n  csv?: {\n    delimiter?: string;\n  };\n  /**\n   * The default \"\\@language\" to use in the output\n   */\n  language?: string;\n}\n```\n\n## Usage\n\n```typescript\nimport * as RmlMapper from '@comake/rmlmapper-js';\n\nconst inputFiles = {\n  'input.json': '{ \"name\": \"Adler\" }'\n}\n\nconst options = {\n  toRDF: true,\n  replace: false,\n};\n\n// With a Turtle Mapping\nconst turtleMapping = `\n  @prefix rr: \u003chttp://www.w3.org/ns/r2rml#\u003e .\n  @prefix rml: \u003chttp://semweb.mmlab.be/ns/rml#\u003e .\n  @prefix ql: \u003chttp://semweb.mmlab.be/ns/ql#\u003e .\n\n  \u003c#Mapping\u003e rml:logicalSource [\n    rml:source \"input.json\";\n    rml:referenceFormulation ql:JSONPath;\n    rml:iterator \"$\".\n  ];\n`;\n\nconst turtleMappingResult = await RmlMapper.parseTurtle(turtleMapping, inputFiles, options);\n\n// With a JSON-LD Mapping\nconst jsonLdMapping = {\n  '@id': 'https://example.com/#Mapping',\n  '@type': 'http://www.w3.org/ns/r2rml#TriplesMap',\n  'http://semweb.mmlab.be/ns/rml#logicalSource': {\n    'http://semweb.mmlab.be/ns/rml#source': 'input.json',\n    'http://semweb.mmlab.be/ns/rml#referenceFormulation': 'http://semweb.mmlab.be/ns/ql#JSONPath',\n    'http://semweb.mmlab.be/ns/rml#iterator': '$'\n  }\n}\n\nconst jsonLdMappingResult = await RmlMapper.parseJsonLd(jsonLdMapping, inputFiles, options);\n```\n\n## Example\nBelow there is shown a very simple example with no nested data and no arrays.\n\nAdditional examples can be seen in the tests folder.\n\n#### Input\n\n```json\n{\n  \"name\":\"Tom A.\",\n  \"age\":15\n}\n```\n\n\n#### Turtle mapfile\n\n```ttl\n@prefix rr: \u003chttp://www.w3.org/ns/r2rml#\u003e .\n@prefix rml: \u003chttp://semweb.mmlab.be/ns/rml#\u003e .\n@prefix schema: \u003chttps://schema.org/\u003e .\n@prefix ql: \u003chttp://semweb.mmlab.be/ns/ql#\u003e .\n\n\u003c#LOGICALSOURCE\u003e\n  rml:source \"input.json\";\n  rml:referenceFormulation ql:JSONPath;\n  rml:iterator \"$\".\n\n\u003c#Mapping\u003e\n  rml:logicalSource \u003c#LOGICALSOURCE\u003e;\n\n  rr:subjectMap [\n    rr:termType rr:BlankNode;\n    rr:class schema:Person;\n  ];\n\n  rr:predicateObjectMap [\n      rr:predicate schema:name;\n      rr:objectMap [ rml:reference \"name\" ];\n  ];\n\n  rr:predicateObjectMap [\n      rr:predicate schema:age;\n      rr:objectMap [ rml:reference \"age\" ];\n  ].\n\n```\n\n#### Output\n```json\n[{\n  \"@type\": \"https://schema.org/Person\",\n  \"https://schema.org/name\": \"Tom A.\",\n  \"https://schema.org/age\": 15\n}]\n```\n\n## Functions:\nThis library also allows the user to define javascript functions beforehand and pass them through the options parameter. These functions can be used within an RML Mapping according to the [FNO specification](https://fno.io/rml/).\n\nAn example how this works can be seen below:\n\n#### Input\n\n\n```json\n{\n  \"name\":\"Tom A.\",\n  \"age\":15\n}\n```\n\n\n#### Turtle mapfile\n\nThe mapfile must also specify the input source path.\n\n```ttl\n@prefix rr: \u003chttp://www.w3.org/ns/r2rml#\u003e .\n@prefix xsd: \u003chttp://www.w3.org/2001/XMLSchema#\u003e .\n@prefix rml: \u003chttp://semweb.mmlab.be/ns/rml#\u003e .\n@prefix schema: \u003chttps://schema.org/\u003e .\n@prefix ql: \u003chttp://semweb.mmlab.be/ns/ql#\u003e .\n@prefix fnml: \u003chttp://semweb.mmlab.be/ns/fnml#\u003e .\n@prefix fno: \u003chttp://w3id.org/function/ontology#\u003e .\n@prefix grel: \u003chttp://users.ugent.be/~bjdmeest/function/grel.ttl#\u003e .\n\n\u003c#LOGICALSOURCE\u003e\n  rml:source \"input.json\";\n  rml:referenceFormulation ql:JSONPath;\n  rml:iterator \"$\".\n\n\u003c#Mapping\u003e\n  rml:logicalSource \u003c#LOGICALSOURCE\u003e;\n\n  rr:subjectMap [\n    rr:termType rr:BlankNode;\n    rr:class schema:Person;\n  ];\n\n  rr:predicateObjectMap [\n    rr:predicate schema:name;\n    rr:objectMap [ rml:reference \"name\" ];\n  ];\n\n  rr:predicateObjectMap [\n    rr:predicate schema:description;\n    rr:objectMap  \u003c#FunctionMap\u003e;\n  ].\n\n\u003c#FunctionMap\u003e\n  fnml:functionValue [\n    rml:logicalSource \u003c#LOGICALSOURCE\u003e ;\n    rr:predicateObjectMap [\n      rr:predicate fno:executes ;\n      rr:objectMap [ rr:constant grel:createDescription ]\n    ] ;\n    rr:predicateObjectMap [\n      rr:predicate grel:inputString ;\n      rr:objectMap [ rml:reference \"name\" ]\n    ];\n    rr:predicateObjectMap [\n      rr:predicate grel:inputString ;\n      rr:objectMap [ rml:reference \"age\" ]\n    ];\n  ].\n\n```\n\nwhere the option parameter looks like this:\n```typescript\n  const options = {\n    functions: {\n      'http://users.ugent.be/~bjdmeest/function/grel.ttl#createDescription': (data) =\u003e {\n        return `${data[0]} is ${data[1]} years old.`;\n      }\n    }\n  };\n```\n\n#### Output\n```json\n\n[{\n  \"@type\": \"https://schema.org/Person\",\n  \"https://schema.org/name\": \"Tom A.\",\n  \"https://schema.org/description\": \"Tom A. is 15 years old.\"\n}]\n```\n\n#### Description\nAccording to the [FNO specification](https://fno.io/rml/) a `FunctionMap` has an array of `predicateObjectMaps`. One of the `predicateObjectMaps` defines the function with `fno:executes` and the name of the function in `rr:constant`.\nThe other `predicateObjectMaps` specify the function parameters. The first parameter (`rml:reference: \"name\"`) is then stored in `data[0]`, the second in `data[1]` and so on.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomake%2Frmlmapper-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomake%2Frmlmapper-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomake%2Frmlmapper-js/lists"}