+ All Categories
Home > Technology > XML to MongoDb BSON

XML to MongoDb BSON

Date post: 21-Jan-2015
Category:
Upload: nomos-software
View: 545 times
Download: 11 times
Share this document with a friend
Description:
MongoDb stores data in BSON (binary JSON) format. A primary use case for MongoDb is to store JSON data. But what If you want to insert XML data. BSON and XML support more data types than JSON, and it can useful to maintain the fidelity of the XML type information when you insert data to MongoDb. These slides explain some of the challenges in inserting XML data to MongoDb, and give an overview of how the RuleX product from Nomos Software can be used to map XML to BSON.
Popular Tags:
18
nomossoftware nomos-software.com XML to MongoDb BSON XML to BSON Requirements Overview of RuleX & RuleX MongoDb Flavor XML to BSON Challenges RuleX MongoDb Flavor Explained Worked Example: ISO 20022 XML inserted to MongoDb Find out more: contact [email protected]
Transcript
Page 1: XML to MongoDb BSON

nomossoftware nomos-software.com

XML to MongoDb BSONXML to BSON Requirements

Overview of RuleX & RuleX MongoDb FlavorXML to BSON Challenges

RuleX MongoDb Flavor ExplainedWorked Example: ISO 20022 XML inserted to MongoDb

Find out more: contact [email protected]

Page 2: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

XML to MongoDb BSON Requirements

XML MongoDbSourceBSON

Insert to MongoDbcollections

Validate

Enrich

Query

Preserve types

Preserve relationships

API Platform

Messaging Bus

Etc

BSONBSON

Page 3: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Overview of RuleX from Nomos Software

RuleX RuleX MongoDb FlavorGenerates java librariesthat validate, enrich and query XML based on high level rules

fast to build, easy to maintain, high performance, ultra lightweight java libraries

Generates java librariesthat validate, enrich and query….

Returns detailed error informationerror descriptions & locations : line numbers & Xpath, autocorrected XML fragments etc

Returns query results in BSON

Preserves XML types

Preserves XML relationships

Page 4: XML to MongoDb BSON

XML to BSON Challenges

Page 5: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

XML to BSON – Challenge 1

BSON has 18 primitive types : http://docs.mongodb.org/manual/reference/bson-types/

XML Schema has over 40 primitive types : http://www.w3.org/TR/xmlschema-2/#built-in-datatypes

Need to map dates, times, integers etc correctly

Otherwise, useful operations such as date comparisons and numeric computations cannot be executed on the MongoDb BSON collections

Preserving XML primitive type information in BSON

Page 6: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

XML to BSON – Challenge 2

This is an XML string primitive type, but needs to be treated as an integer

Preserving XML simple type information in BSON

If not mapped correctly, useful operations such as date comparisons and numeric computations cannot be executed on the MongoDb BSON collections

This is an XML integer primitive type, but needs to be treated as a date

Example from ISO 20022: http://www.iso20022.org/

Page 7: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

XML to BSON – Challenge 3

Relationships are identified in XML using keys, keyrefs, ids, idrefs, hrefs etc(marked up XML)

Preserving XML relationships

Example from FpML: http://www.fpml.org/

Any hrefs using ‘party1’ are referring to the ‘party1’ at end of file.

Need to preserve the information about the relationships in the generated BSON.

Page 8: XML to MongoDb BSON

RuleX MongoDb Flavor

Page 9: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Generated Java

Libraries

RuleX Technical Overview

Generated Java

Libraries

SOAP, Rest or Java API

XML

XML Schema

RuleX flavor forMongoDb

Requirements as Rules

Deploy Generated Library

+

Documentation

BSON

BSONBSON

Page 10: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Generated Java

Libraries

Java Libraries are fully functional and 100% autogenerated by Nomos RuleX product.

Generated code is java readable source code.

No additional coding required.

XML to BSON via RuleX Java Libraries

Java Libraries generated by RuleX

SOAP, Rest or Java API

XML MongoDbSourceBSON

BSONBSON

Page 11: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Analyst or developer authors rules, e.g. to extract all payment transactions in a file

individually

Building ‘XML to BSON’ Libraries with RuleX

Generated Java

Library

Single click generation.

Transforms any XML conformant with the schema into BSON, in accordance with the

rules.

RuleX Flavorfor MongoDb

XML Schema Rules

BSONXMLBSON

Page 12: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Example query rules on XML

Query Name Query Description

GetHighPaymentTypeInformation

self.PmtInf.PmtTpInf->select(a | a.InstrPrty='HIGH')

Return all payment type information who have an instruction authority set to High

GetAllChkPaymentsself.PmtInf->select(a | a.PmtMtd='CHK' and a.NbOfTxs.toInteger() > 0)

Return all payments transaction type is cheque and whose number of transactions exceed 0

GetAllCorkPostalCodesself.PstlAdr->select(a | a.Ctry = 'IRL' and a.PstCd = 'CORK')

Return all Postal Address whose Country is Ireland and who post code is Cork

* Validation and query rules are based on the OCL standard: http://www.omg.org/spec/OCL/2.3.1/Rules language has been extended to support support enrichment (action) rules, as well as additional functions for specific domains.

Examples of Rules

RuleX generates java code for each rule.

RuleX supports validation, query and enrichment rules*.

Page 13: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

RuleX MongoDb Flavor

RuleX generated java libraries

Unmarshall XML to com.mongoDb.DBObject java classes

Run query rules on the java classes returning results as BSON

Preserve XML type information mapping XML primitive types to BSON primitive types

mapping XML simple types to BSON primitive types

Preserve XML relationships preserving the semantics of XML hrefs, keys etc

Page 14: XML to MongoDb BSON

Example:

Building a MongoDb Flavor library

The library:- takes an XML document containing multiple payment transactions - generates BSON for each ‘cheque’ payment- connects to a MongoDb instance via the java driver

MongoDb

BSON Collection of PmtInfs

DocumentHeader (GrpHdr)Payment (PmtInf)Payment (PmtInf)…

XML

Page 15: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Example – Building a MongoDb Flavor Library

Generated Java

Library

ISO 20022 SEPA Payments XML, pain.001.001.003

Single click generation

Returns BSON document for each cheque payment, and connects to MongoDb instance

via java driver and adds to MongoDbcollections

Schema Pain.001.001.003.xsd

PmtInf->select(a |a.PmtMtd = ‘CHK’))

Custom Query Rule:Select every payment (PmtInf) found in the XML document that uses Payment Method

(PmtMtd) cheque (CHK)

RuleX Flavorfor MongoDb

Page 16: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Example – Building a Library

Single Click Generation with RuleX Eclipse Plugin

PmtInf->select(a |a.PmtMtd = ‘CHK’))

Spreadsheet containing one rule:“paymentsWhoseMtdIsChk”

XML Schema

Java Readable Source CodeINPUT

OUTPUT

Page 17: XML to MongoDb BSON

www.nomos-software.comCopyright © Nomoséire Limited 2014 trading as Nomos Software nomossoftware

Running the Library

Input : ISO 20022 SEPA XML File Result: Updated collections in MongoDb

Screenshot shows results of find statement executed on mongoDb instance

Page 18: XML to MongoDb BSON

Find out more?

http://nomos-software.com/contact

[email protected]

nomossoftware https://www.linkedin.com/company/nomos-software


Recommended