Skip to content

Commit

Permalink
feat(library): Support XML (SDMX-ML Structure message) for input
Browse files Browse the repository at this point in the history
Changed the input format from Document object to XML string. Library will convert the XML string to
document object internally (using xmldon in Node).

Input is no longer Document object. Closes #1
  • Loading branch information
airosa committed Apr 24, 2016
1 parent afb4443 commit c315b3d
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 129 deletions.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,18 @@ for a live demo.

## Usage ##

Just include the library on a web page:

```
<script src="sdmxmllib.js"></script>
<script>console.log('sdmxmllib version: ' + sdmxmllib.version);</script>
```
Either include the library on a web page or require in Node.js.

## Mapping ##

### mapSDMXMLResponse

Maps SDMX-ML Structure message to Javascript objects. Accepts a document object
as input.
Maps SDMX-ML Structure message into Javascript objects. Accepts a SDMX-ML 2.1
Structure Message as input.

```
// req is a XMLHttpRequest object
var msg = sdmxmllib.mapSDMXMLResponse(req.responseXML);
var msg = sdmxmllib.mapSDMXMLResponse(req.responseText);
console.log(msg.header.id); // "IDREF99224"
console.log(msg.resources.length); // 10
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@
"pre-commit": "npm run test:single && npm run check-coverage && npm run lint"
}
},
"dependencies": {}
"dependencies": {
"xmldom": "0.1.22"
}
}
2 changes: 1 addition & 1 deletion samples/sdmxmlmap/js/sdmxmlmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// Show the raw response text on page
xmlOutput.textContent = req.responseText;
// convert XML to javascript objects
var json = sdmxmllib.mapSDMXMLResponse(req.responseXML, url);
var json = sdmxmllib.mapSDMXMLResponse(req.responseText);
// Convert to json and show on page
jsonOutput.textContent = JSON.stringify(json, null, 2);
};
Expand Down
Loading

0 comments on commit c315b3d

Please sign in to comment.