soap4r 1.5.5.20061022

Sign up to get free protection for your applications and to get access to all the features.
Files changed (440) hide show
  1. data/bin/wsdl2ruby.rb +131 -0
  2. data/bin/xsd2ruby.rb +82 -0
  3. data/lib/soap/XMLSchemaDatatypes.rb +9 -0
  4. data/lib/soap/XMLSchemaDatatypes1999.rb +10 -0
  5. data/lib/soap/attachment.rb +108 -0
  6. data/lib/soap/baseData.rb +992 -0
  7. data/lib/soap/cgistub.rb +9 -0
  8. data/lib/soap/charset.rb +9 -0
  9. data/lib/soap/compat.rb +182 -0
  10. data/lib/soap/driver.rb +9 -0
  11. data/lib/soap/element.rb +266 -0
  12. data/lib/soap/encodingstyle/aspDotNetHandler.rb +207 -0
  13. data/lib/soap/encodingstyle/handler.rb +109 -0
  14. data/lib/soap/encodingstyle/literalHandler.rb +241 -0
  15. data/lib/soap/encodingstyle/soapHandler.rb +598 -0
  16. data/lib/soap/generator.rb +264 -0
  17. data/lib/soap/header/handler.rb +60 -0
  18. data/lib/soap/header/handlerset.rb +70 -0
  19. data/lib/soap/header/simplehandler.rb +44 -0
  20. data/lib/soap/httpconfigloader.rb +119 -0
  21. data/lib/soap/mapping.rb +12 -0
  22. data/lib/soap/mapping/encodedregistry.rb +531 -0
  23. data/lib/soap/mapping/factory.rb +372 -0
  24. data/lib/soap/mapping/literalregistry.rb +321 -0
  25. data/lib/soap/mapping/mapping.rb +561 -0
  26. data/lib/soap/mapping/registry.rb +258 -0
  27. data/lib/soap/mapping/rubytypeFactory.rb +475 -0
  28. data/lib/soap/mapping/typeMap.rb +82 -0
  29. data/lib/soap/mapping/wsdlencodedregistry.rb +253 -0
  30. data/lib/soap/mapping/wsdlliteralregistry.rb +246 -0
  31. data/lib/soap/mappingRegistry.rb +9 -0
  32. data/lib/soap/marshal.rb +59 -0
  33. data/lib/soap/mimemessage.rb +241 -0
  34. data/lib/soap/namespace.rb +9 -0
  35. data/lib/soap/netHttpClient.rb +204 -0
  36. data/lib/soap/parser.rb +251 -0
  37. data/lib/soap/processor.rb +66 -0
  38. data/lib/soap/property.rb +333 -0
  39. data/lib/soap/proxy.rb +14 -0
  40. data/lib/soap/qname.rb +9 -0
  41. data/lib/soap/rpc/cgistub.rb +214 -0
  42. data/lib/soap/rpc/driver.rb +245 -0
  43. data/lib/soap/rpc/element.rb +330 -0
  44. data/lib/soap/rpc/httpserver.rb +143 -0
  45. data/lib/soap/rpc/proxy.rb +563 -0
  46. data/lib/soap/rpc/router.rb +602 -0
  47. data/lib/soap/rpc/rpc.rb +25 -0
  48. data/lib/soap/rpc/soaplet.rb +162 -0
  49. data/lib/soap/rpc/standaloneServer.rb +43 -0
  50. data/lib/soap/rpcRouter.rb +9 -0
  51. data/lib/soap/rpcUtils.rb +9 -0
  52. data/lib/soap/server.rb +9 -0
  53. data/lib/soap/soap.rb +150 -0
  54. data/lib/soap/standaloneServer.rb +9 -0
  55. data/lib/soap/streamHandler.rb +258 -0
  56. data/lib/soap/wsdlDriver.rb +580 -0
  57. data/lib/wsdl/binding.rb +65 -0
  58. data/lib/wsdl/data.rb +64 -0
  59. data/lib/wsdl/definitions.rb +250 -0
  60. data/lib/wsdl/documentation.rb +32 -0
  61. data/lib/wsdl/import.rb +80 -0
  62. data/lib/wsdl/importer.rb +38 -0
  63. data/lib/wsdl/info.rb +39 -0
  64. data/lib/wsdl/message.rb +54 -0
  65. data/lib/wsdl/operation.rb +175 -0
  66. data/lib/wsdl/operationBinding.rb +116 -0
  67. data/lib/wsdl/param.rb +85 -0
  68. data/lib/wsdl/parser.rb +163 -0
  69. data/lib/wsdl/part.rb +52 -0
  70. data/lib/wsdl/port.rb +84 -0
  71. data/lib/wsdl/portType.rb +75 -0
  72. data/lib/wsdl/service.rb +61 -0
  73. data/lib/wsdl/soap/address.rb +40 -0
  74. data/lib/wsdl/soap/binding.rb +49 -0
  75. data/lib/wsdl/soap/body.rb +56 -0
  76. data/lib/wsdl/soap/cgiStubCreator.rb +88 -0
  77. data/lib/wsdl/soap/classDefCreator.rb +340 -0
  78. data/lib/wsdl/soap/classDefCreatorSupport.rb +131 -0
  79. data/lib/wsdl/soap/clientSkeltonCreator.rb +93 -0
  80. data/lib/wsdl/soap/complexType.rb +166 -0
  81. data/lib/wsdl/soap/data.rb +42 -0
  82. data/lib/wsdl/soap/definitions.rb +151 -0
  83. data/lib/wsdl/soap/driverCreator.rb +110 -0
  84. data/lib/wsdl/soap/element.rb +28 -0
  85. data/lib/wsdl/soap/encodedMappingRegistryCreator.rb +117 -0
  86. data/lib/wsdl/soap/fault.rb +56 -0
  87. data/lib/wsdl/soap/header.rb +86 -0
  88. data/lib/wsdl/soap/headerfault.rb +56 -0
  89. data/lib/wsdl/soap/literalMappingRegistryCreator.rb +188 -0
  90. data/lib/wsdl/soap/mappingRegistryCreator.rb +53 -0
  91. data/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +233 -0
  92. data/lib/wsdl/soap/methodDefCreator.rb +253 -0
  93. data/lib/wsdl/soap/operation.rb +122 -0
  94. data/lib/wsdl/soap/servantSkeltonCreator.rb +78 -0
  95. data/lib/wsdl/soap/standaloneServerStubCreator.rb +98 -0
  96. data/lib/wsdl/soap/wsdl2ruby.rb +196 -0
  97. data/lib/wsdl/types.rb +44 -0
  98. data/lib/wsdl/wsdl.rb +23 -0
  99. data/lib/wsdl/xmlSchema/all.rb +24 -0
  100. data/lib/wsdl/xmlSchema/annotation.rb +34 -0
  101. data/lib/wsdl/xmlSchema/any.rb +56 -0
  102. data/lib/wsdl/xmlSchema/attribute.rb +123 -0
  103. data/lib/wsdl/xmlSchema/choice.rb +55 -0
  104. data/lib/wsdl/xmlSchema/complexContent.rb +88 -0
  105. data/lib/wsdl/xmlSchema/complexExtension.rb +104 -0
  106. data/lib/wsdl/xmlSchema/complexRestriction.rb +92 -0
  107. data/lib/wsdl/xmlSchema/complexType.rb +152 -0
  108. data/lib/wsdl/xmlSchema/content.rb +74 -0
  109. data/lib/wsdl/xmlSchema/data.rb +90 -0
  110. data/lib/wsdl/xmlSchema/element.rb +158 -0
  111. data/lib/wsdl/xmlSchema/enumeration.rb +36 -0
  112. data/lib/wsdl/xmlSchema/import.rb +65 -0
  113. data/lib/wsdl/xmlSchema/importer.rb +87 -0
  114. data/lib/wsdl/xmlSchema/include.rb +54 -0
  115. data/lib/wsdl/xmlSchema/length.rb +35 -0
  116. data/lib/wsdl/xmlSchema/list.rb +48 -0
  117. data/lib/wsdl/xmlSchema/maxlength.rb +35 -0
  118. data/lib/wsdl/xmlSchema/minlength.rb +35 -0
  119. data/lib/wsdl/xmlSchema/parser.rb +166 -0
  120. data/lib/wsdl/xmlSchema/pattern.rb +36 -0
  121. data/lib/wsdl/xmlSchema/schema.rb +144 -0
  122. data/lib/wsdl/xmlSchema/sequence.rb +51 -0
  123. data/lib/wsdl/xmlSchema/simpleContent.rb +69 -0
  124. data/lib/wsdl/xmlSchema/simpleExtension.rb +54 -0
  125. data/lib/wsdl/xmlSchema/simpleRestriction.rb +91 -0
  126. data/lib/wsdl/xmlSchema/simpleType.rb +80 -0
  127. data/lib/wsdl/xmlSchema/unique.rb +34 -0
  128. data/lib/wsdl/xmlSchema/xsd2ruby.rb +107 -0
  129. data/lib/xsd/charset.rb +187 -0
  130. data/lib/xsd/codegen.rb +12 -0
  131. data/lib/xsd/codegen/classdef.rb +203 -0
  132. data/lib/xsd/codegen/commentdef.rb +34 -0
  133. data/lib/xsd/codegen/gensupport.rb +168 -0
  134. data/lib/xsd/codegen/methoddef.rb +70 -0
  135. data/lib/xsd/codegen/moduledef.rb +191 -0
  136. data/lib/xsd/datatypes.rb +1282 -0
  137. data/lib/xsd/datatypes1999.rb +20 -0
  138. data/lib/xsd/iconvcharset.rb +33 -0
  139. data/lib/xsd/mapping.rb +42 -0
  140. data/lib/xsd/namedelements.rb +124 -0
  141. data/lib/xsd/ns.rb +146 -0
  142. data/lib/xsd/qname.rb +78 -0
  143. data/lib/xsd/xmlparser.rb +61 -0
  144. data/lib/xsd/xmlparser/parser.rb +96 -0
  145. data/lib/xsd/xmlparser/rexmlparser.rb +54 -0
  146. data/lib/xsd/xmlparser/xmlparser.rb +50 -0
  147. data/lib/xsd/xmlparser/xmlscanner.rb +147 -0
  148. data/test/16runner.rb +68 -0
  149. data/test/interopR2/README.txt +2 -0
  150. data/test/interopR2/SOAPBuildersInterop_R2.wsdl +461 -0
  151. data/test/interopR2/SOAPBuildersInterop_R2GrB.wsdl +19 -0
  152. data/test/interopR2/base.rb +288 -0
  153. data/test/interopR2/client.NetRemoting.rb +17 -0
  154. data/test/interopR2/client.NetRemoting.rb.result +3410 -0
  155. data/test/interopR2/client.NetRemoting_Base.log +6279 -0
  156. data/test/interopR2/client.NetRemoting_GroupB.log +1188 -0
  157. data/test/interopR2/client.rb +1228 -0
  158. data/test/interopR2/client4S4C.rb +15 -0
  159. data/test/interopR2/client4S4C2.rb +14 -0
  160. data/test/interopR2/client4S4C2_Base.log +4955 -0
  161. data/test/interopR2/client4S4C2_GroupB.log +1000 -0
  162. data/test/interopR2/client4S4C_Base.log +4635 -0
  163. data/test/interopR2/client4S4C_GroupB.log +900 -0
  164. data/test/interopR2/clientASP.NET.rb +17 -0
  165. data/test/interopR2/clientASP.NET_Base.log +5468 -0
  166. data/test/interopR2/clientASP.NET_GroupB.log +977 -0
  167. data/test/interopR2/clientApacheAxis.rb +16 -0
  168. data/test/interopR2/clientApacheAxis_Base.log +3171 -0
  169. data/test/interopR2/clientApacheAxis_GroupB.log +498 -0
  170. data/test/interopR2/clientApacheSOAP.rb +17 -0
  171. data/test/interopR2/clientApacheSOAP_Base.log +3171 -0
  172. data/test/interopR2/clientBEAWebLogic.rb +17 -0
  173. data/test/interopR2/clientBEAWebLogic_Base.log +3171 -0
  174. data/test/interopR2/clientBEAWebLogic_GroupB.log +498 -0
  175. data/test/interopR2/clientBase.rb +1970 -0
  176. data/test/interopR2/clientCapeConnect.rb +18 -0
  177. data/test/interopR2/clientCapeConnect_Base.log +2126 -0
  178. data/test/interopR2/clientDelphi.rb +19 -0
  179. data/test/interopR2/clientDelphi_Base.log +0 -0
  180. data/test/interopR2/clientEasySoap.rb +14 -0
  181. data/test/interopR2/clientEasySoap_Base.log +6187 -0
  182. data/test/interopR2/clientEasySoap_GroupB.log +1076 -0
  183. data/test/interopR2/clientFrontier.rb +25 -0
  184. data/test/interopR2/clientFrontier_Base.log +5188 -0
  185. data/test/interopR2/clientGLUE.rb +32 -0
  186. data/test/interopR2/clientHP.rb +13 -0
  187. data/test/interopR2/clientHP_Base.log +3171 -0
  188. data/test/interopR2/clientHP_GroupB.log +498 -0
  189. data/test/interopR2/clientJAX-RPC.rb +19 -0
  190. data/test/interopR2/clientJSOAP.rb +14 -0
  191. data/test/interopR2/clientJSOAP_Base.log +4465 -0
  192. data/test/interopR2/clientJSOAP_GroupB.log +824 -0
  193. data/test/interopR2/clientKafkaXSLT.rb +15 -0
  194. data/test/interopR2/clientKafkaXSLT_Base.log +10299 -0
  195. data/test/interopR2/clientKafkaXSLT_GroupB.log +1739 -0
  196. data/test/interopR2/clientMSSOAPToolkit2.0.rb +17 -0
  197. data/test/interopR2/clientMSSOAPToolkit2.0_Base.log +4805 -0
  198. data/test/interopR2/clientMSSOAPToolkit2.0_GroupB.log +871 -0
  199. data/test/interopR2/clientMSSOAPToolkit3.0.rb +17 -0
  200. data/test/interopR2/clientMSSOAPToolkit3.0_Base.log +5076 -0
  201. data/test/interopR2/clientMSSOAPToolkit3.0_GroupB.log +908 -0
  202. data/test/interopR2/clientNuSOAP.rb +19 -0
  203. data/test/interopR2/clientNuSOAP_Base.log +5076 -0
  204. data/test/interopR2/clientNuSOAP_GroupB.log +958 -0
  205. data/test/interopR2/clientNuWave.rb +15 -0
  206. data/test/interopR2/clientNuWave_Base.log +2019 -0
  207. data/test/interopR2/clientOpenLink.rb +15 -0
  208. data/test/interopR2/clientOpenLink_Base.log +6171 -0
  209. data/test/interopR2/clientOpenLink_GroupB.log +1094 -0
  210. data/test/interopR2/clientOracle.rb +15 -0
  211. data/test/interopR2/clientOracle_Base.log +5594 -0
  212. data/test/interopR2/clientPEAR.rb +18 -0
  213. data/test/interopR2/clientPEAR_Base.log +6261 -0
  214. data/test/interopR2/clientPEAR_GroupB.log +1106 -0
  215. data/test/interopR2/clientPhalanx.rb +18 -0
  216. data/test/interopR2/clientPhalanx_Base.log +41036 -0
  217. data/test/interopR2/clientPhalanx_GroupB.log +6519 -0
  218. data/test/interopR2/clientSIMACE.rb +18 -0
  219. data/test/interopR2/clientSIMACE_Base.log +6171 -0
  220. data/test/interopR2/clientSIMACE_GroupB.log +1093 -0
  221. data/test/interopR2/clientSOAP4R.rb +18 -0
  222. data/test/interopR2/clientSOAP4R.rb.result +3409 -0
  223. data/test/interopR2/clientSOAP4R_Base.log +6366 -0
  224. data/test/interopR2/clientSOAP4R_GroupB.log +1112 -0
  225. data/test/interopR2/clientSOAP__Lite.rb +14 -0
  226. data/test/interopR2/clientSQLData.rb +18 -0
  227. data/test/interopR2/clientSQLData_Base.log +4857 -0
  228. data/test/interopR2/clientSQLData_GroupB.log +770 -0
  229. data/test/interopR2/clientSilverStream.rb +17 -0
  230. data/test/interopR2/clientSilverStream_Base.log +3171 -0
  231. data/test/interopR2/clientSpray2001.rb +17 -0
  232. data/test/interopR2/clientSpray2001_Base.log +8187 -0
  233. data/test/interopR2/clientSpray2001_GroupB.log +1408 -0
  234. data/test/interopR2/clientSun.rb +19 -0
  235. data/test/interopR2/clientSun_Base.log +4641 -0
  236. data/test/interopR2/clientSun_GroupB.log +856 -0
  237. data/test/interopR2/clientVWOpentalkSoap.rb +19 -0
  238. data/test/interopR2/clientVWOpentalkSoap_Base.log +5402 -0
  239. data/test/interopR2/clientVWOpentalkSoap_GroupB.log +972 -0
  240. data/test/interopR2/clientWASP.rb +19 -0
  241. data/test/interopR2/clientWASPC.rb +18 -0
  242. data/test/interopR2/clientWASPC_Base.log +4187 -0
  243. data/test/interopR2/clientWASPC_GroupB.log +763 -0
  244. data/test/interopR2/clientWASP_Base.log +5414 -0
  245. data/test/interopR2/clientWASP_GroupB.log +970 -0
  246. data/test/interopR2/clientWebMethods.rb +15 -0
  247. data/test/interopR2/clientWebMethods_Base.log +3075 -0
  248. data/test/interopR2/clientWebMethods_GroupB.log +483 -0
  249. data/test/interopR2/clientWhiteMesa.rb +28 -0
  250. data/test/interopR2/clientWhiteMesa_Base.log +4359 -0
  251. data/test/interopR2/clientWhiteMesa_GroupB.log +808 -0
  252. data/test/interopR2/clientWingfoot.rb +15 -0
  253. data/test/interopR2/clientWingfoot_Base.log +4445 -0
  254. data/test/interopR2/clientWingfoot_GroupB.log +848 -0
  255. data/test/interopR2/clientXMLBus.rb +19 -0
  256. data/test/interopR2/clientXMLBus_Base.log +3075 -0
  257. data/test/interopR2/clientXMLBus_GroupB.log +483 -0
  258. data/test/interopR2/clientXMLRPC-EPI.rb +17 -0
  259. data/test/interopR2/clientXSOAP.rb +14 -0
  260. data/test/interopR2/clientXSOAP_Base.log +4445 -0
  261. data/test/interopR2/clientZSI.rb +19 -0
  262. data/test/interopR2/clienteSOAP.rb +18 -0
  263. data/test/interopR2/clienteSOAP_Base.log +8728 -0
  264. data/test/interopR2/clientgSOAP.rb +18 -0
  265. data/test/interopR2/clientgSOAP_Base.log +4689 -0
  266. data/test/interopR2/clientgSOAP_GroupB.log +1014 -0
  267. data/test/interopR2/clientkSOAP.rb +17 -0
  268. data/test/interopR2/clientkSOAP_Base.log +5625 -0
  269. data/test/interopR2/iSimonReg.rb +112 -0
  270. data/test/interopR2/interopResultBase.rb +114 -0
  271. data/test/interopR2/interopService.rb +247 -0
  272. data/test/interopR2/result_client.NetRemoting.txt +4593 -0
  273. data/test/interopR2/rwikiInteropService.rb +105 -0
  274. data/test/interopR2/server.cgi +270 -0
  275. data/test/interopR2/server.rb +274 -0
  276. data/test/interopR2/simonReg.rb +123 -0
  277. data/test/interopR2/test.sh +49 -0
  278. data/test/interopR4/client.rb +112 -0
  279. data/test/runner.rb +9 -0
  280. data/test/sm11/classDef.rb +156 -0
  281. data/test/sm11/client.rb +542 -0
  282. data/test/sm11/driver.rb +183 -0
  283. data/test/sm11/servant.rb +1067 -0
  284. data/test/sm11/server.rb +25 -0
  285. data/test/soap/asp.net/hello.wsdl +96 -0
  286. data/test/soap/asp.net/test_aspdotnet.rb +112 -0
  287. data/test/soap/calc/calc.rb +17 -0
  288. data/test/soap/calc/calc2.rb +29 -0
  289. data/test/soap/calc/server.cgi +13 -0
  290. data/test/soap/calc/server.rb +17 -0
  291. data/test/soap/calc/server2.rb +20 -0
  292. data/test/soap/calc/test_calc.rb +49 -0
  293. data/test/soap/calc/test_calc2.rb +53 -0
  294. data/test/soap/calc/test_calc_cgi.rb +69 -0
  295. data/test/soap/fault/test_customfault.rb +58 -0
  296. data/test/soap/header/server.cgi +119 -0
  297. data/test/soap/header/test_authheader.rb +240 -0
  298. data/test/soap/header/test_authheader_cgi.rb +121 -0
  299. data/test/soap/header/test_simplehandler.rb +116 -0
  300. data/test/soap/helloworld/hw_s.rb +16 -0
  301. data/test/soap/helloworld/test_helloworld.rb +41 -0
  302. data/test/soap/literalArrayMapping/amazonEc.rb +4778 -0
  303. data/test/soap/literalArrayMapping/amazonEcDriver.rb +172 -0
  304. data/test/soap/literalArrayMapping/amazonresponse.xml +100 -0
  305. data/test/soap/literalArrayMapping/test_definedarray.rb +36 -0
  306. data/test/soap/marshal/marshaltestlib.rb +494 -0
  307. data/test/soap/marshal/test_digraph.rb +56 -0
  308. data/test/soap/marshal/test_marshal.rb +26 -0
  309. data/test/soap/marshal/test_struct.rb +47 -0
  310. data/test/soap/ssl/README +1 -0
  311. data/test/soap/ssl/ca.cert +23 -0
  312. data/test/soap/ssl/client.cert +19 -0
  313. data/test/soap/ssl/client.key +15 -0
  314. data/test/soap/ssl/server.cert +19 -0
  315. data/test/soap/ssl/server.key +15 -0
  316. data/test/soap/ssl/sslsvr.rb +57 -0
  317. data/test/soap/ssl/subca.cert +21 -0
  318. data/test/soap/ssl/test_ssl.rb +245 -0
  319. data/test/soap/struct/test_struct.rb +77 -0
  320. data/test/soap/styleuse/client.rb +20 -0
  321. data/test/soap/styleuse/server.rb +86 -0
  322. data/test/soap/swa/test_file.rb +73 -0
  323. data/test/soap/test_basetype.rb +976 -0
  324. data/test/soap/test_custommap.rb +108 -0
  325. data/test/soap/test_empty.rb +79 -0
  326. data/test/soap/test_envelopenamespace.rb +92 -0
  327. data/test/soap/test_httpconfigloader.rb +39 -0
  328. data/test/soap/test_mapping.rb +59 -0
  329. data/test/soap/test_no_indent.rb +86 -0
  330. data/test/soap/test_property.rb +424 -0
  331. data/test/soap/test_response_as_xml.rb +95 -0
  332. data/test/soap/test_soapelement.rb +120 -0
  333. data/test/soap/test_streamhandler.rb +262 -0
  334. data/test/soap/test_styleuse.rb +333 -0
  335. data/test/soap/wsdlDriver/README.txt +2 -0
  336. data/test/soap/wsdlDriver/calc.wsdl +126 -0
  337. data/test/soap/wsdlDriver/document.wsdl +54 -0
  338. data/test/soap/wsdlDriver/echo_version.rb +29 -0
  339. data/test/soap/wsdlDriver/simpletype.wsdl +63 -0
  340. data/test/soap/wsdlDriver/test_calc.rb +100 -0
  341. data/test/soap/wsdlDriver/test_document.rb +78 -0
  342. data/test/soap/wsdlDriver/test_simpletype.rb +87 -0
  343. data/test/wsdl/abstract/abstract.wsdl +97 -0
  344. data/test/wsdl/abstract/test_abstract.rb +130 -0
  345. data/test/wsdl/any/any.wsdl +51 -0
  346. data/test/wsdl/any/expectedDriver.rb +46 -0
  347. data/test/wsdl/any/expectedEcho.rb +18 -0
  348. data/test/wsdl/any/expectedService.rb +42 -0
  349. data/test/wsdl/any/test_any.rb +193 -0
  350. data/test/wsdl/axisArray/axisArray.wsdl +60 -0
  351. data/test/wsdl/axisArray/itemList.rb +14 -0
  352. data/test/wsdl/axisArray/test_axisarray.rb +69 -0
  353. data/test/wsdl/choice/choice.wsdl +91 -0
  354. data/test/wsdl/choice/test_choice.rb +134 -0
  355. data/test/wsdl/complexcontent/complexContent.wsdl +83 -0
  356. data/test/wsdl/complexcontent/test_echo.rb +101 -0
  357. data/test/wsdl/datetime/DatetimeService.rb +44 -0
  358. data/test/wsdl/datetime/datetime.rb +0 -0
  359. data/test/wsdl/datetime/datetime.wsdl +45 -0
  360. data/test/wsdl/datetime/datetimeServant.rb +21 -0
  361. data/test/wsdl/datetime/test_datetime.rb +82 -0
  362. data/test/wsdl/document/array/double.wsdl +72 -0
  363. data/test/wsdl/document/array/test_array.rb +117 -0
  364. data/test/wsdl/document/document.wsdl +74 -0
  365. data/test/wsdl/document/number.wsdl +54 -0
  366. data/test/wsdl/document/ping_nosoapaction.wsdl +66 -0
  367. data/test/wsdl/document/test_nosoapaction.rb +109 -0
  368. data/test/wsdl/document/test_number.rb +99 -0
  369. data/test/wsdl/document/test_rpc.rb +211 -0
  370. data/test/wsdl/emptycomplextype.wsdl +31 -0
  371. data/test/wsdl/list/list.wsdl +93 -0
  372. data/test/wsdl/list/test_list.rb +134 -0
  373. data/test/wsdl/map/map.wsdl +92 -0
  374. data/test/wsdl/map/map.xml +43 -0
  375. data/test/wsdl/map/test_map.rb +99 -0
  376. data/test/wsdl/marshal/person.wsdl +21 -0
  377. data/test/wsdl/marshal/person_org.rb +18 -0
  378. data/test/wsdl/marshal/test_wsdlmarshal.rb +79 -0
  379. data/test/wsdl/multiplefault.wsdl +68 -0
  380. data/test/wsdl/overload/overload.wsdl +80 -0
  381. data/test/wsdl/overload/test_overload.rb +118 -0
  382. data/test/wsdl/qualified/lp.wsdl +47 -0
  383. data/test/wsdl/qualified/lp.xsd +26 -0
  384. data/test/wsdl/qualified/np.wsdl +51 -0
  385. data/test/wsdl/qualified/test_qualified.rb +145 -0
  386. data/test/wsdl/qualified/test_unqualified.rb +159 -0
  387. data/test/wsdl/raa/RAA.rb +120 -0
  388. data/test/wsdl/raa/RAAServant.rb +107 -0
  389. data/test/wsdl/raa/RAAService.rb +120 -0
  390. data/test/wsdl/raa/README.txt +8 -0
  391. data/test/wsdl/raa/raa.wsdl +264 -0
  392. data/test/wsdl/raa/server.rb +103 -0
  393. data/test/wsdl/raa/test_raa.rb +91 -0
  394. data/test/wsdl/ref/expectedProduct.rb +158 -0
  395. data/test/wsdl/ref/product.wsdl +147 -0
  396. data/test/wsdl/ref/test_ref.rb +289 -0
  397. data/test/wsdl/rpc/rpc.wsdl +83 -0
  398. data/test/wsdl/rpc/test-rpc-lit.wsdl +364 -0
  399. data/test/wsdl/rpc/test_rpc.rb +173 -0
  400. data/test/wsdl/rpc/test_rpc_lit.rb +407 -0
  401. data/test/wsdl/simplecontent/simplecontent.wsdl +83 -0
  402. data/test/wsdl/simplecontent/test_simplecontent.rb +116 -0
  403. data/test/wsdl/simpletype/rpc/expectedClient.rb +34 -0
  404. data/test/wsdl/simpletype/rpc/expectedDriver.rb +55 -0
  405. data/test/wsdl/simpletype/rpc/expectedEchoVersion.rb +19 -0
  406. data/test/wsdl/simpletype/rpc/expectedServant.rb +32 -0
  407. data/test/wsdl/simpletype/rpc/expectedService.rb +51 -0
  408. data/test/wsdl/simpletype/rpc/rpc.wsdl +80 -0
  409. data/test/wsdl/simpletype/rpc/test_rpc.rb +62 -0
  410. data/test/wsdl/simpletype/simpletype.wsdl +95 -0
  411. data/test/wsdl/simpletype/test_simpletype.rb +99 -0
  412. data/test/wsdl/soap/soapbodyparts.wsdl +103 -0
  413. data/test/wsdl/soap/test_soapbodyparts.rb +79 -0
  414. data/test/wsdl/soap/wsdl2ruby/expectedClassdef.rb +19 -0
  415. data/test/wsdl/soap/wsdl2ruby/expectedClient.rb +34 -0
  416. data/test/wsdl/soap/wsdl2ruby/expectedDriver.rb +55 -0
  417. data/test/wsdl/soap/wsdl2ruby/expectedServant.rb +32 -0
  418. data/test/wsdl/soap/wsdl2ruby/expectedService.cgi +44 -0
  419. data/test/wsdl/soap/wsdl2ruby/expectedService.rb +51 -0
  420. data/test/wsdl/soap/wsdl2ruby/rpc.wsdl +80 -0
  421. data/test/wsdl/soap/wsdl2ruby/section/expectedClassdef.rb +31 -0
  422. data/test/wsdl/soap/wsdl2ruby/section/section.xsd +31 -0
  423. data/test/wsdl/soap/wsdl2ruby/section/test_section.rb +54 -0
  424. data/test/wsdl/soap/wsdl2ruby/soapenc/soapenc.wsdl +64 -0
  425. data/test/wsdl/soap/wsdl2ruby/soapenc/test_soapenc.rb +96 -0
  426. data/test/wsdl/soap/wsdl2ruby/test_wsdl2ruby.rb +79 -0
  427. data/test/wsdl/soaptype/soaptype.wsdl +61 -0
  428. data/test/wsdl/soaptype/test_soaptype.rb +160 -0
  429. data/test/wsdl/test_emptycomplextype.rb +21 -0
  430. data/test/wsdl/test_fault.rb +50 -0
  431. data/test/wsdl/test_multiplefault.rb +39 -0
  432. data/test/xsd/codegen/test_classdef.rb +214 -0
  433. data/test/xsd/noencoding.xml +4 -0
  434. data/test/xsd/test_noencoding.rb +32 -0
  435. data/test/xsd/test_ns.rb +20 -0
  436. data/test/xsd/test_xmlschemaparser.rb +22 -0
  437. data/test/xsd/test_xsd.rb +1523 -0
  438. data/test/xsd/xmllang.xml +43 -0
  439. data/test/xsd/xmlschema.xml +12 -0
  440. metadata +539 -0
@@ -0,0 +1,1282 @@
1
+ # XSD4R - XML Schema Datatype implementation.
2
+ # Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
3
+
4
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
5
+ # redistribute it and/or modify it under the same terms of Ruby's license;
6
+ # either the dual license version in 2003, or any later version.
7
+
8
+
9
+ require 'xsd/qname'
10
+ require 'xsd/charset'
11
+ require 'uri'
12
+
13
+
14
+ ###
15
+ ## XMLSchamaDatatypes general definitions.
16
+ #
17
+ module XSD
18
+
19
+
20
+ Namespace = 'http://www.w3.org/2001/XMLSchema'
21
+ InstanceNamespace = 'http://www.w3.org/2001/XMLSchema-instance'
22
+
23
+ AttrType = 'type'
24
+ NilValue = 'true'
25
+
26
+ AnyTypeLiteral = 'anyType'
27
+ AnySimpleTypeLiteral = 'anySimpleType'
28
+ NilLiteral = 'nil'
29
+ StringLiteral = 'string'
30
+ BooleanLiteral = 'boolean'
31
+ DecimalLiteral = 'decimal'
32
+ FloatLiteral = 'float'
33
+ DoubleLiteral = 'double'
34
+ DurationLiteral = 'duration'
35
+ DateTimeLiteral = 'dateTime'
36
+ TimeLiteral = 'time'
37
+ DateLiteral = 'date'
38
+ GYearMonthLiteral = 'gYearMonth'
39
+ GYearLiteral = 'gYear'
40
+ GMonthDayLiteral = 'gMonthDay'
41
+ GDayLiteral = 'gDay'
42
+ GMonthLiteral = 'gMonth'
43
+ HexBinaryLiteral = 'hexBinary'
44
+ Base64BinaryLiteral = 'base64Binary'
45
+ AnyURILiteral = 'anyURI'
46
+ QNameLiteral = 'QName'
47
+
48
+ NormalizedStringLiteral = 'normalizedString'
49
+ #3.3.2 token
50
+ #3.3.3 language
51
+ #3.3.4 NMTOKEN
52
+ #3.3.5 NMTOKENS
53
+ #3.3.6 Name
54
+ #3.3.7 NCName
55
+ #3.3.8 ID
56
+ #3.3.9 IDREF
57
+ #3.3.10 IDREFS
58
+ #3.3.11 ENTITY
59
+ #3.3.12 ENTITIES
60
+ IntegerLiteral = 'integer'
61
+ NonPositiveIntegerLiteral = 'nonPositiveInteger'
62
+ NegativeIntegerLiteral = 'negativeInteger'
63
+ LongLiteral = 'long'
64
+ IntLiteral = 'int'
65
+ ShortLiteral = 'short'
66
+ ByteLiteral = 'byte'
67
+ NonNegativeIntegerLiteral = 'nonNegativeInteger'
68
+ UnsignedLongLiteral = 'unsignedLong'
69
+ UnsignedIntLiteral = 'unsignedInt'
70
+ UnsignedShortLiteral = 'unsignedShort'
71
+ UnsignedByteLiteral = 'unsignedByte'
72
+ PositiveIntegerLiteral = 'positiveInteger'
73
+
74
+ AttrTypeName = QName.new(InstanceNamespace, AttrType)
75
+ AttrNilName = QName.new(InstanceNamespace, NilLiteral)
76
+
77
+ AnyTypeName = QName.new(Namespace, AnyTypeLiteral)
78
+ AnySimpleTypeName = QName.new(Namespace, AnySimpleTypeLiteral)
79
+
80
+ class Error < StandardError; end
81
+ class ValueSpaceError < Error; end
82
+
83
+
84
+ ###
85
+ ## The base class of all datatypes with Namespace.
86
+ #
87
+ class NSDBase
88
+ @@types = []
89
+
90
+ attr_accessor :type
91
+
92
+ def self.inherited(klass)
93
+ @@types << klass
94
+ end
95
+
96
+ def self.types
97
+ @@types
98
+ end
99
+
100
+ def initialize
101
+ end
102
+
103
+ def init(type)
104
+ @type = type
105
+ end
106
+ end
107
+
108
+
109
+ ###
110
+ ## The base class of XSD datatypes.
111
+ #
112
+ class XSDAnySimpleType < NSDBase
113
+ include XSD
114
+ Type = QName.new(Namespace, AnySimpleTypeLiteral)
115
+
116
+ # @data represents canonical space (ex. Integer: 123).
117
+ attr_reader :data
118
+ # @is_nil represents this data is nil or not.
119
+ attr_accessor :is_nil
120
+
121
+ def initialize(value = nil)
122
+ init(Type, value)
123
+ end
124
+
125
+ # true or raise
126
+ def check_lexical_format(value)
127
+ screen_data(value)
128
+ true
129
+ end
130
+
131
+ # set accepts a string which follows lexical space (ex. String: "+123"), or
132
+ # an object which follows canonical space (ex. Integer: 123).
133
+ def set(value)
134
+ if value.nil?
135
+ @is_nil = true
136
+ @data = nil
137
+ _set(nil)
138
+ else
139
+ @is_nil = false
140
+ _set(screen_data(value))
141
+ end
142
+ end
143
+
144
+ # to_s creates a string which follows lexical space (ex. String: "123").
145
+ def to_s()
146
+ if @is_nil
147
+ ""
148
+ else
149
+ _to_s
150
+ end
151
+ end
152
+
153
+ private
154
+
155
+ def init(type, value)
156
+ super(type)
157
+ set(value)
158
+ end
159
+
160
+ # raises ValueSpaceError if check failed
161
+ def screen_data(value)
162
+ value
163
+ end
164
+
165
+ def _set(value)
166
+ @data = value
167
+ end
168
+
169
+ def _to_s
170
+ @data.to_s
171
+ end
172
+ end
173
+
174
+ class XSDNil < XSDAnySimpleType
175
+ Type = QName.new(Namespace, NilLiteral)
176
+ Value = 'true'
177
+
178
+ def initialize(value = nil)
179
+ init(Type, value)
180
+ end
181
+ end
182
+
183
+
184
+ ###
185
+ ## Primitive datatypes.
186
+ #
187
+ class XSDString < XSDAnySimpleType
188
+ Type = QName.new(Namespace, StringLiteral)
189
+
190
+ def initialize(value = nil)
191
+ init(Type, value)
192
+ end
193
+
194
+ @@strict_ces_validation = false
195
+
196
+ def self.strict_ces_validation=(strict_ces_validation)
197
+ @@strict_ces_validation = strict_ces_validation
198
+ end
199
+
200
+ def self.strict_ces_validation
201
+ @@strict_ces_validation
202
+ end
203
+
204
+ private
205
+
206
+ def screen_data(value)
207
+ if ::XSD::XSDString.strict_ces_validation
208
+ externalces = XSD::Charset.encoding
209
+ unless XSD::Charset.is_ces(value, externalces)
210
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
211
+ end
212
+ end
213
+ value
214
+ end
215
+ end
216
+
217
+ class XSDBoolean < XSDAnySimpleType
218
+ Type = QName.new(Namespace, BooleanLiteral)
219
+
220
+ def initialize(value = nil)
221
+ init(Type, value)
222
+ end
223
+
224
+ private
225
+
226
+ def screen_data(value)
227
+ if value.is_a?(String)
228
+ str = value.strip
229
+ if str == 'true' || str == '1'
230
+ true
231
+ elsif str == 'false' || str == '0'
232
+ false
233
+ else
234
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
235
+ end
236
+ else
237
+ value ? true : false
238
+ end
239
+ end
240
+ end
241
+
242
+ class XSDDecimal < XSDAnySimpleType
243
+ Type = QName.new(Namespace, DecimalLiteral)
244
+
245
+ def initialize(value = nil)
246
+ init(Type, value)
247
+ end
248
+
249
+ def nonzero?
250
+ (@number != '0')
251
+ end
252
+
253
+ private
254
+
255
+ def screen_data(d)
256
+ if d.is_a?(String)
257
+ # Integer("00012") => 10 in Ruby.
258
+ d.sub!(/^([+\-]?)0*(?=\d)/, "\\1")
259
+ end
260
+ screen_data_str(d)
261
+ end
262
+
263
+ def screen_data_str(str)
264
+ /^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
265
+ unless Regexp.last_match
266
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
267
+ end
268
+ sign = $1 || '+'
269
+ int_part = $2
270
+ frac_part = $3
271
+ int_part = '0' if int_part.empty?
272
+ frac_part = frac_part ? frac_part.sub(/0+$/, '') : ''
273
+ point = - frac_part.size
274
+ number = int_part + frac_part
275
+ # normalize
276
+ if sign == '+'
277
+ sign = ''
278
+ elsif sign == '-'
279
+ if number == '0'
280
+ sign = ''
281
+ end
282
+ end
283
+ [sign, point, number]
284
+ end
285
+
286
+ def _set(data)
287
+ if data.nil?
288
+ @sign = @point = @number = @data = nil
289
+ return
290
+ end
291
+ @sign, @point, @number = data
292
+ @data = _to_s
293
+ @data.freeze
294
+ end
295
+
296
+ # 0.0 -> 0; right?
297
+ def _to_s
298
+ str = @number.dup
299
+ if @point.nonzero?
300
+ str[@number.size + @point, 0] = '.'
301
+ end
302
+ @sign + str
303
+ end
304
+ end
305
+
306
+ module FloatConstants
307
+ NaN = 0.0/0.0
308
+ POSITIVE_INF = +1.0/0.0
309
+ NEGATIVE_INF = -1.0/0.0
310
+ POSITIVE_ZERO = +1.0/POSITIVE_INF
311
+ NEGATIVE_ZERO = -1.0/POSITIVE_INF
312
+ MIN_POSITIVE_SINGLE = 2.0 ** -149
313
+ end
314
+
315
+ class XSDFloat < XSDAnySimpleType
316
+ include FloatConstants
317
+ Type = QName.new(Namespace, FloatLiteral)
318
+
319
+ def initialize(value = nil)
320
+ init(Type, value)
321
+ end
322
+
323
+ private
324
+
325
+ def screen_data(value)
326
+ # "NaN".to_f => 0 in some environment. libc?
327
+ if value.is_a?(Float)
328
+ return narrow32bit(value)
329
+ end
330
+ str = value.to_s.strip
331
+ if str == 'NaN'
332
+ NaN
333
+ elsif str == 'INF'
334
+ POSITIVE_INF
335
+ elsif str == '-INF'
336
+ NEGATIVE_INF
337
+ else
338
+ if /^[+\-\.\deE]+$/ !~ str
339
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
340
+ end
341
+ # Float("-1.4E") might fail on some system.
342
+ str << '0' if /e$/i =~ str
343
+ begin
344
+ return narrow32bit(Float(str))
345
+ rescue ArgumentError
346
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
347
+ end
348
+ end
349
+ end
350
+
351
+ def _to_s
352
+ if @data.nan?
353
+ 'NaN'
354
+ elsif @data.infinite? == 1
355
+ 'INF'
356
+ elsif @data.infinite? == -1
357
+ '-INF'
358
+ else
359
+ sign = XSDFloat.positive?(@data) ? '+' : '-'
360
+ sign + sprintf("%.10g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
361
+ end
362
+ end
363
+
364
+ # Convert to single-precision 32-bit floating point value.
365
+ def narrow32bit(f)
366
+ if f.nan? || f.infinite?
367
+ f
368
+ elsif f.abs < MIN_POSITIVE_SINGLE
369
+ XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO
370
+ else
371
+ f
372
+ end
373
+ end
374
+
375
+ def self.positive?(value)
376
+ (1 / value) > 0.0
377
+ end
378
+ end
379
+
380
+ # Ruby's Float is double-precision 64-bit floating point value.
381
+ class XSDDouble < XSDAnySimpleType
382
+ include FloatConstants
383
+ Type = QName.new(Namespace, DoubleLiteral)
384
+
385
+ def initialize(value = nil)
386
+ init(Type, value)
387
+ end
388
+
389
+ private
390
+
391
+ def screen_data(value)
392
+ # "NaN".to_f => 0 in some environment. libc?
393
+ if value.is_a?(Float)
394
+ return value
395
+ end
396
+ str = value.to_s.strip
397
+ if str == 'NaN'
398
+ NaN
399
+ elsif str == 'INF'
400
+ POSITIVE_INF
401
+ elsif str == '-INF'
402
+ NEGATIVE_INF
403
+ else
404
+ begin
405
+ return Float(str)
406
+ rescue ArgumentError
407
+ # '1.4e' cannot be parsed on some architecture.
408
+ if /e\z/i =~ str
409
+ begin
410
+ return Float(str + '0')
411
+ rescue ArgumentError
412
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
413
+ end
414
+ else
415
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
416
+ end
417
+ end
418
+ end
419
+ end
420
+
421
+ def _to_s
422
+ if @data.nan?
423
+ 'NaN'
424
+ elsif @data.infinite? == 1
425
+ 'INF'
426
+ elsif @data.infinite? == -1
427
+ '-INF'
428
+ else
429
+ sign = (1 / @data > 0.0) ? '+' : '-'
430
+ sign + sprintf("%.16g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
431
+ end
432
+ end
433
+ end
434
+
435
+ class XSDDuration < XSDAnySimpleType
436
+ Type = QName.new(Namespace, DurationLiteral)
437
+
438
+ attr_accessor :sign
439
+ attr_accessor :year
440
+ attr_accessor :month
441
+ attr_accessor :day
442
+ attr_accessor :hour
443
+ attr_accessor :min
444
+ attr_accessor :sec
445
+
446
+ def initialize(value = nil)
447
+ init(Type, value)
448
+ end
449
+
450
+ private
451
+
452
+ def screen_data(value)
453
+ /^([+\-]?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/ =~ value.to_s.strip
454
+ unless Regexp.last_match
455
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
456
+ end
457
+ if ($5 and ((!$2 and !$3 and !$4) or (!$6 and !$7 and !$8)))
458
+ # Should we allow 'PT5S' here?
459
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
460
+ end
461
+ sign = $1
462
+ year = $2.to_i
463
+ month = $3.to_i
464
+ day = $4.to_i
465
+ hour = $6.to_i
466
+ min = $7.to_i
467
+ sec = $8 ? XSDDecimal.new($8) : 0
468
+ [sign, year, month, day, hour, min, sec]
469
+ end
470
+
471
+ def _set(data)
472
+ if data.nil?
473
+ @sign = @year = @month = @day = @hour = @min = @sec = @data = nil
474
+ return
475
+ end
476
+ @sign, @year, @month, @day, @hour, @min, @sec = data
477
+ @data = _to_s
478
+ @data.freeze
479
+ end
480
+
481
+ def _to_s
482
+ str = ''
483
+ str << @sign if @sign
484
+ str << 'P'
485
+ l = ''
486
+ l << "#{ @year }Y" if @year.nonzero?
487
+ l << "#{ @month }M" if @month.nonzero?
488
+ l << "#{ @day }D" if @day.nonzero?
489
+ r = ''
490
+ r << "#{ @hour }H" if @hour.nonzero?
491
+ r << "#{ @min }M" if @min.nonzero?
492
+ r << "#{ @sec }S" if @sec.nonzero?
493
+ str << l
494
+ if l.empty?
495
+ str << "0D"
496
+ end
497
+ unless r.empty?
498
+ str << "T" << r
499
+ end
500
+ str
501
+ end
502
+ end
503
+
504
+
505
+ require 'rational'
506
+ require 'date'
507
+
508
+ module XSDDateTimeImpl
509
+ SecInDay = 86400 # 24 * 60 * 60
510
+
511
+ def to_obj(klass)
512
+ if klass == Time
513
+ to_time
514
+ elsif klass == Date
515
+ to_date
516
+ elsif klass == DateTime
517
+ to_datetime
518
+ else
519
+ nil
520
+ end
521
+ end
522
+
523
+ def to_time
524
+ begin
525
+ if @data.offset * SecInDay == Time.now.utc_offset
526
+ d = @data
527
+ usec = (d.sec_fraction * SecInDay * 1000000).round
528
+ Time.local(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
529
+ else
530
+ d = @data.newof
531
+ usec = (d.sec_fraction * SecInDay * 1000000).round
532
+ Time.gm(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
533
+ end
534
+ rescue ArgumentError
535
+ nil
536
+ end
537
+ end
538
+
539
+ def to_date
540
+ Date.new0(@data.class.jd_to_ajd(@data.jd, 0, 0), 0, @data.start)
541
+ end
542
+
543
+ def to_datetime
544
+ data
545
+ end
546
+
547
+ def tz2of(str)
548
+ /^(?:Z|(?:([+\-])(\d\d):(\d\d))?)$/ =~ str
549
+ sign = $1
550
+ hour = $2.to_i
551
+ min = $3.to_i
552
+
553
+ of = case sign
554
+ when '+'
555
+ of = +(hour.to_r * 60 + min) / 1440 # 24 * 60
556
+ when '-'
557
+ of = -(hour.to_r * 60 + min) / 1440 # 24 * 60
558
+ else
559
+ 0
560
+ end
561
+ of
562
+ end
563
+
564
+ def of2tz(offset)
565
+ diffmin = offset * 24 * 60
566
+ if diffmin.zero?
567
+ 'Z'
568
+ else
569
+ ((diffmin < 0) ? '-' : '+') << format('%02d:%02d',
570
+ (diffmin.abs / 60.0).to_i, (diffmin.abs % 60.0).to_i)
571
+ end
572
+ end
573
+
574
+ def screen_data(t)
575
+ # convert t to a DateTime as an internal representation.
576
+ if t.respond_to?(:to_datetime) # 1.9 or later
577
+ t.to_datetime
578
+ elsif t.is_a?(DateTime)
579
+ t
580
+ elsif t.is_a?(Date)
581
+ t = screen_data_str(t)
582
+ t <<= 12 if t.year < 0
583
+ t
584
+ elsif t.is_a?(Time)
585
+ jd = DateTime.civil_to_jd(t.year, t.mon, t.mday, DateTime::ITALY)
586
+ fr = DateTime.time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) +
587
+ t.usec.to_r / 1000000 / SecInDay
588
+ of = t.utc_offset.to_r / SecInDay
589
+ DateTime.new0(DateTime.jd_to_ajd(jd, fr, of), of, DateTime::ITALY)
590
+ else
591
+ screen_data_str(t)
592
+ end
593
+ end
594
+
595
+ def add_tz(s)
596
+ s + of2tz(@data.offset)
597
+ end
598
+ end
599
+
600
+ class XSDDateTime < XSDAnySimpleType
601
+ include XSDDateTimeImpl
602
+ Type = QName.new(Namespace, DateTimeLiteral)
603
+
604
+ def initialize(value = nil)
605
+ init(Type, value)
606
+ end
607
+
608
+ private
609
+
610
+ def screen_data_str(t)
611
+ /^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
612
+ unless Regexp.last_match
613
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
614
+ end
615
+ if $1 == '0000'
616
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
617
+ end
618
+ year = $1.to_i
619
+ if year < 0
620
+ year += 1
621
+ end
622
+ mon = $2.to_i
623
+ mday = $3.to_i
624
+ hour = $4.to_i
625
+ min = $5.to_i
626
+ sec = $6.to_i
627
+ secfrac = $7
628
+ zonestr = $8
629
+ data = DateTime.civil(year, mon, mday, hour, min, sec, tz2of(zonestr))
630
+ if secfrac
631
+ diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
632
+ data += diffday
633
+ # FYI: new0 and jd_to_rjd are not necessary to use if you don't have
634
+ # exceptional reason.
635
+ end
636
+ [data, secfrac]
637
+ end
638
+
639
+ def _set(data)
640
+ if data.nil?
641
+ @data = @secfrac = nil
642
+ return
643
+ end
644
+ @data, @secfrac = data
645
+ end
646
+
647
+ def _to_s
648
+ year = (@data.year > 0) ? @data.year : @data.year - 1
649
+ s = format('%.4d-%02d-%02dT%02d:%02d:%02d',
650
+ year, @data.mon, @data.mday, @data.hour, @data.min, @data.sec)
651
+ if @data.sec_fraction.nonzero?
652
+ if @secfrac
653
+ s << ".#{ @secfrac }"
654
+ else
655
+ s << sprintf("%.16f",
656
+ (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
657
+ end
658
+ end
659
+ add_tz(s)
660
+ end
661
+ end
662
+
663
+ class XSDTime < XSDAnySimpleType
664
+ include XSDDateTimeImpl
665
+ Type = QName.new(Namespace, TimeLiteral)
666
+
667
+ def initialize(value = nil)
668
+ init(Type, value)
669
+ end
670
+
671
+ private
672
+
673
+ def screen_data_str(t)
674
+ /^(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
675
+ unless Regexp.last_match
676
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
677
+ end
678
+ hour = $1.to_i
679
+ min = $2.to_i
680
+ sec = $3.to_i
681
+ secfrac = $4
682
+ zonestr = $5
683
+ data = DateTime.civil(1, 1, 1, hour, min, sec, tz2of(zonestr))
684
+ if secfrac
685
+ diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
686
+ data += diffday
687
+ end
688
+ [data, secfrac]
689
+ end
690
+
691
+ def _set(data)
692
+ if data.nil?
693
+ @data = @secfrac = nil
694
+ return
695
+ end
696
+ @data, @secfrac = data
697
+ end
698
+
699
+ def _to_s
700
+ s = format('%02d:%02d:%02d', @data.hour, @data.min, @data.sec)
701
+ if @data.sec_fraction.nonzero?
702
+ if @secfrac
703
+ s << ".#{ @secfrac }"
704
+ else
705
+ s << sprintf("%.16f",
706
+ (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
707
+ end
708
+ end
709
+ add_tz(s)
710
+ end
711
+ end
712
+
713
+ class XSDDate < XSDAnySimpleType
714
+ include XSDDateTimeImpl
715
+ Type = QName.new(Namespace, DateLiteral)
716
+
717
+ def initialize(value = nil)
718
+ init(Type, value)
719
+ end
720
+
721
+ private
722
+
723
+ def screen_data_str(t)
724
+ /^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
725
+ unless Regexp.last_match
726
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
727
+ end
728
+ year = $1.to_i
729
+ if year < 0
730
+ year += 1
731
+ end
732
+ mon = $2.to_i
733
+ mday = $3.to_i
734
+ zonestr = $4
735
+ DateTime.civil(year, mon, mday, 0, 0, 0, tz2of(zonestr))
736
+ end
737
+
738
+ def _to_s
739
+ year = (@data.year > 0) ? @data.year : @data.year - 1
740
+ s = format('%.4d-%02d-%02d', year, @data.mon, @data.mday)
741
+ add_tz(s)
742
+ end
743
+ end
744
+
745
+ class XSDGYearMonth < XSDAnySimpleType
746
+ include XSDDateTimeImpl
747
+ Type = QName.new(Namespace, GYearMonthLiteral)
748
+
749
+ def initialize(value = nil)
750
+ init(Type, value)
751
+ end
752
+
753
+ private
754
+
755
+ def screen_data_str(t)
756
+ /^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
757
+ unless Regexp.last_match
758
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
759
+ end
760
+ year = $1.to_i
761
+ if year < 0
762
+ year += 1
763
+ end
764
+ mon = $2.to_i
765
+ zonestr = $3
766
+ DateTime.civil(year, mon, 1, 0, 0, 0, tz2of(zonestr))
767
+ end
768
+
769
+ def _to_s
770
+ year = (@data.year > 0) ? @data.year : @data.year - 1
771
+ s = format('%.4d-%02d', year, @data.mon)
772
+ add_tz(s)
773
+ end
774
+ end
775
+
776
+ class XSDGYear < XSDAnySimpleType
777
+ include XSDDateTimeImpl
778
+ Type = QName.new(Namespace, GYearLiteral)
779
+
780
+ def initialize(value = nil)
781
+ init(Type, value)
782
+ end
783
+
784
+ private
785
+
786
+ def screen_data_str(t)
787
+ /^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
788
+ unless Regexp.last_match
789
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
790
+ end
791
+ year = $1.to_i
792
+ if year < 0
793
+ year += 1
794
+ end
795
+ zonestr = $2
796
+ DateTime.civil(year, 1, 1, 0, 0, 0, tz2of(zonestr))
797
+ end
798
+
799
+ def _to_s
800
+ year = (@data.year > 0) ? @data.year : @data.year - 1
801
+ s = format('%.4d', year)
802
+ add_tz(s)
803
+ end
804
+ end
805
+
806
+ class XSDGMonthDay < XSDAnySimpleType
807
+ include XSDDateTimeImpl
808
+ Type = QName.new(Namespace, GMonthDayLiteral)
809
+
810
+ def initialize(value = nil)
811
+ init(Type, value)
812
+ end
813
+
814
+ private
815
+
816
+ def screen_data_str(t)
817
+ /^(\d\d)-(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
818
+ unless Regexp.last_match
819
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
820
+ end
821
+ mon = $1.to_i
822
+ mday = $2.to_i
823
+ zonestr = $3
824
+ DateTime.civil(1, mon, mday, 0, 0, 0, tz2of(zonestr))
825
+ end
826
+
827
+ def _to_s
828
+ s = format('%02d-%02d', @data.mon, @data.mday)
829
+ add_tz(s)
830
+ end
831
+ end
832
+
833
+ class XSDGDay < XSDAnySimpleType
834
+ include XSDDateTimeImpl
835
+ Type = QName.new(Namespace, GDayLiteral)
836
+
837
+ def initialize(value = nil)
838
+ init(Type, value)
839
+ end
840
+
841
+ private
842
+
843
+ def screen_data_str(t)
844
+ /^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
845
+ unless Regexp.last_match
846
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
847
+ end
848
+ mday = $1.to_i
849
+ zonestr = $2
850
+ DateTime.civil(1, 1, mday, 0, 0, 0, tz2of(zonestr))
851
+ end
852
+
853
+ def _to_s
854
+ s = format('%02d', @data.mday)
855
+ add_tz(s)
856
+ end
857
+ end
858
+
859
+ class XSDGMonth < XSDAnySimpleType
860
+ include XSDDateTimeImpl
861
+ Type = QName.new(Namespace, GMonthLiteral)
862
+
863
+ def initialize(value = nil)
864
+ init(Type, value)
865
+ end
866
+
867
+ private
868
+
869
+ def screen_data_str(t)
870
+ /^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
871
+ unless Regexp.last_match
872
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
873
+ end
874
+ mon = $1.to_i
875
+ zonestr = $2
876
+ DateTime.civil(1, mon, 1, 0, 0, 0, tz2of(zonestr))
877
+ end
878
+
879
+ def _to_s
880
+ s = format('%02d', @data.mon)
881
+ add_tz(s)
882
+ end
883
+ end
884
+
885
+ class XSDHexBinary < XSDAnySimpleType
886
+ Type = QName.new(Namespace, HexBinaryLiteral)
887
+
888
+ # String in Ruby could be a binary.
889
+ def initialize(value = nil)
890
+ init(Type, value)
891
+ end
892
+
893
+ def set_encoded(value)
894
+ if /^[0-9a-fA-F]*$/ !~ value
895
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
896
+ end
897
+ @data = String.new(value).strip
898
+ @is_nil = false
899
+ end
900
+
901
+ def string
902
+ [@data].pack("H*")
903
+ end
904
+
905
+ private
906
+
907
+ def screen_data(value)
908
+ value.unpack("H*")[0].tr('a-f', 'A-F')
909
+ end
910
+ end
911
+
912
+ class XSDBase64Binary < XSDAnySimpleType
913
+ Type = QName.new(Namespace, Base64BinaryLiteral)
914
+
915
+ # String in Ruby could be a binary.
916
+ def initialize(value = nil)
917
+ init(Type, value)
918
+ end
919
+
920
+ def set_encoded(value)
921
+ if /^[A-Za-z0-9+\/=]*$/ !~ value
922
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
923
+ end
924
+ @data = String.new(value).strip
925
+ @is_nil = false
926
+ end
927
+
928
+ def string
929
+ @data.unpack("m")[0]
930
+ end
931
+
932
+ private
933
+
934
+ def screen_data(value)
935
+ [value].pack("m").strip
936
+ end
937
+ end
938
+
939
+ class XSDAnyURI < XSDAnySimpleType
940
+ Type = QName.new(Namespace, AnyURILiteral)
941
+
942
+ def initialize(value = nil)
943
+ init(Type, value)
944
+ end
945
+
946
+ private
947
+
948
+ def screen_data(value)
949
+ begin
950
+ URI.parse(value.to_s.strip)
951
+ rescue URI::InvalidURIError
952
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
953
+ end
954
+ end
955
+ end
956
+
957
+ class XSDQName < XSDAnySimpleType
958
+ Type = QName.new(Namespace, QNameLiteral)
959
+
960
+ def initialize(value = nil)
961
+ init(Type, value)
962
+ end
963
+
964
+ private
965
+
966
+ def screen_data(value)
967
+ /^(?:([^:]+):)?([^:]+)$/ =~ value.to_s.strip
968
+ unless Regexp.last_match
969
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
970
+ end
971
+ prefix = $1
972
+ localpart = $2
973
+ [prefix, localpart]
974
+ end
975
+
976
+ def _set(data)
977
+ if data.nil?
978
+ @prefix = @localpart = @data = nil
979
+ return
980
+ end
981
+ @prefix, @localpart = data
982
+ @data = _to_s
983
+ @data.freeze
984
+ end
985
+
986
+ def _to_s
987
+ if @prefix
988
+ "#{ @prefix }:#{ @localpart }"
989
+ else
990
+ "#{ @localpart }"
991
+ end
992
+ end
993
+ end
994
+
995
+
996
+ ###
997
+ ## Derived types
998
+ #
999
+ class XSDNormalizedString < XSDString
1000
+ Type = QName.new(Namespace, NormalizedStringLiteral)
1001
+
1002
+ def initialize(value = nil)
1003
+ init(Type, value)
1004
+ end
1005
+
1006
+ private
1007
+
1008
+ def screen_data(value)
1009
+ if /[\t\r\n]/ =~ value
1010
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
1011
+ end
1012
+ super
1013
+ end
1014
+ end
1015
+
1016
+ class XSDInteger < XSDDecimal
1017
+ Type = QName.new(Namespace, IntegerLiteral)
1018
+
1019
+ def initialize(value = nil)
1020
+ init(Type, value)
1021
+ end
1022
+
1023
+ private
1024
+
1025
+ def screen_data_str(str)
1026
+ begin
1027
+ data = Integer(str)
1028
+ rescue ArgumentError
1029
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
1030
+ end
1031
+ unless validate(data)
1032
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
1033
+ end
1034
+ data
1035
+ end
1036
+
1037
+ def _set(value)
1038
+ @data = value
1039
+ end
1040
+
1041
+ def _to_s()
1042
+ @data.to_s
1043
+ end
1044
+
1045
+ def validate(v)
1046
+ max = maxinclusive
1047
+ min = mininclusive
1048
+ (max.nil? or v <= max) and (min.nil? or v >= min)
1049
+ end
1050
+
1051
+ def maxinclusive
1052
+ nil
1053
+ end
1054
+
1055
+ def mininclusive
1056
+ nil
1057
+ end
1058
+
1059
+ PositiveMinInclusive = 1
1060
+ def positive(v)
1061
+ PositiveMinInclusive <= v
1062
+ end
1063
+ end
1064
+
1065
+ class XSDNonPositiveInteger < XSDInteger
1066
+ Type = QName.new(Namespace, NonPositiveIntegerLiteral)
1067
+
1068
+ def initialize(value = nil)
1069
+ init(Type, value)
1070
+ end
1071
+
1072
+ private
1073
+
1074
+ def maxinclusive
1075
+ 0
1076
+ end
1077
+
1078
+ def mininclusive
1079
+ nil
1080
+ end
1081
+ end
1082
+
1083
+ class XSDNegativeInteger < XSDNonPositiveInteger
1084
+ Type = QName.new(Namespace, NegativeIntegerLiteral)
1085
+
1086
+ def initialize(value = nil)
1087
+ init(Type, value)
1088
+ end
1089
+
1090
+ private
1091
+
1092
+ def maxinclusive
1093
+ -1
1094
+ end
1095
+
1096
+ def mininclusive
1097
+ nil
1098
+ end
1099
+ end
1100
+
1101
+ class XSDLong < XSDInteger
1102
+ Type = QName.new(Namespace, LongLiteral)
1103
+
1104
+ def initialize(value = nil)
1105
+ init(Type, value)
1106
+ end
1107
+
1108
+ private
1109
+
1110
+ def maxinclusive
1111
+ +9223372036854775807
1112
+ end
1113
+
1114
+ def mininclusive
1115
+ -9223372036854775808
1116
+ end
1117
+ end
1118
+
1119
+ class XSDInt < XSDLong
1120
+ Type = QName.new(Namespace, IntLiteral)
1121
+
1122
+ def initialize(value = nil)
1123
+ init(Type, value)
1124
+ end
1125
+
1126
+ private
1127
+
1128
+ def maxinclusive
1129
+ +2147483647
1130
+ end
1131
+
1132
+ def mininclusive
1133
+ -2147483648
1134
+ end
1135
+ end
1136
+
1137
+ class XSDShort < XSDInt
1138
+ Type = QName.new(Namespace, ShortLiteral)
1139
+
1140
+ def initialize(value = nil)
1141
+ init(Type, value)
1142
+ end
1143
+
1144
+ private
1145
+
1146
+ def maxinclusive
1147
+ +32767
1148
+ end
1149
+
1150
+ def mininclusive
1151
+ -32768
1152
+ end
1153
+ end
1154
+
1155
+ class XSDByte < XSDShort
1156
+ Type = QName.new(Namespace, ByteLiteral)
1157
+
1158
+ def initialize(value = nil)
1159
+ init(Type, value)
1160
+ end
1161
+
1162
+ private
1163
+
1164
+ def maxinclusive
1165
+ +127
1166
+ end
1167
+
1168
+ def mininclusive
1169
+ -128
1170
+ end
1171
+ end
1172
+
1173
+ class XSDNonNegativeInteger < XSDInteger
1174
+ Type = QName.new(Namespace, NonNegativeIntegerLiteral)
1175
+
1176
+ def initialize(value = nil)
1177
+ init(Type, value)
1178
+ end
1179
+
1180
+ private
1181
+
1182
+ def maxinclusive
1183
+ nil
1184
+ end
1185
+
1186
+ def mininclusive
1187
+ 0
1188
+ end
1189
+ end
1190
+
1191
+ class XSDUnsignedLong < XSDNonNegativeInteger
1192
+ Type = QName.new(Namespace, UnsignedLongLiteral)
1193
+
1194
+ def initialize(value = nil)
1195
+ init(Type, value)
1196
+ end
1197
+
1198
+ private
1199
+
1200
+ def maxinclusive
1201
+ +18446744073709551615
1202
+ end
1203
+
1204
+ def mininclusive
1205
+ 0
1206
+ end
1207
+ end
1208
+
1209
+ class XSDUnsignedInt < XSDUnsignedLong
1210
+ Type = QName.new(Namespace, UnsignedIntLiteral)
1211
+
1212
+ def initialize(value = nil)
1213
+ init(Type, value)
1214
+ end
1215
+
1216
+ private
1217
+
1218
+ def maxinclusive
1219
+ +4294967295
1220
+ end
1221
+
1222
+ def mininclusive
1223
+ 0
1224
+ end
1225
+ end
1226
+
1227
+ class XSDUnsignedShort < XSDUnsignedInt
1228
+ Type = QName.new(Namespace, UnsignedShortLiteral)
1229
+
1230
+ def initialize(value = nil)
1231
+ init(Type, value)
1232
+ end
1233
+
1234
+ private
1235
+
1236
+ def maxinclusive
1237
+ +65535
1238
+ end
1239
+
1240
+ def mininclusive
1241
+ 0
1242
+ end
1243
+ end
1244
+
1245
+ class XSDUnsignedByte < XSDUnsignedShort
1246
+ Type = QName.new(Namespace, UnsignedByteLiteral)
1247
+
1248
+ def initialize(value = nil)
1249
+ init(Type, value)
1250
+ end
1251
+
1252
+ private
1253
+
1254
+ def maxinclusive
1255
+ +255
1256
+ end
1257
+
1258
+ def mininclusive
1259
+ 0
1260
+ end
1261
+ end
1262
+
1263
+ class XSDPositiveInteger < XSDNonNegativeInteger
1264
+ Type = QName.new(Namespace, PositiveIntegerLiteral)
1265
+
1266
+ def initialize(value = nil)
1267
+ init(Type, value)
1268
+ end
1269
+
1270
+ private
1271
+
1272
+ def maxinclusive
1273
+ nil
1274
+ end
1275
+
1276
+ def mininclusive
1277
+ 1
1278
+ end
1279
+ end
1280
+
1281
+
1282
+ end