Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rsm-hcd/common-cartridge
Library encapsulating the XDT files provided by IMS to convert XML Common Cartridge files into structured classes
https://github.com/rsm-hcd/common-cartridge
common-cartridge dotnet-core ims-basiclti lti parser parsing
Last synced: about 1 month ago
JSON representation
Library encapsulating the XDT files provided by IMS to convert XML Common Cartridge files into structured classes
- Host: GitHub
- URL: https://github.com/rsm-hcd/common-cartridge
- Owner: rsm-hcd
- License: apache-2.0
- Created: 2017-10-12T12:31:40.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-03T13:01:17.000Z (over 6 years ago)
- Last Synced: 2023-10-09T20:40:37.421Z (about 1 year ago)
- Topics: common-cartridge, dotnet-core, ims-basiclti, lti, parser, parsing
- Language: C#
- Homepage:
- Size: 246 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Common Cartridge Dotnet core parser
Dotnet Core Package for parsing LTI & Common Cartridge XML files into C# classes. XDT files downloaded from the [IMS Global Technical Resources](https://www.imsglobal.org/technical-resources) page
## Installation
Install from the Nuget repository [https://www.nuget.org/packages/AndcultureCode.CommonCartridge.Parser/]
## Usage
### Parsing a cartridge manifest file
```
using CommonCartridge.Core;
using CommonCartridge.Core.Constants;
using CommonCartridge.Core.Interfaces;var fileContent = File.ReadAllText(filename);
var parser = new Parser();
var versionParser = new VersionParser();// Check Version
var version = versionParser.GetSchemaVersion(fileContent);if (version == Versions.VERSION_1_0)
{
// v0 variable contains a fully structured class representing the Common Cartridge 1.0 manifest
var v0 = parser.FromCCXml(fileContent, directoryPath);
} else if (version == Versions.VERSION_1_1)
{
// v1 variable contains a fully structured class representing the Common Cartridge 1.1 manifest
var v1 = parser.FromCCXml(fileContent, DirectoryPath);
} else if (version == Versions.VERSION_1_2)
{
// v2 variable contains a fully structured class representing the Common Cartridge 1.2 manifest
var v2 = parser.FromCCXml(fileContent, DirectoryPath);
} else if (version == Versions.VERSION_1_3)
{
// v3 variable contains a fully structured class representing the Common Cartridge 1.3 manifest
var v3 = parser.FromCCXml(fileContent, DirectoryPath);
}
```### Parsing an LTI file
```
using CommonCartridge.Core;
using CommonCartridge.Core.Constants;
using CommonCartridge.Core.Interfaces;var fileContent = File.ReadAllText(filename);
var parser = new Parser();
var versionParser = new VersionParser();// Check Version
var version = versionParser.GetSchemaVersion(fileContent, "blti");if (version == Versions.VERSION_1_0)
{
// v0 variable contains a fully structured class representing the LTI 1.0 file
var v0 = _parser.FromXml(fileContent);
} else if (version == Versions.VERSION_1_1)
{
// v1 variable contains a fully structured class representing the LTI 1.1 file
var v1 = _parser.FromXml(fileContent);
} else if (version == Versions.VERSION_1_2)
{
// v1_1 variable contains a fully structured class representing the LTI 1.1.2 file
var v1_1 = _parser.FromXml(fileContent);
}
```## Interfaces
### IParser
Method | Return | Description
----------|------|------------
FromFile<T> | ParserResult | Same as FromXml, but also loads file from specified path before parsing
FromXml<T> | ParserResult | Loads XML into XDocument and deserializes to provided class
FromCCArchive<T> | ParserResult | Verifies extension of archive, attemps to unzip into a temp directory, and looks for an imsmanifest.xml file to pass to FromCCFile
FromCCFile<T> | ParserResult | Same as FromCCXml, but also loads file from specified path before parsing
FromCCXml<T> | ParserResult | Loads XML into XDocument and deserializes to provided CC class### IVersionParser
Method | Return | Description
----------|------|------------
GetSchemaVersionFromFile | string | Same as GetSchemaVersion, but also loads file from specified path before parsing
GetSchemaVersion | string | Loads XML into XDocument attempts to read version string from XML schemaversion attribute. Second param (prefix) is optional, will attempt to read the version from a custom namespace. Default empty.