* lib/soap/**/*.rb, lib/wsdl/**/*.rb, lib/xsd/**/*.rb: changed license; GPL2 -> Ruby's.
* lib/soap/rpc/driver.rb, lib/soap/wsdlDriver.rb, lib/soap/streamHandler.rb: add interface to streamhandler.
* lib/soap/marshal.rb: raise error if parse fails.
* lib/soap/netHttpClient.rb: add https support. Patched by Oliver M. Bolzer.
* lib/soap/netHttpClient.rb: dump HTTP response message body by itself.
* lib/soap/rpc/driver.rb, lib/soap/rpc/proxy.rb, lib/soap/wsdlDriver.rb: add driver#mandatorycharset interface to foce using charset for parsing response from buggy server.
* lib/soap/encodingstyle/soapHandler.rb: support Apache Axis's half typed multi-ref array.
* lib/soap/mapping/factory.rb, lib/soap/mapping/registry.rb: map SOAPStruct which has multi-accessors which name are the same, to an array.
* lib/soap/rpc/element.rb: fixed illegal parameter order.
* lib/soap/rpc/element.rb: element name of response message could have the name other than 'return'.
* lib/wsdl/operation.rb, lib/wsdl/operationBinding.rb, lib/wsdl/soap/classDefCreator.rb, lib/wsdl/soap/methodDefCreator.rb, lib/wsdl/soap/methodDefCreatorSupport.rb: WSDL/1.1 allows plural fault definition in a operation. [ruby-talk:84948]
* test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb: add test for above fix.
* lib/wsdl/soap/complexType.rb: support WSDL array definition with maxOccures="unbound".
* lib/xsd/charset.rb: use cp932 under emx. Patched by Siena. / SHINAGAWA, Norihide in [ruby-dev:21972]
* lib/xsd/xmlparser/parser.rb: set @charset nil by default. Nil means 'follow encoding declaration in XML'.
* sample/soap/digraph.rb, sample/wsdl/amazon/wsdlDriver.rb, sample/wsdl/googleSearch/sampleClient.rb, sample/wsdl/googleSearch/wsdlDriver.rb, test/wsdl/test_emptycomplextype.rb, test/wsdl/marshal/test_wsdlmarshal.rb, test/xsd/test_xmlschemaparser.rb: use File.open(...) { |f| f.read } instead of File.open(...).read. [ruby-dev:21964]
* test/wsdl/emptycomplextype.wsdl, test/wsdl/test_emptycomplextype.rb: simplify the test case.
* test/wsdl/axisArray/*: add tests for axis's array encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-25 02:31:33 -05:00
|
|
|
# XSD4R - XML Schema Datatype implementation.
|
|
|
|
# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
2003-09-24 11:18:44 -04:00
|
|
|
|
* lib/soap/**/*.rb, lib/wsdl/**/*.rb, lib/xsd/**/*.rb: changed license; GPL2 -> Ruby's.
* lib/soap/rpc/driver.rb, lib/soap/wsdlDriver.rb, lib/soap/streamHandler.rb: add interface to streamhandler.
* lib/soap/marshal.rb: raise error if parse fails.
* lib/soap/netHttpClient.rb: add https support. Patched by Oliver M. Bolzer.
* lib/soap/netHttpClient.rb: dump HTTP response message body by itself.
* lib/soap/rpc/driver.rb, lib/soap/rpc/proxy.rb, lib/soap/wsdlDriver.rb: add driver#mandatorycharset interface to foce using charset for parsing response from buggy server.
* lib/soap/encodingstyle/soapHandler.rb: support Apache Axis's half typed multi-ref array.
* lib/soap/mapping/factory.rb, lib/soap/mapping/registry.rb: map SOAPStruct which has multi-accessors which name are the same, to an array.
* lib/soap/rpc/element.rb: fixed illegal parameter order.
* lib/soap/rpc/element.rb: element name of response message could have the name other than 'return'.
* lib/wsdl/operation.rb, lib/wsdl/operationBinding.rb, lib/wsdl/soap/classDefCreator.rb, lib/wsdl/soap/methodDefCreator.rb, lib/wsdl/soap/methodDefCreatorSupport.rb: WSDL/1.1 allows plural fault definition in a operation. [ruby-talk:84948]
* test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb: add test for above fix.
* lib/wsdl/soap/complexType.rb: support WSDL array definition with maxOccures="unbound".
* lib/xsd/charset.rb: use cp932 under emx. Patched by Siena. / SHINAGAWA, Norihide in [ruby-dev:21972]
* lib/xsd/xmlparser/parser.rb: set @charset nil by default. Nil means 'follow encoding declaration in XML'.
* sample/soap/digraph.rb, sample/wsdl/amazon/wsdlDriver.rb, sample/wsdl/googleSearch/sampleClient.rb, sample/wsdl/googleSearch/wsdlDriver.rb, test/wsdl/test_emptycomplextype.rb, test/wsdl/marshal/test_wsdlmarshal.rb, test/xsd/test_xmlschemaparser.rb: use File.open(...) { |f| f.read } instead of File.open(...).read. [ruby-dev:21964]
* test/wsdl/emptycomplextype.wsdl, test/wsdl/test_emptycomplextype.rb: simplify the test case.
* test/wsdl/axisArray/*: add tests for axis's array encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-25 02:31:33 -05:00
|
|
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
|
|
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
|
|
|
# either the dual license version in 2003, or any later version.
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
require 'xsd/qname'
|
|
|
|
require 'xsd/charset'
|
|
|
|
require 'uri'
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
## XMLSchamaDatatypes general definitions.
|
|
|
|
#
|
|
|
|
module XSD
|
|
|
|
|
|
|
|
|
|
|
|
Namespace = 'http://www.w3.org/2001/XMLSchema'
|
|
|
|
InstanceNamespace = 'http://www.w3.org/2001/XMLSchema-instance'
|
|
|
|
|
|
|
|
AttrType = 'type'
|
|
|
|
NilValue = 'true'
|
|
|
|
|
|
|
|
AnyTypeLiteral = 'anyType'
|
|
|
|
AnySimpleTypeLiteral = 'anySimpleType'
|
|
|
|
NilLiteral = 'nil'
|
|
|
|
StringLiteral = 'string'
|
|
|
|
BooleanLiteral = 'boolean'
|
|
|
|
DecimalLiteral = 'decimal'
|
|
|
|
FloatLiteral = 'float'
|
|
|
|
DoubleLiteral = 'double'
|
|
|
|
DurationLiteral = 'duration'
|
|
|
|
DateTimeLiteral = 'dateTime'
|
|
|
|
TimeLiteral = 'time'
|
|
|
|
DateLiteral = 'date'
|
|
|
|
GYearMonthLiteral = 'gYearMonth'
|
|
|
|
GYearLiteral = 'gYear'
|
|
|
|
GMonthDayLiteral = 'gMonthDay'
|
|
|
|
GDayLiteral = 'gDay'
|
|
|
|
GMonthLiteral = 'gMonth'
|
|
|
|
HexBinaryLiteral = 'hexBinary'
|
|
|
|
Base64BinaryLiteral = 'base64Binary'
|
|
|
|
AnyURILiteral = 'anyURI'
|
|
|
|
QNameLiteral = 'QName'
|
|
|
|
|
|
|
|
NormalizedStringLiteral = 'normalizedString'
|
2004-12-20 08:50:15 -05:00
|
|
|
#3.3.2 token
|
|
|
|
#3.3.3 language
|
|
|
|
#3.3.4 NMTOKEN
|
|
|
|
#3.3.5 NMTOKENS
|
|
|
|
#3.3.6 Name
|
|
|
|
#3.3.7 NCName
|
|
|
|
#3.3.8 ID
|
|
|
|
#3.3.9 IDREF
|
|
|
|
#3.3.10 IDREFS
|
|
|
|
#3.3.11 ENTITY
|
|
|
|
#3.3.12 ENTITIES
|
2003-09-24 11:18:44 -04:00
|
|
|
IntegerLiteral = 'integer'
|
2004-12-20 08:50:15 -05:00
|
|
|
NonPositiveIntegerLiteral = 'nonPositiveInteger'
|
|
|
|
NegativeIntegerLiteral = 'negativeInteger'
|
2003-09-24 11:18:44 -04:00
|
|
|
LongLiteral = 'long'
|
|
|
|
IntLiteral = 'int'
|
|
|
|
ShortLiteral = 'short'
|
2004-12-20 08:50:15 -05:00
|
|
|
ByteLiteral = 'byte'
|
|
|
|
NonNegativeIntegerLiteral = 'nonNegativeInteger'
|
|
|
|
UnsignedLongLiteral = 'unsignedLong'
|
|
|
|
UnsignedIntLiteral = 'unsignedInt'
|
|
|
|
UnsignedShortLiteral = 'unsignedShort'
|
|
|
|
UnsignedByteLiteral = 'unsignedByte'
|
|
|
|
PositiveIntegerLiteral = 'positiveInteger'
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
AttrTypeName = QName.new(InstanceNamespace, AttrType)
|
|
|
|
AttrNilName = QName.new(InstanceNamespace, NilLiteral)
|
|
|
|
|
|
|
|
AnyTypeName = QName.new(Namespace, AnyTypeLiteral)
|
|
|
|
AnySimpleTypeName = QName.new(Namespace, AnySimpleTypeLiteral)
|
|
|
|
|
|
|
|
class Error < StandardError; end
|
|
|
|
class ValueSpaceError < Error; end
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
## The base class of all datatypes with Namespace.
|
|
|
|
#
|
|
|
|
class NSDBase
|
|
|
|
@@types = []
|
|
|
|
|
|
|
|
attr_accessor :type
|
|
|
|
|
|
|
|
def self.inherited(klass)
|
|
|
|
@@types << klass
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.types
|
|
|
|
@@types
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize
|
2004-12-20 08:50:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def init(type)
|
|
|
|
@type = type
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
## The base class of XSD datatypes.
|
|
|
|
#
|
|
|
|
class XSDAnySimpleType < NSDBase
|
|
|
|
include XSD
|
|
|
|
Type = QName.new(Namespace, AnySimpleTypeLiteral)
|
|
|
|
|
|
|
|
# @data represents canonical space (ex. Integer: 123).
|
|
|
|
attr_reader :data
|
|
|
|
# @is_nil represents this data is nil or not.
|
|
|
|
attr_accessor :is_nil
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
# true or raise
|
|
|
|
def check_lexical_format(value)
|
|
|
|
screen_data(value)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
# set accepts a string which follows lexical space (ex. String: "+123"), or
|
|
|
|
# an object which follows canonical space (ex. Integer: 123).
|
|
|
|
def set(value)
|
|
|
|
if value.nil?
|
|
|
|
@is_nil = true
|
|
|
|
@data = nil
|
2004-12-20 08:50:15 -05:00
|
|
|
_set(nil)
|
2003-09-24 11:18:44 -04:00
|
|
|
else
|
|
|
|
@is_nil = false
|
2004-07-03 09:33:20 -04:00
|
|
|
_set(screen_data(value))
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# to_s creates a string which follows lexical space (ex. String: "123").
|
|
|
|
def to_s()
|
|
|
|
if @is_nil
|
|
|
|
""
|
|
|
|
else
|
|
|
|
_to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def init(type, value)
|
|
|
|
super(type)
|
|
|
|
set(value)
|
|
|
|
end
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
# raises ValueSpaceError if check failed
|
|
|
|
def screen_data(value)
|
|
|
|
value
|
|
|
|
end
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
def _set(value)
|
|
|
|
@data = value
|
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
@data.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDNil < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, NilLiteral)
|
|
|
|
Value = 'true'
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
## Primitive datatypes.
|
|
|
|
#
|
|
|
|
class XSDString < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, StringLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-09-24 11:18:44 -04:00
|
|
|
unless XSD::Charset.is_ces(value, XSD::Charset.encoding)
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
value
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDBoolean < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, BooleanLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-09-24 11:18:44 -04:00
|
|
|
if value.is_a?(String)
|
2003-10-03 13:15:23 -04:00
|
|
|
str = value.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
if str == 'true' || str == '1'
|
2004-07-03 09:33:20 -04:00
|
|
|
true
|
2003-09-24 11:18:44 -04:00
|
|
|
elsif str == 'false' || str == '0'
|
2004-07-03 09:33:20 -04:00
|
|
|
false
|
2003-09-24 11:18:44 -04:00
|
|
|
else
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
|
|
|
else
|
2004-07-03 09:33:20 -04:00
|
|
|
value ? true : false
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDDecimal < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, DecimalLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def nonzero?
|
|
|
|
(@number != '0')
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(d)
|
2003-09-24 11:18:44 -04:00
|
|
|
if d.is_a?(String)
|
|
|
|
# Integer("00012") => 10 in Ruby.
|
|
|
|
d.sub!(/^([+\-]?)0*(?=\d)/, "\\1")
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
screen_data_str(d)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(str)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
sign = $1 || '+'
|
2003-09-24 11:18:44 -04:00
|
|
|
int_part = $2
|
|
|
|
frac_part = $3
|
|
|
|
int_part = '0' if int_part.empty?
|
|
|
|
frac_part = frac_part ? frac_part.sub(/0+$/, '') : ''
|
2004-07-03 09:33:20 -04:00
|
|
|
point = - frac_part.size
|
|
|
|
number = int_part + frac_part
|
2003-09-24 11:18:44 -04:00
|
|
|
# normalize
|
2004-07-03 09:33:20 -04:00
|
|
|
if sign == '+'
|
|
|
|
sign = ''
|
|
|
|
elsif sign == '-'
|
|
|
|
if number == '0'
|
|
|
|
sign = ''
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
[sign, point, number]
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def _set(data)
|
|
|
|
if data.nil?
|
|
|
|
@sign = @point = @number = @data = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
@sign, @point, @number = data
|
2003-09-24 11:18:44 -04:00
|
|
|
@data = _to_s
|
2003-11-28 00:53:16 -05:00
|
|
|
@data.freeze
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# 0.0 -> 0; right?
|
|
|
|
def _to_s
|
|
|
|
str = @number.dup
|
|
|
|
if @point.nonzero?
|
|
|
|
str[@number.size + @point, 0] = '.'
|
|
|
|
end
|
|
|
|
@sign + str
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2003-10-03 13:15:23 -04:00
|
|
|
module FloatConstants
|
|
|
|
NaN = 0.0/0.0
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
POSITIVE_INF = +1.0/0.0
|
2003-10-03 13:15:23 -04:00
|
|
|
NEGATIVE_INF = -1.0/0.0
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
POSITIVE_ZERO = +1.0/POSITIVE_INF
|
|
|
|
NEGATIVE_ZERO = -1.0/POSITIVE_INF
|
2004-07-03 09:33:20 -04:00
|
|
|
MIN_POSITIVE_SINGLE = 2.0 ** -149
|
2003-10-03 13:15:23 -04:00
|
|
|
end
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
class XSDFloat < XSDAnySimpleType
|
2003-10-03 13:15:23 -04:00
|
|
|
include FloatConstants
|
2003-09-24 11:18:44 -04:00
|
|
|
Type = QName.new(Namespace, FloatLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-09-24 11:18:44 -04:00
|
|
|
# "NaN".to_f => 0 in some environment. libc?
|
|
|
|
if value.is_a?(Float)
|
2004-07-03 09:33:20 -04:00
|
|
|
return narrow32bit(value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2003-10-03 13:15:23 -04:00
|
|
|
str = value.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
if str == 'NaN'
|
2004-07-03 09:33:20 -04:00
|
|
|
NaN
|
2003-09-24 11:18:44 -04:00
|
|
|
elsif str == 'INF'
|
2004-07-03 09:33:20 -04:00
|
|
|
POSITIVE_INF
|
2003-09-24 11:18:44 -04:00
|
|
|
elsif str == '-INF'
|
2004-07-03 09:33:20 -04:00
|
|
|
NEGATIVE_INF
|
2003-09-24 11:18:44 -04:00
|
|
|
else
|
|
|
|
if /^[+\-\.\deE]+$/ !~ str
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
|
|
|
# Float("-1.4E") might fail on some system.
|
|
|
|
str << '0' if /e$/i =~ str
|
|
|
|
begin
|
2004-07-03 09:33:20 -04:00
|
|
|
return narrow32bit(Float(str))
|
2003-09-24 11:18:44 -04:00
|
|
|
rescue ArgumentError
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
if @data.nan?
|
|
|
|
'NaN'
|
|
|
|
elsif @data.infinite? == 1
|
|
|
|
'INF'
|
|
|
|
elsif @data.infinite? == -1
|
|
|
|
'-INF'
|
|
|
|
else
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
sign = XSDFloat.positive?(@data) ? '+' : '-'
|
2003-10-03 13:15:23 -04:00
|
|
|
sign + sprintf("%.10g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Convert to single-precision 32-bit floating point value.
|
|
|
|
def narrow32bit(f)
|
|
|
|
if f.nan? || f.infinite?
|
|
|
|
f
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
elsif f.abs < MIN_POSITIVE_SINGLE
|
|
|
|
XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO
|
2003-09-24 11:18:44 -04:00
|
|
|
else
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
f
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-05 21:20:51 -05:00
|
|
|
|
|
|
|
def self.positive?(value)
|
|
|
|
(1 / value) > 0.0
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Ruby's Float is double-precision 64-bit floating point value.
|
|
|
|
class XSDDouble < XSDAnySimpleType
|
2003-10-03 13:15:23 -04:00
|
|
|
include FloatConstants
|
2003-09-24 11:18:44 -04:00
|
|
|
Type = QName.new(Namespace, DoubleLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-09-24 11:18:44 -04:00
|
|
|
# "NaN".to_f => 0 in some environment. libc?
|
|
|
|
if value.is_a?(Float)
|
2004-07-03 09:33:20 -04:00
|
|
|
return value
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2003-10-03 13:15:23 -04:00
|
|
|
str = value.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
if str == 'NaN'
|
2004-07-03 09:33:20 -04:00
|
|
|
NaN
|
2003-09-24 11:18:44 -04:00
|
|
|
elsif str == 'INF'
|
2004-07-03 09:33:20 -04:00
|
|
|
POSITIVE_INF
|
2003-09-24 11:18:44 -04:00
|
|
|
elsif str == '-INF'
|
2004-07-03 09:33:20 -04:00
|
|
|
NEGATIVE_INF
|
2003-09-24 11:18:44 -04:00
|
|
|
else
|
|
|
|
begin
|
2004-07-03 09:33:20 -04:00
|
|
|
return Float(str)
|
2003-09-24 11:18:44 -04:00
|
|
|
rescue ArgumentError
|
|
|
|
# '1.4e' cannot be parsed on some architecture.
|
|
|
|
if /e\z/i =~ str
|
|
|
|
begin
|
2004-07-03 09:33:20 -04:00
|
|
|
return Float(str + '0')
|
2003-09-24 11:18:44 -04:00
|
|
|
rescue ArgumentError
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
if @data.nan?
|
|
|
|
'NaN'
|
|
|
|
elsif @data.infinite? == 1
|
|
|
|
'INF'
|
|
|
|
elsif @data.infinite? == -1
|
|
|
|
'-INF'
|
|
|
|
else
|
2003-10-03 13:15:23 -04:00
|
|
|
sign = (1 / @data > 0.0) ? '+' : '-'
|
|
|
|
sign + sprintf("%.16g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDDuration < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, DurationLiteral)
|
|
|
|
|
|
|
|
attr_accessor :sign
|
|
|
|
attr_accessor :year
|
|
|
|
attr_accessor :month
|
|
|
|
attr_accessor :day
|
|
|
|
attr_accessor :hour
|
|
|
|
attr_accessor :min
|
|
|
|
attr_accessor :sec
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^([+\-]?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/ =~ value.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
|
|
|
if ($5 and ((!$2 and !$3 and !$4) or (!$6 and !$7 and !$8)))
|
|
|
|
# Should we allow 'PT5S' here?
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
sign = $1
|
|
|
|
year = $2.to_i
|
|
|
|
month = $3.to_i
|
|
|
|
day = $4.to_i
|
|
|
|
hour = $6.to_i
|
|
|
|
min = $7.to_i
|
|
|
|
sec = $8 ? XSDDecimal.new($8) : 0
|
|
|
|
[sign, year, month, day, hour, min, sec]
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def _set(data)
|
|
|
|
if data.nil?
|
|
|
|
@sign = @year = @month = @day = @hour = @min = @sec = @data = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
@sign, @year, @month, @day, @hour, @min, @sec = data
|
2003-09-24 11:18:44 -04:00
|
|
|
@data = _to_s
|
2003-11-28 00:53:16 -05:00
|
|
|
@data.freeze
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
str = ''
|
|
|
|
str << @sign if @sign
|
|
|
|
str << 'P'
|
|
|
|
l = ''
|
|
|
|
l << "#{ @year }Y" if @year.nonzero?
|
|
|
|
l << "#{ @month }M" if @month.nonzero?
|
|
|
|
l << "#{ @day }D" if @day.nonzero?
|
|
|
|
r = ''
|
|
|
|
r << "#{ @hour }H" if @hour.nonzero?
|
|
|
|
r << "#{ @min }M" if @min.nonzero?
|
|
|
|
r << "#{ @sec }S" if @sec.nonzero?
|
|
|
|
str << l
|
|
|
|
if l.empty?
|
|
|
|
str << "0D"
|
|
|
|
end
|
|
|
|
unless r.empty?
|
|
|
|
str << "T" << r
|
|
|
|
end
|
|
|
|
str
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
require 'rational'
|
|
|
|
require 'date'
|
|
|
|
|
|
|
|
module XSDDateTimeImpl
|
|
|
|
SecInDay = 86400 # 24 * 60 * 60
|
|
|
|
|
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.4.
== SOAP client and server ==
=== for both client side and server side ===
* improved document/literal service support.
style(rpc,document)/use(encoding, literal) combination are all
supported. for the detail about combination, see
test/soap/test_style.rb.
* let WSDLEncodedRegistry#soap2obj map SOAP/OM to Ruby according to
WSDL as well as obj2soap. closes #70.
* let SOAP::Mapping::Object handle XML attribute for doc/lit service.
you can set/get XML attribute via accessor methods which as a name
'xmlattr_' prefixed (<foo name="bar"/> -> Foo#xmlattr_name).
=== client side ===
* WSDLDriver capitalized name operation bug fixed. from
1.5.3-ruby1.8.2, operation which has capitalized name (such as
KeywordSearchRequest in AWS) is defined as a method having
uncapitalized name. (converted with GenSupport.safemethodname
to handle operation name 'foo-bar'). it introduced serious
incompatibility; in the past, it was defined as a capitalized.
define capitalized method as well under that circumstance.
* added new factory interface 'WSDLDriverFactory#create_rpc_driver'
to create RPC::Driver, not WSDLDriver (RPC::Driver and WSDLDriver
are merged). 'WSDLDriverFactory#create_driver' still creates
WSDLDriver for compatibility but it warns that the method is
deprecated. please use create_rpc_driver instead of create_driver.
* allow to use an URI object as an endpoint_url even with net/http,
not http-access2.
=== server side ===
* added mod_ruby support to SOAP::CGIStub. rename a CGI script
server.cgi to server.rb and let mod_ruby's RubyHandler handles the
script. CGIStub detects if it's running under mod_ruby environment
or not.
* added fcgi support to SOAP::CGIStub. see the sample at
sample/soap/calc/server.fcgi. (almost same as server.cgi but has
fcgi handler at the bottom.)
* allow to return a SOAPFault object to respond customized SOAP fault.
* added the interface 'generate_explicit_type' for server side
(CGIStub, HTTPServer). call 'self.generate_explicit_type = true'
if you want to return simplified XML even if it's rpc/encoded
service.
== WSDL ==
=== WSDL definition ===
* improved XML Schema support such as extension, restriction,
simpleType, complexType + simpleContent, ref, length, import,
include.
* reduced "unknown element/attribute" warnings (warn only 1 time for
each QName).
* importing XSD file at schemaLocation with xsd:import.
=== code generation from WSDL ===
* generator crashed when there's '-' in defined element/attribute
name.
* added ApacheMap WSDL definition.
* sample/{soap,wsdl}: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-22 09:03:38 -04:00
|
|
|
def to_obj(klass)
|
|
|
|
if klass == Time
|
|
|
|
to_time
|
|
|
|
elsif klass == Date
|
|
|
|
to_date
|
|
|
|
elsif klass == DateTime
|
|
|
|
to_datetime
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
def to_time
|
|
|
|
begin
|
2003-10-14 11:14:02 -04:00
|
|
|
if @data.offset * SecInDay == Time.now.utc_offset
|
2003-09-24 11:18:44 -04:00
|
|
|
d = @data
|
2003-11-28 00:53:16 -05:00
|
|
|
usec = (d.sec_fraction * SecInDay * 1000000).round
|
2003-09-24 11:18:44 -04:00
|
|
|
Time.local(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
|
|
|
|
else
|
|
|
|
d = @data.newof
|
2003-11-28 00:53:16 -05:00
|
|
|
usec = (d.sec_fraction * SecInDay * 1000000).round
|
2003-09-24 11:18:44 -04:00
|
|
|
Time.gm(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
|
|
|
|
end
|
|
|
|
rescue ArgumentError
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.4.
== SOAP client and server ==
=== for both client side and server side ===
* improved document/literal service support.
style(rpc,document)/use(encoding, literal) combination are all
supported. for the detail about combination, see
test/soap/test_style.rb.
* let WSDLEncodedRegistry#soap2obj map SOAP/OM to Ruby according to
WSDL as well as obj2soap. closes #70.
* let SOAP::Mapping::Object handle XML attribute for doc/lit service.
you can set/get XML attribute via accessor methods which as a name
'xmlattr_' prefixed (<foo name="bar"/> -> Foo#xmlattr_name).
=== client side ===
* WSDLDriver capitalized name operation bug fixed. from
1.5.3-ruby1.8.2, operation which has capitalized name (such as
KeywordSearchRequest in AWS) is defined as a method having
uncapitalized name. (converted with GenSupport.safemethodname
to handle operation name 'foo-bar'). it introduced serious
incompatibility; in the past, it was defined as a capitalized.
define capitalized method as well under that circumstance.
* added new factory interface 'WSDLDriverFactory#create_rpc_driver'
to create RPC::Driver, not WSDLDriver (RPC::Driver and WSDLDriver
are merged). 'WSDLDriverFactory#create_driver' still creates
WSDLDriver for compatibility but it warns that the method is
deprecated. please use create_rpc_driver instead of create_driver.
* allow to use an URI object as an endpoint_url even with net/http,
not http-access2.
=== server side ===
* added mod_ruby support to SOAP::CGIStub. rename a CGI script
server.cgi to server.rb and let mod_ruby's RubyHandler handles the
script. CGIStub detects if it's running under mod_ruby environment
or not.
* added fcgi support to SOAP::CGIStub. see the sample at
sample/soap/calc/server.fcgi. (almost same as server.cgi but has
fcgi handler at the bottom.)
* allow to return a SOAPFault object to respond customized SOAP fault.
* added the interface 'generate_explicit_type' for server side
(CGIStub, HTTPServer). call 'self.generate_explicit_type = true'
if you want to return simplified XML even if it's rpc/encoded
service.
== WSDL ==
=== WSDL definition ===
* improved XML Schema support such as extension, restriction,
simpleType, complexType + simpleContent, ref, length, import,
include.
* reduced "unknown element/attribute" warnings (warn only 1 time for
each QName).
* importing XSD file at schemaLocation with xsd:import.
=== code generation from WSDL ===
* generator crashed when there's '-' in defined element/attribute
name.
* added ApacheMap WSDL definition.
* sample/{soap,wsdl}: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-22 09:03:38 -04:00
|
|
|
def to_date
|
|
|
|
Date.new0(@data.class.jd_to_ajd(@data.jd, 0, 0), 0, @data.start)
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_datetime
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
def tz2of(str)
|
|
|
|
/^(?:Z|(?:([+\-])(\d\d):(\d\d))?)$/ =~ str
|
|
|
|
sign = $1
|
|
|
|
hour = $2.to_i
|
|
|
|
min = $3.to_i
|
|
|
|
|
|
|
|
of = case sign
|
|
|
|
when '+'
|
|
|
|
of = +(hour.to_r * 60 + min) / 1440 # 24 * 60
|
|
|
|
when '-'
|
|
|
|
of = -(hour.to_r * 60 + min) / 1440 # 24 * 60
|
|
|
|
else
|
|
|
|
0
|
|
|
|
end
|
|
|
|
of
|
|
|
|
end
|
|
|
|
|
|
|
|
def of2tz(offset)
|
|
|
|
diffmin = offset * 24 * 60
|
|
|
|
if diffmin.zero?
|
|
|
|
'Z'
|
|
|
|
else
|
|
|
|
((diffmin < 0) ? '-' : '+') << format('%02d:%02d',
|
|
|
|
(diffmin.abs / 60.0).to_i, (diffmin.abs % 60.0).to_i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(t)
|
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.4.
== SOAP client and server ==
=== for both client side and server side ===
* improved document/literal service support.
style(rpc,document)/use(encoding, literal) combination are all
supported. for the detail about combination, see
test/soap/test_style.rb.
* let WSDLEncodedRegistry#soap2obj map SOAP/OM to Ruby according to
WSDL as well as obj2soap. closes #70.
* let SOAP::Mapping::Object handle XML attribute for doc/lit service.
you can set/get XML attribute via accessor methods which as a name
'xmlattr_' prefixed (<foo name="bar"/> -> Foo#xmlattr_name).
=== client side ===
* WSDLDriver capitalized name operation bug fixed. from
1.5.3-ruby1.8.2, operation which has capitalized name (such as
KeywordSearchRequest in AWS) is defined as a method having
uncapitalized name. (converted with GenSupport.safemethodname
to handle operation name 'foo-bar'). it introduced serious
incompatibility; in the past, it was defined as a capitalized.
define capitalized method as well under that circumstance.
* added new factory interface 'WSDLDriverFactory#create_rpc_driver'
to create RPC::Driver, not WSDLDriver (RPC::Driver and WSDLDriver
are merged). 'WSDLDriverFactory#create_driver' still creates
WSDLDriver for compatibility but it warns that the method is
deprecated. please use create_rpc_driver instead of create_driver.
* allow to use an URI object as an endpoint_url even with net/http,
not http-access2.
=== server side ===
* added mod_ruby support to SOAP::CGIStub. rename a CGI script
server.cgi to server.rb and let mod_ruby's RubyHandler handles the
script. CGIStub detects if it's running under mod_ruby environment
or not.
* added fcgi support to SOAP::CGIStub. see the sample at
sample/soap/calc/server.fcgi. (almost same as server.cgi but has
fcgi handler at the bottom.)
* allow to return a SOAPFault object to respond customized SOAP fault.
* added the interface 'generate_explicit_type' for server side
(CGIStub, HTTPServer). call 'self.generate_explicit_type = true'
if you want to return simplified XML even if it's rpc/encoded
service.
== WSDL ==
=== WSDL definition ===
* improved XML Schema support such as extension, restriction,
simpleType, complexType + simpleContent, ref, length, import,
include.
* reduced "unknown element/attribute" warnings (warn only 1 time for
each QName).
* importing XSD file at schemaLocation with xsd:import.
=== code generation from WSDL ===
* generator crashed when there's '-' in defined element/attribute
name.
* added ApacheMap WSDL definition.
* sample/{soap,wsdl}: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-22 09:03:38 -04:00
|
|
|
# convert t to a DateTime as an internal representation.
|
2005-09-15 10:33:53 -04:00
|
|
|
if t.respond_to?(:to_datetime) # 1.9 or later
|
|
|
|
t.to_datetime
|
|
|
|
elsif t.is_a?(DateTime)
|
2004-07-03 09:33:20 -04:00
|
|
|
t
|
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.4.
== SOAP client and server ==
=== for both client side and server side ===
* improved document/literal service support.
style(rpc,document)/use(encoding, literal) combination are all
supported. for the detail about combination, see
test/soap/test_style.rb.
* let WSDLEncodedRegistry#soap2obj map SOAP/OM to Ruby according to
WSDL as well as obj2soap. closes #70.
* let SOAP::Mapping::Object handle XML attribute for doc/lit service.
you can set/get XML attribute via accessor methods which as a name
'xmlattr_' prefixed (<foo name="bar"/> -> Foo#xmlattr_name).
=== client side ===
* WSDLDriver capitalized name operation bug fixed. from
1.5.3-ruby1.8.2, operation which has capitalized name (such as
KeywordSearchRequest in AWS) is defined as a method having
uncapitalized name. (converted with GenSupport.safemethodname
to handle operation name 'foo-bar'). it introduced serious
incompatibility; in the past, it was defined as a capitalized.
define capitalized method as well under that circumstance.
* added new factory interface 'WSDLDriverFactory#create_rpc_driver'
to create RPC::Driver, not WSDLDriver (RPC::Driver and WSDLDriver
are merged). 'WSDLDriverFactory#create_driver' still creates
WSDLDriver for compatibility but it warns that the method is
deprecated. please use create_rpc_driver instead of create_driver.
* allow to use an URI object as an endpoint_url even with net/http,
not http-access2.
=== server side ===
* added mod_ruby support to SOAP::CGIStub. rename a CGI script
server.cgi to server.rb and let mod_ruby's RubyHandler handles the
script. CGIStub detects if it's running under mod_ruby environment
or not.
* added fcgi support to SOAP::CGIStub. see the sample at
sample/soap/calc/server.fcgi. (almost same as server.cgi but has
fcgi handler at the bottom.)
* allow to return a SOAPFault object to respond customized SOAP fault.
* added the interface 'generate_explicit_type' for server side
(CGIStub, HTTPServer). call 'self.generate_explicit_type = true'
if you want to return simplified XML even if it's rpc/encoded
service.
== WSDL ==
=== WSDL definition ===
* improved XML Schema support such as extension, restriction,
simpleType, complexType + simpleContent, ref, length, import,
include.
* reduced "unknown element/attribute" warnings (warn only 1 time for
each QName).
* importing XSD file at schemaLocation with xsd:import.
=== code generation from WSDL ===
* generator crashed when there's '-' in defined element/attribute
name.
* added ApacheMap WSDL definition.
* sample/{soap,wsdl}: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-22 09:03:38 -04:00
|
|
|
elsif t.is_a?(Date)
|
2005-09-15 10:33:53 -04:00
|
|
|
t = screen_data_str(t)
|
|
|
|
t <<= 12 if t.year < 0
|
|
|
|
t
|
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.4.
== SOAP client and server ==
=== for both client side and server side ===
* improved document/literal service support.
style(rpc,document)/use(encoding, literal) combination are all
supported. for the detail about combination, see
test/soap/test_style.rb.
* let WSDLEncodedRegistry#soap2obj map SOAP/OM to Ruby according to
WSDL as well as obj2soap. closes #70.
* let SOAP::Mapping::Object handle XML attribute for doc/lit service.
you can set/get XML attribute via accessor methods which as a name
'xmlattr_' prefixed (<foo name="bar"/> -> Foo#xmlattr_name).
=== client side ===
* WSDLDriver capitalized name operation bug fixed. from
1.5.3-ruby1.8.2, operation which has capitalized name (such as
KeywordSearchRequest in AWS) is defined as a method having
uncapitalized name. (converted with GenSupport.safemethodname
to handle operation name 'foo-bar'). it introduced serious
incompatibility; in the past, it was defined as a capitalized.
define capitalized method as well under that circumstance.
* added new factory interface 'WSDLDriverFactory#create_rpc_driver'
to create RPC::Driver, not WSDLDriver (RPC::Driver and WSDLDriver
are merged). 'WSDLDriverFactory#create_driver' still creates
WSDLDriver for compatibility but it warns that the method is
deprecated. please use create_rpc_driver instead of create_driver.
* allow to use an URI object as an endpoint_url even with net/http,
not http-access2.
=== server side ===
* added mod_ruby support to SOAP::CGIStub. rename a CGI script
server.cgi to server.rb and let mod_ruby's RubyHandler handles the
script. CGIStub detects if it's running under mod_ruby environment
or not.
* added fcgi support to SOAP::CGIStub. see the sample at
sample/soap/calc/server.fcgi. (almost same as server.cgi but has
fcgi handler at the bottom.)
* allow to return a SOAPFault object to respond customized SOAP fault.
* added the interface 'generate_explicit_type' for server side
(CGIStub, HTTPServer). call 'self.generate_explicit_type = true'
if you want to return simplified XML even if it's rpc/encoded
service.
== WSDL ==
=== WSDL definition ===
* improved XML Schema support such as extension, restriction,
simpleType, complexType + simpleContent, ref, length, import,
include.
* reduced "unknown element/attribute" warnings (warn only 1 time for
each QName).
* importing XSD file at schemaLocation with xsd:import.
=== code generation from WSDL ===
* generator crashed when there's '-' in defined element/attribute
name.
* added ApacheMap WSDL definition.
* sample/{soap,wsdl}: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-22 09:03:38 -04:00
|
|
|
elsif t.is_a?(Time)
|
2005-09-15 10:33:53 -04:00
|
|
|
jd = DateTime.civil_to_jd(t.year, t.mon, t.mday, DateTime::ITALY)
|
|
|
|
fr = DateTime.time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) +
|
|
|
|
t.usec.to_r / 1000000 / SecInDay
|
2003-09-24 11:18:44 -04:00
|
|
|
of = t.utc_offset.to_r / SecInDay
|
2005-09-15 10:33:53 -04:00
|
|
|
DateTime.new0(DateTime.jd_to_ajd(jd, fr, of), of, DateTime::ITALY)
|
2003-09-24 11:18:44 -04:00
|
|
|
else
|
2004-07-03 09:33:20 -04:00
|
|
|
screen_data_str(t)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_tz(s)
|
|
|
|
s + of2tz(@data.offset)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDDateTime < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, DateTimeLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
if $1 == '0000'
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
year = $1.to_i
|
|
|
|
if year < 0
|
|
|
|
year += 1
|
|
|
|
end
|
|
|
|
mon = $2.to_i
|
|
|
|
mday = $3.to_i
|
|
|
|
hour = $4.to_i
|
|
|
|
min = $5.to_i
|
|
|
|
sec = $6.to_i
|
|
|
|
secfrac = $7
|
|
|
|
zonestr = $8
|
2004-07-03 09:33:20 -04:00
|
|
|
data = DateTime.civil(year, mon, mday, hour, min, sec, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
if secfrac
|
|
|
|
diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
|
2004-07-03 09:33:20 -04:00
|
|
|
data += diffday
|
2003-09-24 11:18:44 -04:00
|
|
|
# FYI: new0 and jd_to_rjd are not necessary to use if you don't have
|
|
|
|
# exceptional reason.
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
[data, secfrac]
|
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def _set(data)
|
|
|
|
if data.nil?
|
|
|
|
@data = @secfrac = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
@data, @secfrac = data
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
year = (@data.year > 0) ? @data.year : @data.year - 1
|
|
|
|
s = format('%.4d-%02d-%02dT%02d:%02d:%02d',
|
|
|
|
year, @data.mon, @data.mday, @data.hour, @data.min, @data.sec)
|
|
|
|
if @data.sec_fraction.nonzero?
|
2003-11-28 00:53:16 -05:00
|
|
|
if @secfrac
|
|
|
|
s << ".#{ @secfrac }"
|
|
|
|
else
|
2004-07-03 09:33:20 -04:00
|
|
|
s << sprintf("%.16f",
|
|
|
|
(@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
|
2003-11-28 00:53:16 -05:00
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDTime < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, TimeLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
hour = $1.to_i
|
|
|
|
min = $2.to_i
|
|
|
|
sec = $3.to_i
|
|
|
|
secfrac = $4
|
|
|
|
zonestr = $5
|
2004-07-03 09:33:20 -04:00
|
|
|
data = DateTime.civil(1, 1, 1, hour, min, sec, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
if secfrac
|
2003-11-28 00:53:16 -05:00
|
|
|
diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
|
2004-07-03 09:33:20 -04:00
|
|
|
data += diffday
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
[data, secfrac]
|
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def _set(data)
|
|
|
|
if data.nil?
|
|
|
|
@data = @secfrac = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
@data, @secfrac = data
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
s = format('%02d:%02d:%02d', @data.hour, @data.min, @data.sec)
|
|
|
|
if @data.sec_fraction.nonzero?
|
2003-11-28 00:53:16 -05:00
|
|
|
if @secfrac
|
|
|
|
s << ".#{ @secfrac }"
|
|
|
|
else
|
2004-07-03 09:33:20 -04:00
|
|
|
s << sprintf("%.16f",
|
|
|
|
(@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
|
2003-11-28 00:53:16 -05:00
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDDate < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, DateLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
year = $1.to_i
|
|
|
|
if year < 0
|
|
|
|
year += 1
|
|
|
|
end
|
|
|
|
mon = $2.to_i
|
|
|
|
mday = $3.to_i
|
|
|
|
zonestr = $4
|
2004-07-03 09:33:20 -04:00
|
|
|
DateTime.civil(year, mon, mday, 0, 0, 0, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
year = (@data.year > 0) ? @data.year : @data.year - 1
|
|
|
|
s = format('%.4d-%02d-%02d', year, @data.mon, @data.mday)
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDGYearMonth < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, GYearMonthLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
year = $1.to_i
|
|
|
|
if year < 0
|
|
|
|
year += 1
|
|
|
|
end
|
|
|
|
mon = $2.to_i
|
|
|
|
zonestr = $3
|
2004-07-03 09:33:20 -04:00
|
|
|
DateTime.civil(year, mon, 1, 0, 0, 0, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
year = (@data.year > 0) ? @data.year : @data.year - 1
|
|
|
|
s = format('%.4d-%02d', year, @data.mon)
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDGYear < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, GYearLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
year = $1.to_i
|
|
|
|
if year < 0
|
|
|
|
year += 1
|
|
|
|
end
|
|
|
|
zonestr = $2
|
2004-07-03 09:33:20 -04:00
|
|
|
DateTime.civil(year, 1, 1, 0, 0, 0, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
year = (@data.year > 0) ? @data.year : @data.year - 1
|
|
|
|
s = format('%.4d', year)
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDGMonthDay < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, GMonthDayLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^(\d\d)-(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
mon = $1.to_i
|
|
|
|
mday = $2.to_i
|
|
|
|
zonestr = $3
|
2004-07-03 09:33:20 -04:00
|
|
|
DateTime.civil(1, mon, mday, 0, 0, 0, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
s = format('%02d-%02d', @data.mon, @data.mday)
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDGDay < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, GDayLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
mday = $1.to_i
|
|
|
|
zonestr = $2
|
2004-07-03 09:33:20 -04:00
|
|
|
DateTime.civil(1, 1, mday, 0, 0, 0, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
s = format('%02d', @data.mday)
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDGMonth < XSDAnySimpleType
|
|
|
|
include XSDDateTimeImpl
|
|
|
|
Type = QName.new(Namespace, GMonthLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(t)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
|
|
|
end
|
|
|
|
mon = $1.to_i
|
|
|
|
zonestr = $2
|
2004-07-03 09:33:20 -04:00
|
|
|
DateTime.civil(1, mon, 1, 0, 0, 0, tz2of(zonestr))
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
s = format('%02d', @data.mon)
|
|
|
|
add_tz(s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDHexBinary < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, HexBinaryLiteral)
|
|
|
|
|
|
|
|
# String in Ruby could be a binary.
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_encoded(value)
|
|
|
|
if /^[0-9a-fA-F]*$/ !~ value
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
2003-10-03 13:15:23 -04:00
|
|
|
@data = String.new(value).strip
|
2003-09-24 11:18:44 -04:00
|
|
|
@is_nil = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def string
|
|
|
|
[@data].pack("H*")
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
|
|
|
value.unpack("H*")[0].tr('a-f', 'A-F')
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDBase64Binary < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, Base64BinaryLiteral)
|
|
|
|
|
|
|
|
# String in Ruby could be a binary.
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_encoded(value)
|
|
|
|
if /^[A-Za-z0-9+\/=]*$/ !~ value
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
2003-10-03 13:15:23 -04:00
|
|
|
@data = String.new(value).strip
|
2003-09-24 11:18:44 -04:00
|
|
|
@is_nil = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def string
|
|
|
|
@data.unpack("m")[0]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
|
|
|
[value].pack("m").strip
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDAnyURI < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, AnyURILiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-09-24 11:18:44 -04:00
|
|
|
begin
|
2004-07-03 09:33:20 -04:00
|
|
|
URI.parse(value.to_s.strip)
|
2003-09-24 11:18:44 -04:00
|
|
|
rescue URI::InvalidURIError
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDQName < XSDAnySimpleType
|
|
|
|
Type = QName.new(Namespace, QNameLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-10-03 13:15:23 -04:00
|
|
|
/^(?:([^:]+):)?([^:]+)$/ =~ value.to_s.strip
|
2003-09-24 11:18:44 -04:00
|
|
|
unless Regexp.last_match
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
prefix = $1
|
|
|
|
localpart = $2
|
|
|
|
[prefix, localpart]
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def _set(data)
|
|
|
|
if data.nil?
|
|
|
|
@prefix = @localpart = @data = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
@prefix, @localpart = data
|
2003-09-24 11:18:44 -04:00
|
|
|
@data = _to_s
|
2003-11-28 00:53:16 -05:00
|
|
|
@data.freeze
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s
|
|
|
|
if @prefix
|
|
|
|
"#{ @prefix }:#{ @localpart }"
|
|
|
|
else
|
|
|
|
"#{ @localpart }"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
## Derived types
|
|
|
|
#
|
|
|
|
class XSDNormalizedString < XSDString
|
|
|
|
Type = QName.new(Namespace, NormalizedStringLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data(value)
|
2003-09-24 11:18:44 -04:00
|
|
|
if /[\t\r\n]/ =~ value
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
|
|
|
end
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDInteger < XSDDecimal
|
|
|
|
Type = QName.new(Namespace, IntegerLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-07-03 09:33:20 -04:00
|
|
|
def screen_data_str(str)
|
2003-09-24 11:18:44 -04:00
|
|
|
begin
|
2004-07-03 09:33:20 -04:00
|
|
|
data = Integer(str)
|
2003-09-24 11:18:44 -04:00
|
|
|
rescue ArgumentError
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
unless validate(data)
|
|
|
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
|
|
|
end
|
2004-07-03 09:33:20 -04:00
|
|
|
data
|
|
|
|
end
|
|
|
|
|
|
|
|
def _set(value)
|
|
|
|
@data = value
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def _to_s()
|
|
|
|
@data.to_s
|
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
|
|
|
|
def validate(v)
|
|
|
|
max = maxinclusive
|
|
|
|
min = mininclusive
|
|
|
|
(max.nil? or v <= max) and (min.nil? or v >= min)
|
|
|
|
end
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
PositiveMinInclusive = 1
|
|
|
|
def positive(v)
|
|
|
|
PositiveMinInclusive <= v
|
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
class XSDNonPositiveInteger < XSDInteger
|
|
|
|
Type = QName.new(Namespace, NonPositiveIntegerLiteral)
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def maxinclusive
|
|
|
|
0
|
2004-07-03 09:33:20 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def mininclusive
|
|
|
|
nil
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
class XSDNegativeInteger < XSDNonPositiveInteger
|
|
|
|
Type = QName.new(Namespace, NegativeIntegerLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
-1
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
nil
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
class XSDLong < XSDInteger
|
|
|
|
Type = QName.new(Namespace, LongLiteral)
|
2003-09-24 11:18:44 -04:00
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def maxinclusive
|
|
|
|
+9223372036854775807
|
2004-07-03 09:33:20 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def mininclusive
|
|
|
|
-9223372036854775808
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
class XSDInt < XSDLong
|
|
|
|
Type = QName.new(Namespace, IntLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
+2147483647
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
-2147483648
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDShort < XSDInt
|
|
|
|
Type = QName.new(Namespace, ShortLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
2004-12-20 08:50:15 -05:00
|
|
|
init(Type, value)
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def maxinclusive
|
|
|
|
+32767
|
2004-07-03 09:33:20 -04:00
|
|
|
end
|
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
def mininclusive
|
|
|
|
-32768
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
2004-12-20 08:50:15 -05:00
|
|
|
end
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2004-12-20 08:50:15 -05:00
|
|
|
class XSDByte < XSDShort
|
|
|
|
Type = QName.new(Namespace, ByteLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
+127
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
-128
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDNonNegativeInteger < XSDInteger
|
|
|
|
Type = QName.new(Namespace, NonNegativeIntegerLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDUnsignedLong < XSDNonNegativeInteger
|
|
|
|
Type = QName.new(Namespace, UnsignedLongLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
+18446744073709551615
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDUnsignedInt < XSDUnsignedLong
|
|
|
|
Type = QName.new(Namespace, UnsignedIntLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
+4294967295
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDUnsignedShort < XSDUnsignedInt
|
|
|
|
Type = QName.new(Namespace, UnsignedShortLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
+65535
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDUnsignedByte < XSDUnsignedShort
|
|
|
|
Type = QName.new(Namespace, UnsignedByteLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
+255
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class XSDPositiveInteger < XSDNonNegativeInteger
|
|
|
|
Type = QName.new(Namespace, PositiveIntegerLiteral)
|
|
|
|
|
|
|
|
def initialize(value = nil)
|
|
|
|
init(Type, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def maxinclusive
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def mininclusive
|
|
|
|
1
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|