https://github.com/slipke/eurlex-model-go
This projects implements the EUR-Lex XML data model in Golang. For more information see README.md
https://github.com/slipke/eurlex-model-go
data datamodel eur-lex eurlex webservice
Last synced: 4 months ago
JSON representation
This projects implements the EUR-Lex XML data model in Golang. For more information see README.md
- Host: GitHub
- URL: https://github.com/slipke/eurlex-model-go
- Owner: slipke
- License: mit
- Created: 2021-05-01T15:42:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-03T20:34:11.000Z (about 5 years ago)
- Last Synced: 2024-03-20T22:33:55.394Z (over 2 years ago)
- Topics: data, datamodel, eur-lex, eurlex, webservice
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# eurlex-model-go
# Overview
[eurlex-model-go](https://github.com/slipke/eurlex-model-go) implements the XML data model used by [EUR-Lex](https://eur-lex.europa.eu/homepage.html) in Golang. It is required by [eurlex-ws-go](https://github.com/slipke/eurlex-ws-go), which implements the Webservice (Search), and [Cellar](https://op.europa.eu/documents/10530/676542/ao10463_annex_17_cellar_dissemination_interface_en.pdf).
## Install
```bash
go get -u github.com/slipke/eurlex-model-go
```
## Usage
Retrieve the XML from either the Webservice or Cellar, or alternatively directly from the website (i.e. [celex:32008R1272](https://eur-lex.europa.eu/legal-content/EN/ALL/?uri=celex%3A32008R1272) and click on ["Download notice"](https://eur-lex.europa.eu/download-notice.html?legalContentId=cellar:6bf54b59-7673-461b-b8e1-f24c545cbd3c¬iceType=branch&callingUrl=%2Flegal-content%2FEN%2FALL%2F%3Furi%3Dcelex%253A32008R1272&lng=EN)). Afterwards, the resulting XML file can be parsed by using the exemplary code:
```go
import (
"encoding/xml"
"io/ioutil"
log "github.com/sirupsen/logrus"
model "github.com/slipke/eurlex-model-go"
)
func main() {
xmlBytes, err := ioutil.ReadFile("cellar_6bf54b59-7673-461b-b8e1-f24c545cbd3c.xml")
if err != nil {
log.Fatalf("Failed to load file %s: %s", file, err)
}
var n *model.Notice
err = xml.Unmarshal(xmlBytes, &n)
if err != nil {
log.Fatalf("Failed to parse xml: %s", err)
}
// Print notice
log.Info(n)
}
```
## Resources
- [Cellar Interface](https://op.europa.eu/documents/10530/676542/ao10463_annex_17_cellar_dissemination_interface_en.pdf)
- [eurlex-ws-go](https://github.com/slipke/eurlex-ws-go)
- [EUR-Lex Help](https://eur-lex.europa.eu/content/help/webservice.html)
- [Web Service User Manual](https://eur-lex.europa.eu/content/tools/webservices/SearchWebServiceUserManual_v2.00.pdf)
- [Web Service Query Metadata](https://eur-lex.europa.eu/content/tools/webservices/WebServicesqueryMetadata.pdf)
- [Data Extraction Using Web Services](https://eur-lex.europa.eu/content/tools/webservices/DataExtractionUsingWebServices-v1.00.pdf)