Class: XSD::Restriction
- Inherits:
-
BaseObject
- Object
- BaseObject
- XSD::Restriction
- Includes:
- AttributeContainer, Based, SimpleTyped
- Defined in:
- lib/xsd/objects/restriction.rb
Overview
The restriction element defines restrictions on a simpleType, simpleContent, or complexContent definition. Parent elements: simpleType, simpleContent, complexContent www.w3schools.com/xml/el_restriction.asp
Constant Summary collapse
- TYPE_PROPERTY =
nil
- FACET_ELEMENTS =
%w[ minExclusive minInclusive maxExclusive maxInclusive totalDigits fractionDigits length minLength maxLength enumeration whiteSpace pattern ].freeze
Constants inherited from BaseObject
BaseObject::NO_ATTRIBUTES_CONTAINER, BaseObject::NO_ELEMENTS_CONTAINER, BaseObject::XML_SCHEMA
Instance Attribute Summary collapse
-
#all ⇒ Object
Nested all.
-
#choice ⇒ Object
Nested choice.
-
#group ⇒ Object
Nested group.
-
#sequence ⇒ Object
Nested sequence.
Attributes included from AttributeContainer
#attribute_groups, #attributes
Attributes included from SimpleTyped
Attributes included from Based
#base, #base_complex_type, #base_simple_type
Attributes inherited from BaseObject
Instance Method Summary collapse
-
#collect_attributes(include_base = true) ⇒ Object
Get all available attributes on the current stack level, optionally including base type attributes.
-
#collect_elements(include_base = false) ⇒ Object
Get all available elements on the current stack level, optionally including base type elements.
-
#facets ⇒ Object
Get restriction facets.
Methods included from AttributeContainer
Methods included from SimpleTyped
Methods included from Based
Methods inherited from BaseObject
#[], #documentation, #documentation_for, #get_prefix, #initialize, #inspect, #map_child, #map_children, #namespaces, #node, #node_to_object, #nodes, #object_by_name, #parent, #reader, #schema, #schemas_for_namespace, #strip_prefix
Constructor Details
This class inherits a constructor from XSD::BaseObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class XSD::BaseObject
Instance Attribute Details
#all ⇒ Object
Nested all
27 |
# File 'lib/xsd/objects/restriction.rb', line 27 child :all, :all |
#choice ⇒ Object
Nested choice
32 |
# File 'lib/xsd/objects/restriction.rb', line 32 child :choice, :choice |
#group ⇒ Object
Nested group
22 |
# File 'lib/xsd/objects/restriction.rb', line 22 child :group, :group |
#sequence ⇒ Object
Nested sequence
37 |
# File 'lib/xsd/objects/restriction.rb', line 37 child :sequence, :sequence |
Instance Method Details
#collect_attributes(include_base = true) ⇒ Object
Get all available attributes on the current stack level, optionally including base type attributes
73 74 75 76 77 |
# File 'lib/xsd/objects/restriction.rb', line 73 def collect_attributes(include_base = true) result = super(include_base) # Filter restricted attributes to avoid duplicates from restricting and restricted type include_base ? result.inject({}) { |hash, item| hash[item.name] = item; hash }.values : result end |
#collect_elements(include_base = false) ⇒ Object
Get all available elements on the current stack level, optionally including base type elements
64 65 66 67 68 |
# File 'lib/xsd/objects/restriction.rb', line 64 def collect_elements(include_base = false) # Don't include elements from base by default, that will lead to element duplicates because # elements in complex restriction MUST be all listen in restricting type super(include_base) end |
#facets ⇒ Object
Get restriction facets
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/xsd/objects/restriction.rb', line 41 def facets nodes.inject({}) do |hash, node| if FACET_ELEMENTS.include?(node.name) key = node.name value = node['value'] if key == 'enumeration' hash[key] ||= {} hash[key][value] = documentation_for(node) elsif key == 'pattern' hash[key] ||= [] hash[key].push(value) else hash[key] = value end end hash end end |