Class: XSD::Attribute
- Inherits:
-
BaseObject
- Object
- BaseObject
- XSD::Attribute
- Includes:
- Named, Referenced, SimpleTyped
- Defined in:
- lib/xsd/objects/attribute.rb
Overview
The attribute element defines an attribute. Parent elements: attributeGroup, schema, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent) www.w3schools.com/xml/el_attribute.asp
Constant Summary collapse
- TYPE_PROPERTY =
:type
Constants inherited from BaseObject
BaseObject::NO_ATTRIBUTES_CONTAINER, BaseObject::NO_ELEMENTS_CONTAINER, BaseObject::XML_SCHEMA
Instance Attribute Summary collapse
-
#default ⇒ Object
Optional.
-
#fixed ⇒ Object
Optional.
-
#form ⇒ Object
Optional.
-
#name ⇒ Object
Optional.
-
#type ⇒ Object
Optional.
-
#use ⇒ Object
Optional.
Attributes included from Referenced
Attributes included from SimpleTyped
Attributes inherited from BaseObject
Instance Method Summary collapse
-
#data_type ⇒ Object
Get base data type.
-
#optional? ⇒ Boolean
Determine if attribute is optional.
-
#prohibited? ⇒ Boolean
Determine if attribute is prohibited.
-
#required? ⇒ Boolean
Determine if attribute is required.
Methods included from Named
Methods included from Referenced
Methods included from SimpleTyped
Methods inherited from BaseObject
#[], #collect_attributes, #collect_elements, #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
#default ⇒ Object
Optional. Specifies a default value for the attribute. Default and fixed attributes cannot both be present
23 |
# File 'lib/xsd/objects/attribute.rb', line 23 property :default, :string |
#fixed ⇒ Object
Optional. Specifies a fixed value for the attribute. Default and fixed attributes cannot both be present
28 |
# File 'lib/xsd/objects/attribute.rb', line 28 property :fixed, :string |
#form ⇒ Object
Optional. Specifies the form for the attribute. The default value is the value of the attributeFormDefault attribute of the schema containing the attribute. Can be set to one of the following:
qualified - indicates that this attribute must be qualified with the namespace prefix and the no-colon-name
(NCName) of the attribute
unqualified - indicates that this attribute is not required to be qualified with the namespace prefix and is
matched against the (NCName) of the attribute
38 |
# File 'lib/xsd/objects/attribute.rb', line 38 property :form, :string, default: proc { schema.attribute_form_default } |
#name ⇒ Object
Optional. Specifies the name of the attribute. Name and ref attributes cannot both be present
18 |
# File 'lib/xsd/objects/attribute.rb', line 18 property :name, :string |
#type ⇒ Object
Optional. Specifies a built-in data type or a simple type. The type attribute can only be present when the content does not contain a simpleType element
44 |
# File 'lib/xsd/objects/attribute.rb', line 44 property :type, :string |
#use ⇒ Object
Optional. Specifies how the attribute is used. Can be one of the following values:
optional - the attribute is optional (this is default)
prohibited - the attribute cannot be used
required - the attribute is required
52 |
# File 'lib/xsd/objects/attribute.rb', line 52 property :use, :string, default: 'optional' |
Instance Method Details
#data_type ⇒ Object
Get base data type
74 75 76 77 78 79 80 |
# File 'lib/xsd/objects/attribute.rb', line 74 def data_type if simple_type simple_type.data_type else strip_prefix(type) end end |
#optional? ⇒ Boolean
Determine if attribute is optional
62 63 64 |
# File 'lib/xsd/objects/attribute.rb', line 62 def optional? use == 'optional' end |
#prohibited? ⇒ Boolean
Determine if attribute is prohibited
68 69 70 |
# File 'lib/xsd/objects/attribute.rb', line 68 def prohibited? use == 'prohibited' end |
#required? ⇒ Boolean
Determine if attribute is required
56 57 58 |
# File 'lib/xsd/objects/attribute.rb', line 56 def required? use == 'required' end |