https://github.com/ammar257ammar/xml2rdf

A simple XML to RDF converter

https://github.com/ammar257ammar/xml2rdf

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: science.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (6.9%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

A simple XML to RDF converter

Basic Info
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Fork of MaastrichtU-IDS/xml2rdf
Created about 6 years ago · Last pushed over 6 years ago

https://github.com/ammar257ammar/xml2rdf/blob/master/

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)


# About
This tool converts any xml file into a generic rdf model.

See the [Data2Services documentation](http://d2s.semanticscience.org/) to run xml2rdf as part of workflows to generate RDF knowledge graph from structured data.

## RDF model
```shell
PREFIX x2rm: 
PREFIX x2rd: 
PREFIX rdfs: 
PREFIX owl:  
PREFIX rdf:  

insert data {
    # Base XmlElement
    x2rm:XmlElement a rdfs:type .
    # Attributes
    x2rm:hasName a rdf:Property ;
        rdfs:domain x2rm:XmlElement;
        rdfs:type rdfs:Literal .
    x2rm:hasValue a rdf:Property ;
        rdfs:domain x2rm:XmlElement;
        rdfs:type rdfs:Literal .
    x2rm:hasXPath a rdf:Property ;
        rdfs:domain x2rm:XmlElement;
        rdfs:type rdfs:Literal . 
        
    # XmlAttribue
    x2rm:XmlAttribute rdfs:subClassOf x2rm:XmlElement .
    
    # XmlNode
    x2rm:XmlNode rdfs:subClassOf x2rm:XmlElement .
    # Attributes
    x2rm:hasChild a rdf:Property ;
        rdfs:domain x2rm:XmlNode ;
        rdfs:range x2rm:XmlNode .
    x2rm:hasAttribute a rdf:Property ;
        rdfs:domain x2rm:XmlNode ;
        rdfs:range x2rm:XmlAttribute .
        
    # Inverse attributes 
    x2rm:isNameOf owl:inverseOf x2rm:hasName .
    x2rm:isValueOf owl:inverseOf x2rm:hasValue.
    x2rm:isXPathOf owl:inverseOf x2rm:hasXPath .
    x2rm:isChildOf owl:inverseOf x2rm:hasChild .
    x2rm:isAttributeOf owl:inverseOf x2rm:hasAttribute .
}
```
# Docker
## Build
```shell
docker build -t xml2rdf .
```
## Usage
```shell
docker run --rm -it xml2rdf -?
```
```
Usage: xml2rdf [-?] [-xp] -g= -i= [-n=]
               -o=
  -?, --help         display a help message
  -g, --graphuri=
                     Graph URI
  -i, --inputfile=
                     Path to input file (.xml or .xml.gz). Wildcards are also
                       supported. (see: Apache Ant DirectoryScanner)
  -n, --namespace=
                     Namespace for data nodes.
                       Default: http://ids.unimaas.nl/xml2rdf/data/
  -o, --outputfile=
                     Path to output file (.nq or .nq.gz)
      -xp, --xpath   Generate XPath paths in output
```
## Run

### Linux / OSX
```shell
docker run --rm -it -v /home/d2s:/data xml2rdf  -i "/data/input.xml.gz" -o "/data/output.nq.gz" -g "http://kraken/xml2rdf/graph"
```
> For a file on `/home/d2s/input.xml.gz`

### Windows

```shell
docker run --rm -it -v c:/home/d2s:/data xml2rdf  -i "/data/input.xml.gz" -o "/data/output.nq.gz" -g "http://kraken/xml2rdf/graph"
```

> For a file on `c:/home/d2s/input.xml.gz`

More information on the use of docker can be found at [DSRI docker documentation](http://d2s.semanticscience.org/docs/guide-docker).

Owner

  • Name: Ammar Ammar
  • Login: ammar257ammar
  • Kind: user
  • Location: The Netherlands
  • Company: Maastricht University

GitHub Events

Total
Last Year