Class: ADIWG::Mdtranslator::Writers::Iso19110::Multiplicity
- Inherits:
-
Object
- Object
- ADIWG::Mdtranslator::Writers::Iso19110::Multiplicity
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19110/classes/class_multiplicity.rb
Instance Method Summary collapse
-
#initialize(xml, responseObj) ⇒ Multiplicity
constructor
A new instance of Multiplicity.
- #writeXML(hAttribute) ⇒ Object
Constructor Details
#initialize(xml, responseObj) ⇒ Multiplicity
Returns a new instance of Multiplicity.
32 33 34 35 |
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_multiplicity.rb', line 32 def initialize(xml, responseObj) @xml = xml @hResponseObj = responseObj end |
Instance Method Details
#writeXML(hAttribute) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_multiplicity.rb', line 37 def writeXML(hAttribute) # xml for iso classes Multiplicity and MultiplicityRange # in 19110 cardinality is expressed as multiplicity, a min/max range # Multiplicity is not defined in the documentation, only inferred from the XSD # max cardinality ----------------- # ISO 19110-2 rule # ... "If this is an attribute or operation, the default cardinality is 1" # there is no hint if this refers to min or max of the range, I chose max # I assume this means the attribute can occur only once in the entity # I set the internal object mustBeUnique = true as default # I assume false would describe something like a repeating tag in an XML file # min cardinality ----------------- # mdJson allows setting flag to allow nulls as attribute values # I set this into minimum cardinality # issue --------------------------- # min cardinality refers to the attribute values # max cardinality refers to the attribute instantiation # perhaps one of these should not be carried in ISO19110 minCard = 1 maxCard = 9 if hAttribute[:allowNull] minCard = 0 end if hAttribute[:mustBeUnique] maxCard = 1 end # xml for iso classes Multiplicity and MultiplicityRange @xml.tag!('gco:Multiplicity') do @xml.tag!('gco:range') do @xml.tag!('gco:MultiplicityRange') do @xml.tag!('gco:lower') do @xml.tag!('gco:Integer', minCard) end @xml.tag!('gco:upper') do if maxCard == 1 @xml.tag!('gco:UnlimitedInteger', 1) else @xml.tag!('gco:UnlimitedInteger', {'isInfinite'=>'true'}, 9) end end end end end # gco:Multiplicity tag end |