Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

markkorput/xsd-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XsdReader

XsdReader provides easy and flexible access to XSD information

Build Status Code Climate

Installation

Rubygems:

gem install xsd-reader

Bundler:

gem 'xsd-reader'

Examples

Load xsd

require 'xsd_reader'
reader = XsdReader::XML.new(:xsd_file => 'ddex-ern-v36.xsd')

Get elements and their child elements

node = reader['NewReleaseMessage']
node.elements.map(&:name) # => ['MessageHeader', 'UpdateIndicator', 'IsBackfill', 'CatalogTransfer', 'WorkList', 'CueSheetList', 'ResourceList', 'CollectionList', 'ReleaseList', 'DealList']

Get attributes

reader['NewReleaseMessage']['MessageHeader'].attributes.map(&:name) # => ['LanguageAndScriptCode']

Get type information of attribute

attribute = reader['NewReleaseMessage']['MessageHeader']['@LanguageAndScriptCode']
attribute.type 				# => 'xs:string'
attribute.type_name			# => 'string'
attribute.type_namespace	# => 'xs'

Get element amount details

node = @reader['NewReleaseMessage']['ResourceList']['SoundRecording']
node.min_occurs			# => 0
node.max_occurs			# => :unbouded
node.multiple_allowed? # true
node.required?			# false
node = @reader['NewReleaseMessage']['MessageHeader']
node.min_occurs			# => nil
node.max_occurs			# => nil
node.multiple_allowed? # false
node.required?			# true

About

Ruby gem for reading XSDs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages