Module: SerializableToXml

Included in:
Id, IdRef, RegexRestrictedString, VORuby::ADQL::V1_0::From, VORuby::ADQL::V1_0::FromTable, VORuby::ADQL::V1_0::GroupBy, VORuby::ADQL::V1_0::Having, VORuby::ADQL::V1_0::InclusionSet, VORuby::ADQL::V1_0::Into, VORuby::ADQL::V1_0::Literal, VORuby::ADQL::V1_0::Order, VORuby::ADQL::V1_0::OrderExpression, VORuby::ADQL::V1_0::OrderOption, VORuby::ADQL::V1_0::Search, VORuby::ADQL::V1_0::Select, VORuby::ADQL::V1_0::SelectionItem, VORuby::ADQL::V1_0::SelectionLimit, VORuby::ADQL::V1_0::SelectionList, VORuby::ADQL::V1_0::SelectionOption, VORuby::ADQL::V1_0::Where, VORuby::ADQL::V1_0::XMatchTableAlias, VORuby::STC::V1_10::Coords::AbsoluteTime, VORuby::STC::V1_10::Coords::AstroCoordsFile, VORuby::STC::V1_10::Coords::AstronTime, VORuby::STC::V1_10::Coords::CError, VORuby::STC::V1_10::Coords::CPixSize, VORuby::STC::V1_10::Coords::CResolution, VORuby::STC::V1_10::Coords::CSize, VORuby::STC::V1_10::Coords::CoordFitsColumns, VORuby::STC::V1_10::Coords::CoordValue, VORuby::STC::V1_10::Coords::Coordinate, VORuby::STC::V1_10::Coords::CoordinateType, VORuby::STC::V1_10::Coords::Coords, VORuby::STC::V1_10::Coords::DoubleArray, VORuby::STC::V1_10::Coords::Fits, VORuby::STC::V1_10::Coords::Position, VORuby::STC::V1_10::Coords::Redshift, VORuby::STC::V1_10::Coords::RelativeTime, VORuby::STC::V1_10::Coords::Spectral, VORuby::STC::V1_10::Coords::TimeCoordinate, VORuby::STC::V1_10::Coords::Velocity, VORuby::STC::V1_10::Region::BooleanOperatorType, VORuby::STC::V1_10::Region::Constraint, VORuby::STC::V1_10::Region::RegionType, VORuby::STC::V1_10::Region::Shape, VORuby::STC::V1_10::Region::SmallCircle, VORuby::STC::V1_10::Region::Vertex, VORuby::STC::V1_10::STC::CoordAreaType, VORuby::STC::V1_10::STC::CoordFlavorType, VORuby::STC::V1_10::STC::CoordFrame, VORuby::STC::V1_10::STC::CoordFrameType, VORuby::STC::V1_10::STC::CoordIntervalType, VORuby::STC::V1_10::STC::CoordSysType, VORuby::STC::V1_10::STC::CustomSpaceRefFrameType, VORuby::STC::V1_10::STC::FkType, VORuby::STC::V1_10::STC::IcrsType, VORuby::STC::V1_10::STC::ReferencePositionType, VORuby::STC::V1_10::STC::SpatialIntervalType, VORuby::STC::V1_10::STC::StcMetadataType, VORuby::STC::V1_30::AbsoluteTime, VORuby::STC::V1_30::AstronTimeType, VORuby::STC::V1_30::CoordFITSColumnsType, VORuby::STC::V1_30::CoordFlavorType, VORuby::STC::V1_30::CoordRefFrameType, VORuby::STC::V1_30::CoordValue, VORuby::STC::V1_30::CoordValueType, VORuby::STC::V1_30::Curve2Type, VORuby::STC::V1_30::Curve3Type, VORuby::STC::V1_30::FitsType, VORuby::STC::V1_30::HSOffsetType, VORuby::STC::V1_30::HalfspaceType, VORuby::STC::V1_30::PixelType, VORuby::STC::V1_30::ReferencePositionType, VORuby::STC::V1_30::RegionAreaType, VORuby::STC::V1_30::RelocatableOriginType, VORuby::STC::V1_30::STCReference, VORuby::STC::V1_30::SmallCircleType, VORuby::STC::V1_30::VertexType, VORuby::VOEvent::V1_1::Base
Defined in:
lib/voruby/misc.rb

Overview

A mix-in that adds to a classes the ability to serialize themselves to very basic XML.

Instance Method Summary collapse

Instance Method Details

#element(name = nil, ns = nil, options = {}) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/voruby/misc.rb', line 235

def element(name=nil, ns=nil, options={})
  name ||= element_name_from(self.class)
  ns ||= obj_ns

  el = REXML::Element.new("#{ns.prefix}:#{name}")
  el.add_namespace(ns.prefix, ns.uri)
  
  el.add_namespace(XSI_NAMESPACE.prefix, XSI_NAMESPACE.uri) if options[:include_xsi]
  el.attributes["#{XSI_NAMESPACE.prefix}:type"] = "#{options[:prefix] || ns.prefix}:#{options[:type]}" if options[:type]
  
  el
end