Sha256: 9d23c09a8cc981145d0bd855ba30bef02f0c8643a8dfde97997d4017c82ccb58

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# XsdReader

XsdReader provides easy and flexible access to XSD information

## Installation


Rubygems:

```
gem install xsd-reader
```

Bundler: 

```ruby
gem 'xsd-reader'
````

## Examples

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

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

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

Get type information of attribute
```ruby
attribute = reader['NewReleaseMessage']['MessageHeader']['@LanguageAndScriptCode']
attribute.type 				# => 'xs:string'
attribute.type_name			# => 'string'
attribute.type_namespace	# => 'xs'
```

Get element amount details
```ruby
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
```


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xsd-reader-0.1.0 README.md