rubyjedi-soap4r 1.5.8.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (444) hide show
  1. data/bin/wsdl2ruby.rb +137 -0
  2. data/bin/xsd2ruby.rb +90 -0
  3. data/lib/soap/attachment.rb +108 -0
  4. data/lib/soap/attrproxy.rb +34 -0
  5. data/lib/soap/baseData.rb +1094 -0
  6. data/lib/soap/element.rb +279 -0
  7. data/lib/soap/encodingstyle/aspDotNetHandler.rb +207 -0
  8. data/lib/soap/encodingstyle/handler.rb +120 -0
  9. data/lib/soap/encodingstyle/literalHandler.rb +195 -0
  10. data/lib/soap/encodingstyle/soapHandler.rb +559 -0
  11. data/lib/soap/filter.rb +13 -0
  12. data/lib/soap/filter/filterchain.rb +51 -0
  13. data/lib/soap/filter/handler.rb +31 -0
  14. data/lib/soap/filter/streamhandler.rb +29 -0
  15. data/lib/soap/generator.rb +299 -0
  16. data/lib/soap/header/handler.rb +61 -0
  17. data/lib/soap/header/handlerset.rb +70 -0
  18. data/lib/soap/header/mappinghandler.rb +47 -0
  19. data/lib/soap/header/simplehandler.rb +44 -0
  20. data/lib/soap/httpconfigloader.rb +139 -0
  21. data/lib/soap/mapping.rb +12 -0
  22. data/lib/soap/mapping/encodedregistry.rb +537 -0
  23. data/lib/soap/mapping/factory.rb +388 -0
  24. data/lib/soap/mapping/literalregistry.rb +391 -0
  25. data/lib/soap/mapping/mapping.rb +577 -0
  26. data/lib/soap/mapping/registry.rb +310 -0
  27. data/lib/soap/mapping/rubytypeFactory.rb +446 -0
  28. data/lib/soap/mapping/schemadefinition.rb +170 -0
  29. data/lib/soap/mapping/typeMap.rb +106 -0
  30. data/lib/soap/mapping/wsdlencodedregistry.rb +211 -0
  31. data/lib/soap/mapping/wsdlliteralregistry.rb +248 -0
  32. data/lib/soap/marshal.rb +59 -0
  33. data/lib/soap/mimemessage.rb +241 -0
  34. data/lib/soap/nestedexception.rb +42 -0
  35. data/lib/soap/netHttpClient.rb +241 -0
  36. data/lib/soap/ns.rb +34 -0
  37. data/lib/soap/parser.rb +252 -0
  38. data/lib/soap/processor.rb +66 -0
  39. data/lib/soap/property.rb +333 -0
  40. data/lib/soap/proxy.rb +14 -0
  41. data/lib/soap/rpc/cgistub.rb +247 -0
  42. data/lib/soap/rpc/driver.rb +221 -0
  43. data/lib/soap/rpc/element.rb +374 -0
  44. data/lib/soap/rpc/element.rb.orig +378 -0
  45. data/lib/soap/rpc/httpserver.rb +142 -0
  46. data/lib/soap/rpc/methodDef.rb +68 -0
  47. data/lib/soap/rpc/proxy.rb +572 -0
  48. data/lib/soap/rpc/router.rb +662 -0
  49. data/lib/soap/rpc/rpc.rb +25 -0
  50. data/lib/soap/rpc/soaplet.rb +200 -0
  51. data/lib/soap/rpc/standaloneServer.rb +43 -0
  52. data/lib/soap/ruby18ext.rb +13 -0
  53. data/lib/soap/soap.rb +151 -0
  54. data/lib/soap/streamHandler.rb +301 -0
  55. data/lib/soap/wsdlDriver.rb +164 -0
  56. data/lib/wsdl/binding.rb +65 -0
  57. data/lib/wsdl/data.rb +64 -0
  58. data/lib/wsdl/definitions.rb +236 -0
  59. data/lib/wsdl/documentation.rb +32 -0
  60. data/lib/wsdl/import.rb +80 -0
  61. data/lib/wsdl/importer.rb +38 -0
  62. data/lib/wsdl/info.rb +50 -0
  63. data/lib/wsdl/message.rb +54 -0
  64. data/lib/wsdl/operation.rb +151 -0
  65. data/lib/wsdl/operationBinding.rb +240 -0
  66. data/lib/wsdl/param.rb +93 -0
  67. data/lib/wsdl/parser.rb +164 -0
  68. data/lib/wsdl/part.rb +52 -0
  69. data/lib/wsdl/port.rb +66 -0
  70. data/lib/wsdl/portType.rb +75 -0
  71. data/lib/wsdl/service.rb +61 -0
  72. data/lib/wsdl/soap/address.rb +40 -0
  73. data/lib/wsdl/soap/binding.rb +49 -0
  74. data/lib/wsdl/soap/body.rb +58 -0
  75. data/lib/wsdl/soap/cgiStubCreator.rb +92 -0
  76. data/lib/wsdl/soap/classDefCreator.rb +433 -0
  77. data/lib/wsdl/soap/classDefCreatorSupport.rb +240 -0
  78. data/lib/wsdl/soap/classNameCreator.rb +54 -0
  79. data/lib/wsdl/soap/clientSkeltonCreator.rb +104 -0
  80. data/lib/wsdl/soap/complexType.rb +173 -0
  81. data/lib/wsdl/soap/data.rb +42 -0
  82. data/lib/wsdl/soap/definitions.rb +200 -0
  83. data/lib/wsdl/soap/driverCreator.rb +118 -0
  84. data/lib/wsdl/soap/element.rb +33 -0
  85. data/lib/wsdl/soap/encodedMappingRegistryCreator.rb +73 -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 +115 -0
  90. data/lib/wsdl/soap/mappingRegistryCreator.rb +58 -0
  91. data/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +376 -0
  92. data/lib/wsdl/soap/methodDefCreator.rb +199 -0
  93. data/lib/wsdl/soap/operation.rb +112 -0
  94. data/lib/wsdl/soap/servantSkeltonCreator.rb +89 -0
  95. data/lib/wsdl/soap/servletStubCreator.rb +104 -0
  96. data/lib/wsdl/soap/standaloneServerStubCreator.rb +100 -0
  97. data/lib/wsdl/soap/wsdl2ruby.rb +217 -0
  98. data/lib/wsdl/types.rb +44 -0
  99. data/lib/wsdl/wsdl.rb +24 -0
  100. data/lib/wsdl/xmlSchema/all.rb +24 -0
  101. data/lib/wsdl/xmlSchema/annotation.rb +34 -0
  102. data/lib/wsdl/xmlSchema/any.rb +61 -0
  103. data/lib/wsdl/xmlSchema/anyAttribute.rb +48 -0
  104. data/lib/wsdl/xmlSchema/attribute.rb +104 -0
  105. data/lib/wsdl/xmlSchema/attributeGroup.rb +68 -0
  106. data/lib/wsdl/xmlSchema/choice.rb +58 -0
  107. data/lib/wsdl/xmlSchema/complexContent.rb +97 -0
  108. data/lib/wsdl/xmlSchema/complexExtension.rb +119 -0
  109. data/lib/wsdl/xmlSchema/complexRestriction.rb +104 -0
  110. data/lib/wsdl/xmlSchema/complexType.rb +193 -0
  111. data/lib/wsdl/xmlSchema/content.rb +95 -0
  112. data/lib/wsdl/xmlSchema/data.rb +116 -0
  113. data/lib/wsdl/xmlSchema/element.rb +153 -0
  114. data/lib/wsdl/xmlSchema/enumeration.rb +36 -0
  115. data/lib/wsdl/xmlSchema/fractiondigits.rb +37 -0
  116. data/lib/wsdl/xmlSchema/group.rb +100 -0
  117. data/lib/wsdl/xmlSchema/import.rb +53 -0
  118. data/lib/wsdl/xmlSchema/importHandler.rb +45 -0
  119. data/lib/wsdl/xmlSchema/importer.rb +102 -0
  120. data/lib/wsdl/xmlSchema/include.rb +48 -0
  121. data/lib/wsdl/xmlSchema/length.rb +37 -0
  122. data/lib/wsdl/xmlSchema/list.rb +48 -0
  123. data/lib/wsdl/xmlSchema/maxexclusive.rb +37 -0
  124. data/lib/wsdl/xmlSchema/maxinclusive.rb +37 -0
  125. data/lib/wsdl/xmlSchema/maxlength.rb +37 -0
  126. data/lib/wsdl/xmlSchema/minexclusive.rb +37 -0
  127. data/lib/wsdl/xmlSchema/mininclusive.rb +37 -0
  128. data/lib/wsdl/xmlSchema/minlength.rb +37 -0
  129. data/lib/wsdl/xmlSchema/parser.rb +167 -0
  130. data/lib/wsdl/xmlSchema/pattern.rb +36 -0
  131. data/lib/wsdl/xmlSchema/ref.rb +33 -0
  132. data/lib/wsdl/xmlSchema/schema.rb +178 -0
  133. data/lib/wsdl/xmlSchema/sequence.rb +54 -0
  134. data/lib/wsdl/xmlSchema/simpleContent.rb +69 -0
  135. data/lib/wsdl/xmlSchema/simpleExtension.rb +62 -0
  136. data/lib/wsdl/xmlSchema/simpleRestriction.rb +132 -0
  137. data/lib/wsdl/xmlSchema/simpleType.rb +87 -0
  138. data/lib/wsdl/xmlSchema/totaldigits.rb +37 -0
  139. data/lib/wsdl/xmlSchema/union.rb +35 -0
  140. data/lib/wsdl/xmlSchema/unique.rb +34 -0
  141. data/lib/wsdl/xmlSchema/whitespace.rb +37 -0
  142. data/lib/wsdl/xmlSchema/xsd2ruby.rb +174 -0
  143. data/lib/xsd/charset.rb +188 -0
  144. data/lib/xsd/codegen.rb +12 -0
  145. data/lib/xsd/codegen/classdef.rb +208 -0
  146. data/lib/xsd/codegen/commentdef.rb +34 -0
  147. data/lib/xsd/codegen/gensupport.rb +273 -0
  148. data/lib/xsd/codegen/methoddef.rb +70 -0
  149. data/lib/xsd/codegen/moduledef.rb +208 -0
  150. data/lib/xsd/datatypes.rb +1465 -0
  151. data/lib/xsd/datatypes1999.rb +20 -0
  152. data/lib/xsd/iconvcharset.rb +33 -0
  153. data/lib/xsd/mapping.rb +68 -0
  154. data/lib/xsd/namedelements.rb +132 -0
  155. data/lib/xsd/ns.rb +182 -0
  156. data/lib/xsd/qname.rb +79 -0
  157. data/lib/xsd/xmlparser.rb +82 -0
  158. data/lib/xsd/xmlparser.rb.orig +110 -0
  159. data/lib/xsd/xmlparser/libxmlparser.rb +119 -0
  160. data/lib/xsd/xmlparser/parser.rb +100 -0
  161. data/lib/xsd/xmlparser/rexmlparser.rb +58 -0
  162. data/lib/xsd/xmlparser/xmlparser.rb +50 -0
  163. data/lib/xsd/xmlparser/xmlscanner.rb +149 -0
  164. data/test/16runner.rb +68 -0
  165. data/test/interopR2/README.txt +2 -0
  166. data/test/interopR2/SOAPBuildersInterop_R2.wsdl +461 -0
  167. data/test/interopR2/SOAPBuildersInterop_R2GrB.wsdl +19 -0
  168. data/test/interopR2/base.rb +288 -0
  169. data/test/interopR2/client.NetRemoting.rb +17 -0
  170. data/test/interopR2/client.rb +1234 -0
  171. data/test/interopR2/client4S4C.rb +15 -0
  172. data/test/interopR2/client4S4C2.rb +14 -0
  173. data/test/interopR2/clientASP.NET.rb +17 -0
  174. data/test/interopR2/clientApacheAxis.rb +16 -0
  175. data/test/interopR2/clientApacheSOAP.rb +17 -0
  176. data/test/interopR2/clientBEAWebLogic.rb +17 -0
  177. data/test/interopR2/clientBase.rb +1967 -0
  178. data/test/interopR2/clientCapeConnect.rb +18 -0
  179. data/test/interopR2/clientDelphi.rb +19 -0
  180. data/test/interopR2/clientEasySoap.rb +14 -0
  181. data/test/interopR2/clientFrontier.rb +25 -0
  182. data/test/interopR2/clientGLUE.rb +32 -0
  183. data/test/interopR2/clientHP.rb +13 -0
  184. data/test/interopR2/clientJAX-RPC.rb +19 -0
  185. data/test/interopR2/clientJSOAP.rb +14 -0
  186. data/test/interopR2/clientKafkaXSLT.rb +15 -0
  187. data/test/interopR2/clientMSSOAPToolkit2.0.rb +17 -0
  188. data/test/interopR2/clientMSSOAPToolkit3.0.rb +17 -0
  189. data/test/interopR2/clientNuSOAP.rb +19 -0
  190. data/test/interopR2/clientNuWave.rb +15 -0
  191. data/test/interopR2/clientOpenLink.rb +15 -0
  192. data/test/interopR2/clientOracle.rb +15 -0
  193. data/test/interopR2/clientPEAR.rb +18 -0
  194. data/test/interopR2/clientPhalanx.rb +18 -0
  195. data/test/interopR2/clientSIMACE.rb +18 -0
  196. data/test/interopR2/clientSOAP4R.rb +18 -0
  197. data/test/interopR2/clientSOAP__Lite.rb +14 -0
  198. data/test/interopR2/clientSQLData.rb +18 -0
  199. data/test/interopR2/clientSilverStream.rb +17 -0
  200. data/test/interopR2/clientSpray2001.rb +17 -0
  201. data/test/interopR2/clientSun.rb +19 -0
  202. data/test/interopR2/clientVWOpentalkSoap.rb +19 -0
  203. data/test/interopR2/clientWASP.rb +19 -0
  204. data/test/interopR2/clientWASPC.rb +18 -0
  205. data/test/interopR2/clientWebMethods.rb +15 -0
  206. data/test/interopR2/clientWhiteMesa.rb +28 -0
  207. data/test/interopR2/clientWingfoot.rb +15 -0
  208. data/test/interopR2/clientXMLBus.rb +19 -0
  209. data/test/interopR2/clientXMLRPC-EPI.rb +17 -0
  210. data/test/interopR2/clientXSOAP.rb +14 -0
  211. data/test/interopR2/clientZSI.rb +19 -0
  212. data/test/interopR2/clienteSOAP.rb +18 -0
  213. data/test/interopR2/clientgSOAP.rb +18 -0
  214. data/test/interopR2/clientkSOAP.rb +17 -0
  215. data/test/interopR2/iSimonReg.rb +112 -0
  216. data/test/interopR2/interopResultBase.rb +114 -0
  217. data/test/interopR2/interopService.rb +247 -0
  218. data/test/interopR2/rwikiInteropService.rb +105 -0
  219. data/test/interopR2/server.cgi +270 -0
  220. data/test/interopR2/server.rb +275 -0
  221. data/test/interopR2/simonReg.rb +123 -0
  222. data/test/interopR2/test.sh +49 -0
  223. data/test/interopR4/client.rb +112 -0
  224. data/test/results +4810 -0
  225. data/test/runner.rb +7 -0
  226. data/test/sm11/classDef.rb +156 -0
  227. data/test/sm11/client.rb +542 -0
  228. data/test/sm11/driver.rb +183 -0
  229. data/test/sm11/servant.rb +1067 -0
  230. data/test/sm11/server.rb +25 -0
  231. data/test/soap/asp.net/hello.wsdl +96 -0
  232. data/test/soap/asp.net/test_aspdotnet.rb +123 -0
  233. data/test/soap/auth/htdigest +2 -0
  234. data/test/soap/auth/htpasswd +2 -0
  235. data/test/soap/auth/test_basic.rb +117 -0
  236. data/test/soap/auth/test_digest.rb +118 -0
  237. data/test/soap/calc/calc.rb +17 -0
  238. data/test/soap/calc/calc2.rb +29 -0
  239. data/test/soap/calc/server.cgi +13 -0
  240. data/test/soap/calc/server.rb +17 -0
  241. data/test/soap/calc/server2.rb +20 -0
  242. data/test/soap/calc/test_calc.rb +51 -0
  243. data/test/soap/calc/test_calc2.rb +55 -0
  244. data/test/soap/calc/test_calc_cgi.rb +71 -0
  245. data/test/soap/case/test_mapping.rb +57 -0
  246. data/test/soap/fault/test_customfault.rb +60 -0
  247. data/test/soap/fault/test_fault.rb +46 -0
  248. data/test/soap/fault/test_soaparray.rb +35 -0
  249. data/test/soap/filter/test_filter.rb +146 -0
  250. data/test/soap/header/server.cgi +119 -0
  251. data/test/soap/header/session.pstoredb +0 -0
  252. data/test/soap/header/test_authheader.rb +240 -0
  253. data/test/soap/header/test_authheader_cgi.rb +121 -0
  254. data/test/soap/header/test_simplehandler.rb +116 -0
  255. data/test/soap/helloworld/hw_s.rb +16 -0
  256. data/test/soap/helloworld/test_helloworld.rb +43 -0
  257. data/test/soap/htpasswd +2 -0
  258. data/test/soap/literalArrayMapping/amazonEc.rb +4778 -0
  259. data/test/soap/literalArrayMapping/amazonEcDriver.rb +172 -0
  260. data/test/soap/literalArrayMapping/amazonresponse.xml +100 -0
  261. data/test/soap/literalArrayMapping/test_definedarray.rb +34 -0
  262. data/test/soap/marshal/marshaltestlib.rb +494 -0
  263. data/test/soap/marshal/test_digraph.rb +56 -0
  264. data/test/soap/marshal/test_marshal.rb +26 -0
  265. data/test/soap/marshal/test_struct.rb +47 -0
  266. data/test/soap/ssl/README +1 -0
  267. data/test/soap/ssl/ca.cert +23 -0
  268. data/test/soap/ssl/client.cert +19 -0
  269. data/test/soap/ssl/client.key +15 -0
  270. data/test/soap/ssl/server.cert +19 -0
  271. data/test/soap/ssl/server.key +15 -0
  272. data/test/soap/ssl/sslsvr.rb +57 -0
  273. data/test/soap/ssl/subca.cert +21 -0
  274. data/test/soap/ssl/test_ssl.rb +235 -0
  275. data/test/soap/struct/test_struct.rb +70 -0
  276. data/test/soap/styleuse/client.rb +20 -0
  277. data/test/soap/styleuse/server.rb +86 -0
  278. data/test/soap/swa/test_file.rb +75 -0
  279. data/test/soap/test_basetype.rb +1090 -0
  280. data/test/soap/test_cookie.rb +112 -0
  281. data/test/soap/test_custom_ns.rb +105 -0
  282. data/test/soap/test_custommap.rb +110 -0
  283. data/test/soap/test_empty.rb +105 -0
  284. data/test/soap/test_envelopenamespace.rb +85 -0
  285. data/test/soap/test_extraattr.rb +54 -0
  286. data/test/soap/test_generator.rb +29 -0
  287. data/test/soap/test_httpconfigloader.rb +71 -0
  288. data/test/soap/test_mapping.rb +131 -0
  289. data/test/soap/test_nestedexception.rb +56 -0
  290. data/test/soap/test_nil.rb +75 -0
  291. data/test/soap/test_no_indent.rb +88 -0
  292. data/test/soap/test_property.rb +428 -0
  293. data/test/soap/test_response_as_xml.rb +117 -0
  294. data/test/soap/test_soapelement.rb +138 -0
  295. data/test/soap/test_streamhandler.rb +270 -0
  296. data/test/soap/test_styleuse.rb +326 -0
  297. data/test/soap/wsdlDriver/README.txt +2 -0
  298. data/test/soap/wsdlDriver/calc.wsdl +126 -0
  299. data/test/soap/wsdlDriver/document.wsdl +54 -0
  300. data/test/soap/wsdlDriver/echo_version.rb +29 -0
  301. data/test/soap/wsdlDriver/simpletype.wsdl +63 -0
  302. data/test/soap/wsdlDriver/test_calc.rb +71 -0
  303. data/test/soap/wsdlDriver/test_document.rb +71 -0
  304. data/test/soap/wsdlDriver/test_simpletype.rb +80 -0
  305. data/test/testutil.rb +54 -0
  306. data/test/wsdl/abstract/abstract.wsdl +176 -0
  307. data/test/wsdl/abstract/test_abstract.rb +159 -0
  308. data/test/wsdl/anonymous/expectedClassDef.rb +128 -0
  309. data/test/wsdl/anonymous/expectedDriver.rb +59 -0
  310. data/test/wsdl/anonymous/expectedMappingRegistry.rb +176 -0
  311. data/test/wsdl/anonymous/lp.wsdl +147 -0
  312. data/test/wsdl/anonymous/test_anonymous.rb +130 -0
  313. data/test/wsdl/any/any.wsdl +114 -0
  314. data/test/wsdl/any/expectedDriver.rb +68 -0
  315. data/test/wsdl/any/expectedEcho.rb +57 -0
  316. data/test/wsdl/any/expectedMappingRegistry.rb +63 -0
  317. data/test/wsdl/any/expectedService.rb +69 -0
  318. data/test/wsdl/any/test_any.rb +193 -0
  319. data/test/wsdl/axisArray/axisArray.wsdl +87 -0
  320. data/test/wsdl/axisArray/test_axisarray.rb +124 -0
  321. data/test/wsdl/choice/choice.wsdl +167 -0
  322. data/test/wsdl/choice/test_choice.rb +310 -0
  323. data/test/wsdl/complexcontent/complexContent.wsdl +83 -0
  324. data/test/wsdl/complexcontent/test_echo.rb +90 -0
  325. data/test/wsdl/datetime/DatetimeService.rb +44 -0
  326. data/test/wsdl/datetime/datetime.rb +0 -0
  327. data/test/wsdl/datetime/datetime.wsdl +45 -0
  328. data/test/wsdl/datetime/datetimeServant.rb +22 -0
  329. data/test/wsdl/datetime/test_datetime.rb +86 -0
  330. data/test/wsdl/document/array/double.wsdl +161 -0
  331. data/test/wsdl/document/array/test_array.rb +201 -0
  332. data/test/wsdl/document/document.wsdl +76 -0
  333. data/test/wsdl/document/number.wsdl +54 -0
  334. data/test/wsdl/document/ping_nosoapaction.wsdl +66 -0
  335. data/test/wsdl/document/test_nosoapaction.rb +102 -0
  336. data/test/wsdl/document/test_number.rb +92 -0
  337. data/test/wsdl/document/test_rpc.rb +355 -0
  338. data/test/wsdl/emptycomplextype.wsdl +31 -0
  339. data/test/wsdl/fault/fault.wsdl +79 -0
  340. data/test/wsdl/fault/multifault.wsdl +96 -0
  341. data/test/wsdl/fault/test_fault.rb +119 -0
  342. data/test/wsdl/fault/test_multifault.rb +134 -0
  343. data/test/wsdl/group/expectedClassdef.rb +58 -0
  344. data/test/wsdl/group/expectedDriver.rb +51 -0
  345. data/test/wsdl/group/expectedMappingRegistry.rb +67 -0
  346. data/test/wsdl/group/group.wsdl +88 -0
  347. data/test/wsdl/group/test_rpc.rb +145 -0
  348. data/test/wsdl/list/list.wsdl +93 -0
  349. data/test/wsdl/list/test_list.rb +124 -0
  350. data/test/wsdl/map/map.wsdl +92 -0
  351. data/test/wsdl/map/map.xml +43 -0
  352. data/test/wsdl/map/test_map.rb +99 -0
  353. data/test/wsdl/marshal/Person.rb +1 -0
  354. data/test/wsdl/marshal/person.wsdl +21 -0
  355. data/test/wsdl/marshal/person_org.rb +23 -0
  356. data/test/wsdl/marshal/test_wsdlmarshal.rb +76 -0
  357. data/test/wsdl/multiplefault.wsdl +75 -0
  358. data/test/wsdl/oneway/oneway.wsdl +36 -0
  359. data/test/wsdl/oneway/test_oneway.rb +108 -0
  360. data/test/wsdl/overload/expectedClient.rb +37 -0
  361. data/test/wsdl/overload/expectedDriver.rb +61 -0
  362. data/test/wsdl/overload/expectedServant.rb +35 -0
  363. data/test/wsdl/overload/overload.wsdl +70 -0
  364. data/test/wsdl/overload/test_overload.rb +131 -0
  365. data/test/wsdl/qualified/lp.wsdl +47 -0
  366. data/test/wsdl/qualified/lp.xsd +26 -0
  367. data/test/wsdl/qualified/np.wsdl +51 -0
  368. data/test/wsdl/qualified/test_qualified.rb +137 -0
  369. data/test/wsdl/qualified/test_unqualified.rb +138 -0
  370. data/test/wsdl/raa/RAAService.rb +125 -0
  371. data/test/wsdl/raa/README.txt +8 -0
  372. data/test/wsdl/raa/expectedClassDef.rb +100 -0
  373. data/test/wsdl/raa/expectedDriver.rb +96 -0
  374. data/test/wsdl/raa/expectedMappingRegistry.rb +121 -0
  375. data/test/wsdl/raa/raa.wsdl +264 -0
  376. data/test/wsdl/raa/test_raa.rb +126 -0
  377. data/test/wsdl/ref/expectedDriver.rb +51 -0
  378. data/test/wsdl/ref/expectedProduct.rb +243 -0
  379. data/test/wsdl/ref/product.wsdl +147 -0
  380. data/test/wsdl/ref/test_ref.rb +268 -0
  381. data/test/wsdl/rpc/rpc.wsdl +109 -0
  382. data/test/wsdl/rpc/test-rpc-lit.wsdl +371 -0
  383. data/test/wsdl/rpc/test_rpc.rb +176 -0
  384. data/test/wsdl/rpc/test_rpc_lit.rb +470 -0
  385. data/test/wsdl/simplecontent/simplecontent.wsdl +84 -0
  386. data/test/wsdl/simplecontent/test_simplecontent.rb +102 -0
  387. data/test/wsdl/simpletype/rpc/echo_version.rb +1 -0
  388. data/test/wsdl/simpletype/rpc/echo_versionDriver.rb +10 -0
  389. data/test/wsdl/simpletype/rpc/echo_versionMappingRegistry.rb +4 -0
  390. data/test/wsdl/simpletype/rpc/echo_versionServant.rb +3 -0
  391. data/test/wsdl/simpletype/rpc/echo_version_service.rb +3 -0
  392. data/test/wsdl/simpletype/rpc/echo_version_serviceClient.rb +34 -0
  393. data/test/wsdl/simpletype/rpc/expectedClient.rb +34 -0
  394. data/test/wsdl/simpletype/rpc/expectedDriver.rb +58 -0
  395. data/test/wsdl/simpletype/rpc/expectedEchoVersion.rb +36 -0
  396. data/test/wsdl/simpletype/rpc/expectedMappingRegistry.rb +57 -0
  397. data/test/wsdl/simpletype/rpc/expectedServant.rb +32 -0
  398. data/test/wsdl/simpletype/rpc/expectedService.rb +55 -0
  399. data/test/wsdl/simpletype/rpc/rpc.wsdl +98 -0
  400. data/test/wsdl/simpletype/rpc/test_rpc.rb +52 -0
  401. data/test/wsdl/simpletype/simpletype.wsdl +114 -0
  402. data/test/wsdl/simpletype/test_simpletype.rb +92 -0
  403. data/test/wsdl/soap/soapbodyparts.wsdl +103 -0
  404. data/test/wsdl/soap/test_soapbodyparts.rb +79 -0
  405. data/test/wsdl/soap/wsdl2ruby/echo_version.rb +1 -0
  406. data/test/wsdl/soap/wsdl2ruby/echo_versionDriver.rb +10 -0
  407. data/test/wsdl/soap/wsdl2ruby/echo_versionMappingRegistry.rb +4 -0
  408. data/test/wsdl/soap/wsdl2ruby/echo_versionServant.rb +3 -0
  409. data/test/wsdl/soap/wsdl2ruby/echo_version_service.cgi +3 -0
  410. data/test/wsdl/soap/wsdl2ruby/echo_version_service.rb +7 -0
  411. data/test/wsdl/soap/wsdl2ruby/echo_version_serviceClient.rb +34 -0
  412. data/test/wsdl/soap/wsdl2ruby/expectedClassdef.rb +21 -0
  413. data/test/wsdl/soap/wsdl2ruby/expectedClient.rb +34 -0
  414. data/test/wsdl/soap/wsdl2ruby/expectedDriver.rb +58 -0
  415. data/test/wsdl/soap/wsdl2ruby/expectedMappingRegistry.rb +36 -0
  416. data/test/wsdl/soap/wsdl2ruby/expectedServant.rb +32 -0
  417. data/test/wsdl/soap/wsdl2ruby/expectedService.cgi +48 -0
  418. data/test/wsdl/soap/wsdl2ruby/expectedService.rb +55 -0
  419. data/test/wsdl/soap/wsdl2ruby/rpc.wsdl +80 -0
  420. data/test/wsdl/soap/wsdl2ruby/section/expectedClassdef.rb +37 -0
  421. data/test/wsdl/soap/wsdl2ruby/section/section.xsd +31 -0
  422. data/test/wsdl/soap/wsdl2ruby/section/test_section.rb +53 -0
  423. data/test/wsdl/soap/wsdl2ruby/soapenc/soapenc.wsdl +64 -0
  424. data/test/wsdl/soap/wsdl2ruby/soapenc/test_soapenc.rb +83 -0
  425. data/test/wsdl/soap/wsdl2ruby/test_wsdl2ruby.rb +102 -0
  426. data/test/wsdl/soaptype/soaptype.wsdl +61 -0
  427. data/test/wsdl/soaptype/test_soaptype.rb +178 -0
  428. data/test/wsdl/test_emptycomplextype.rb +21 -0
  429. data/test/wsdl/test_fault.rb +50 -0
  430. data/test/wsdl/test_multiplefault.rb +41 -0
  431. data/test/xsd/codegen/test_classdef.rb +244 -0
  432. data/test/xsd/noencoding.xml +4 -0
  433. data/test/xsd/test_noencoding.rb +32 -0
  434. data/test/xsd/test_ns.rb +41 -0
  435. data/test/xsd/test_xmlschemaparser.rb +22 -0
  436. data/test/xsd/test_xsd.rb +1638 -0
  437. data/test/xsd/xmllang.xml +43 -0
  438. data/test/xsd/xmlschema.xml +12 -0
  439. data/test/xsd/xsd2ruby/expected_mysample.rb +65 -0
  440. data/test/xsd/xsd2ruby/expected_mysample_mapper.rb +11 -0
  441. data/test/xsd/xsd2ruby/expected_mysample_mapping_registry.rb +51 -0
  442. data/test/xsd/xsd2ruby/section.xsd +49 -0
  443. data/test/xsd/xsd2ruby/test_xsd2ruby.rb +90 -0
  444. metadata +519 -0
@@ -0,0 +1,70 @@
1
+ # XSD4R - Generating method definition code
2
+ # Copyright (C) 2000-2007 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/codegen/gensupport'
10
+ require 'xsd/codegen/commentdef'
11
+
12
+
13
+ module XSD
14
+ module CodeGen
15
+
16
+
17
+ class MethodDef
18
+ include GenSupport
19
+ include CommentDef
20
+
21
+ attr_accessor :definition
22
+
23
+ def initialize(name, *params)
24
+ klass, mname = name.split('.', 2)
25
+ if mname.nil?
26
+ mname, klass = klass, mname
27
+ end
28
+ unless safemethodname?(mname)
29
+ raise ArgumentError.new("name '#{name}' seems to be unsafe")
30
+ end
31
+ if klass and klass != 'self' and !safeconstname(klass)
32
+ raise ArgumentError.new("name '#{name}' seems to be unsafe")
33
+ end
34
+ @name = name
35
+ @params = params
36
+ @comment = nil
37
+ @definition = yield if block_given?
38
+ end
39
+
40
+ def dump
41
+ buf = ""
42
+ buf << dump_comment if @comment
43
+ buf << dump_method_def
44
+ buf << dump_definition if @definition and !@definition.empty?
45
+ buf << dump_method_def_end
46
+ buf
47
+ end
48
+
49
+ private
50
+
51
+ def dump_method_def
52
+ if @params.empty?
53
+ format("def #{@name}")
54
+ else
55
+ format("def #{@name}(#{@params.join(", ")})")
56
+ end
57
+ end
58
+
59
+ def dump_method_def_end
60
+ format("end")
61
+ end
62
+
63
+ def dump_definition
64
+ format(@definition, 2)
65
+ end
66
+ end
67
+
68
+
69
+ end
70
+ end
@@ -0,0 +1,208 @@
1
+ # XSD4R - Generating module definition code
2
+ # Copyright (C) 2000-2007 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/codegen/gensupport'
10
+ require 'xsd/codegen/methoddef'
11
+ require 'xsd/codegen/commentdef'
12
+
13
+
14
+ module XSD
15
+ module CodeGen
16
+
17
+
18
+ class ModuleDef
19
+ include GenSupport
20
+ include CommentDef
21
+
22
+ attr_reader :name
23
+ attr_reader :innermodule
24
+
25
+ def initialize(name)
26
+ @name = name
27
+ @comment = nil
28
+ @const = []
29
+ @code = []
30
+ @requirepath = []
31
+ @methoddef = []
32
+ @innermodule = []
33
+ end
34
+
35
+ def def_require(path)
36
+ @requirepath << path
37
+ end
38
+
39
+ def def_const(const, value)
40
+ unless safeconstname?(const)
41
+ raise ArgumentError.new("#{const} seems to be unsafe")
42
+ end
43
+ @const << [const, value]
44
+ end
45
+
46
+ def def_code(code)
47
+ @code << code
48
+ end
49
+
50
+ def def_method(name, *params)
51
+ add_method(MethodDef.new(name, *params) { yield if block_given? }, :public)
52
+ end
53
+ alias def_publicmethod def_method
54
+
55
+ def def_protectedmethod(name, *params)
56
+ add_method(MethodDef.new(name, *params) { yield if block_given? },
57
+ :protected)
58
+ end
59
+
60
+ def def_privatemethod(name, *params)
61
+ add_method(MethodDef.new(name, *params) { yield if block_given? }, :private)
62
+ end
63
+
64
+ def add_method(m, visibility = :public)
65
+ @methoddef << [visibility, m]
66
+ end
67
+
68
+ def dump
69
+ buf = ""
70
+ unless @requirepath.empty?
71
+ buf << dump_requirepath
72
+ end
73
+ buf << dump_emptyline unless buf.empty?
74
+ package = @name.split(/::/)[0..-2]
75
+ buf << dump_package_def(package) unless package.empty?
76
+ buf << dump_comment if @comment
77
+ buf << dump_module_def
78
+ spacer = false
79
+ unless @const.empty?
80
+ buf << dump_emptyline if spacer
81
+ spacer = true
82
+ buf << dump_const
83
+ end
84
+ unless @innermodule.empty?
85
+ buf << dump_emptyline # always add 1 empty line
86
+ spacer = true
87
+ buf << dump_innermodule
88
+ end
89
+ unless @code.empty?
90
+ buf << dump_emptyline if spacer
91
+ spacer = true
92
+ buf << dump_code
93
+ end
94
+ unless @methoddef.empty?
95
+ buf << dump_emptyline if spacer
96
+ spacer = true
97
+ buf << dump_methods
98
+ end
99
+ buf << dump_module_def_end
100
+ buf << dump_package_def_end(package) unless package.empty?
101
+ buf.gsub(/^\s+$/, '')
102
+ end
103
+
104
+ private
105
+
106
+ def dump_requirepath
107
+ format(
108
+ @requirepath.collect { |path|
109
+ %Q(require '#{path}')
110
+ }.join("\n")
111
+ )
112
+ end
113
+
114
+ def dump_const
115
+ dump_static(
116
+ @const.sort.collect { |var, value|
117
+ %Q(#{var} = #{dump_value(value)})
118
+ }.join("\n")
119
+ )
120
+ end
121
+
122
+ def dump_innermodule
123
+ dump_static(
124
+ @innermodule.collect { |moduledef|
125
+ moduledef.dump
126
+ }.join("\n")
127
+ )
128
+ end
129
+
130
+ def dump_code
131
+ dump_static(@code.join("\n"))
132
+ end
133
+
134
+ def dump_static(str)
135
+ format(str, 2)
136
+ end
137
+
138
+ def dump_methods
139
+ methods = {}
140
+ @methoddef.each do |visibility, method|
141
+ (methods[visibility] ||= []) << method
142
+ end
143
+ str = ""
144
+ [:public, :protected, :private].each do |visibility|
145
+ if methods[visibility]
146
+ str << "\n" unless str.empty?
147
+ str << visibility.to_s << "\n\n" unless visibility == :public
148
+ str << methods[visibility].collect { |m| format(m.dump, 2) }.join("\n")
149
+ end
150
+ end
151
+ str
152
+ end
153
+
154
+ def dump_value(value)
155
+ if value.respond_to?(:to_src)
156
+ value.to_src
157
+ else
158
+ value
159
+ end
160
+ end
161
+
162
+ def dump_package_def(package)
163
+ format(package.collect { |ele| "module #{ele}" }.join("; ")) + "\n\n"
164
+ end
165
+
166
+ def dump_package_def_end(package)
167
+ "\n\n" + format(package.collect { |ele| "end" }.join("; "))
168
+ end
169
+
170
+ def dump_module_def
171
+ name = @name.to_s.split(/::/)
172
+ format("module #{name.last}")
173
+ end
174
+
175
+ def dump_module_def_end
176
+ format("end")
177
+ end
178
+ end
179
+
180
+
181
+ end
182
+ end
183
+
184
+
185
+ if __FILE__ == $0
186
+ require 'xsd/codegen/moduledef'
187
+ include XSD::CodeGen
188
+ m = ModuleDef.new("Foo::Bar::HobbitName")
189
+ m.def_require("foo/bar")
190
+ m.def_require("baz")
191
+ m.comment = <<-EOD
192
+ foo
193
+ bar
194
+ baz
195
+ EOD
196
+ m.def_method("foo") do
197
+ <<-EOD
198
+ foo.bar = 1
199
+ baz.each do |ele|
200
+ ele + 1
201
+ end
202
+ EOD
203
+ end
204
+ m.def_method("baz", "qux")
205
+ #m.def_protectedmethod("aaa")
206
+ m.def_privatemethod("bbb")
207
+ puts m.dump
208
+ end
@@ -0,0 +1,1465 @@
1
+ # XSD4R - XML Schema Datatype implementation.
2
+ # Copyright (C) 2000-2007 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 'soap/nestedexception'
12
+ require 'uri'
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
+ TokenLiteral = 'token'
50
+ LanguageLiteral = 'language'
51
+ NMTOKENLiteral = 'NMTOKEN'
52
+ NMTOKENSLiteral = 'NMTOKENS'
53
+ NameLiteral = 'Name'
54
+ NCNameLiteral = 'NCName'
55
+ IDLiteral = 'ID'
56
+ IDREFLiteral = 'IDREF'
57
+ IDREFSLiteral = 'IDREFS'
58
+ ENTITYLiteral = 'ENTITY'
59
+ ENTITIESLiteral = '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; include ::SOAP::NestedException; 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 !$6 and !$7 and !$8
458
+ # allows durations lower than a day such as 'PT5S'.
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
+ unless r.empty?
495
+ str << "T" << r
496
+ end
497
+ if l.empty? and r.empty?
498
+ str << "0D"
499
+ end
500
+ str
501
+ end
502
+ end
503
+
504
+
505
+ require 'rational'
506
+ require 'date'
507
+
508
+ module XSDDateTimeImpl
509
+ DayInSec = 86400 # 24 * 60 * 60
510
+ DayInMicro = 86400_000_000
511
+
512
+ def to_obj(klass)
513
+ if klass == Time
514
+ to_time
515
+ elsif klass == Date
516
+ to_date
517
+ elsif klass == DateTime
518
+ to_datetime
519
+ else
520
+ nil
521
+ end
522
+ end
523
+
524
+ def to_time
525
+ begin
526
+ if @data.offset * DayInSec == Time.now.utc_offset
527
+ d = @data
528
+ usec = (d.sec_fraction * DayInMicro).round
529
+ Time.local(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
530
+ else
531
+ d = @data.newof
532
+ usec = (d.sec_fraction * DayInMicro).round
533
+ Time.gm(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
534
+ end
535
+ rescue ArgumentError
536
+ nil
537
+ end
538
+ end
539
+
540
+ def to_date
541
+ Date.new!(@data.class.send(:jd_to_ajd, @data.jd, 0, 0), 0, @data.start)
542
+ end
543
+
544
+ def to_datetime
545
+ data
546
+ end
547
+
548
+ def tz2of(str)
549
+ /^(?:Z|(?:([+\-])(\d\d):(\d\d))?)$/ =~ str
550
+ sign = $1
551
+ hour = $2.to_i
552
+ min = $3.to_i
553
+
554
+ of = case sign
555
+ when '+'
556
+ of = +(hour.to_r * 60 + min) / 1440 # 24 * 60
557
+ when '-'
558
+ of = -(hour.to_r * 60 + min) / 1440 # 24 * 60
559
+ else
560
+ 0
561
+ end
562
+ of
563
+ end
564
+
565
+ def of2tz(offset)
566
+ diffmin = offset * 24 * 60
567
+ if diffmin.zero?
568
+ 'Z'
569
+ else
570
+ ((diffmin < 0) ? '-' : '+') << format('%02d:%02d',
571
+ (diffmin.abs / 60.0).to_i, (diffmin.abs % 60.0).to_i)
572
+ end
573
+ end
574
+
575
+ def screen_data(t)
576
+ # convert t to a DateTime as an internal representation.
577
+ if t.respond_to?(:to_datetime) # 1.9 or later
578
+ t.to_datetime
579
+ elsif t.is_a?(DateTime)
580
+ t
581
+ elsif t.is_a?(Date)
582
+ t = screen_data_str(t)
583
+ t <<= 12 if t.year < 0
584
+ t
585
+ elsif t.is_a?(Time)
586
+ jd = DateTime.civil_to_jd(t.year, t.mon, t.mday, DateTime::ITALY)
587
+ fr = DateTime.time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) +
588
+ t.usec.to_r / DayInMicro
589
+ of = t.utc_offset.to_r / DayInSec
590
+ DateTime.new!(DateTime.jd_to_ajd(jd, fr, of), of, DateTime::ITALY)
591
+ else
592
+ screen_data_str(t)
593
+ end
594
+ end
595
+
596
+ def add_tz(s)
597
+ s + of2tz(@data.offset)
598
+ end
599
+ end
600
+
601
+ class XSDDateTime < XSDAnySimpleType
602
+ include XSDDateTimeImpl
603
+ Type = QName.new(Namespace, DateTimeLiteral)
604
+
605
+ def initialize(value = nil)
606
+ init(Type, value)
607
+ end
608
+
609
+ private
610
+
611
+ def screen_data_str(t)
612
+ /^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
613
+ unless Regexp.last_match
614
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
615
+ end
616
+ if $1 == '0000'
617
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
618
+ end
619
+ year = $1.to_i
620
+ if year < 0
621
+ year += 1
622
+ end
623
+ mon = $2.to_i
624
+ mday = $3.to_i
625
+ hour = $4.to_i
626
+ min = $5.to_i
627
+ sec = $6.to_i
628
+ secfrac = $7
629
+ zonestr = $8
630
+ data = DateTime.civil(year, mon, mday, hour, min, sec, tz2of(zonestr))
631
+ if secfrac
632
+ diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / DayInSec
633
+ data += diffday
634
+ # FYI: new0 and jd_to_rjd are not necessary to use if you don't have
635
+ # exceptional reason.
636
+ end
637
+ [data, secfrac]
638
+ end
639
+
640
+ def _set(data)
641
+ if data.nil?
642
+ @data = @secfrac = nil
643
+ return
644
+ end
645
+ @data, @secfrac = data
646
+ end
647
+
648
+ def _to_s
649
+ year = (@data.year > 0) ? @data.year : @data.year - 1
650
+ s = format('%.4d-%02d-%02dT%02d:%02d:%02d',
651
+ year, @data.mon, @data.mday, @data.hour, @data.min, @data.sec)
652
+ if @data.sec_fraction.nonzero?
653
+ if @secfrac
654
+ s << ".#{ @secfrac }"
655
+ else
656
+ s << sprintf("%.16f",
657
+ (@data.sec_fraction * DayInSec).to_f).sub(/^0/, '').sub(/0*$/, '')
658
+ end
659
+ end
660
+ add_tz(s)
661
+ end
662
+ end
663
+
664
+ class XSDTime < XSDAnySimpleType
665
+ include XSDDateTimeImpl
666
+ Type = QName.new(Namespace, TimeLiteral)
667
+
668
+ def initialize(value = nil)
669
+ init(Type, value)
670
+ end
671
+
672
+ private
673
+
674
+ def screen_data_str(t)
675
+ /^(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
676
+ unless Regexp.last_match
677
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
678
+ end
679
+ hour = $1.to_i
680
+ min = $2.to_i
681
+ sec = $3.to_i
682
+ secfrac = $4
683
+ zonestr = $5
684
+ data = DateTime.civil(1, 1, 1, hour, min, sec, tz2of(zonestr))
685
+ if secfrac
686
+ diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / DayInSec
687
+ data += diffday
688
+ end
689
+ [data, secfrac]
690
+ end
691
+
692
+ def _set(data)
693
+ if data.nil?
694
+ @data = @secfrac = nil
695
+ return
696
+ end
697
+ @data, @secfrac = data
698
+ end
699
+
700
+ def _to_s
701
+ s = format('%02d:%02d:%02d', @data.hour, @data.min, @data.sec)
702
+ if @data.sec_fraction.nonzero?
703
+ if @secfrac
704
+ s << ".#{ @secfrac }"
705
+ else
706
+ s << sprintf("%.16f",
707
+ (@data.sec_fraction * DayInSec).to_f).sub(/^0/, '').sub(/0*$/, '')
708
+ end
709
+ end
710
+ add_tz(s)
711
+ end
712
+ end
713
+
714
+ class XSDDate < XSDAnySimpleType
715
+ include XSDDateTimeImpl
716
+ Type = QName.new(Namespace, DateLiteral)
717
+
718
+ def initialize(value = nil)
719
+ init(Type, value)
720
+ end
721
+
722
+ private
723
+
724
+ def screen_data_str(t)
725
+ /^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
726
+ unless Regexp.last_match
727
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
728
+ end
729
+ year = $1.to_i
730
+ if year < 0
731
+ year += 1
732
+ end
733
+ mon = $2.to_i
734
+ mday = $3.to_i
735
+ zonestr = $4
736
+ DateTime.civil(year, mon, mday, 0, 0, 0, tz2of(zonestr))
737
+ end
738
+
739
+ def _to_s
740
+ year = (@data.year > 0) ? @data.year : @data.year - 1
741
+ s = format('%.4d-%02d-%02d', year, @data.mon, @data.mday)
742
+ add_tz(s)
743
+ end
744
+ end
745
+
746
+ class XSDGYearMonth < XSDAnySimpleType
747
+ include XSDDateTimeImpl
748
+ Type = QName.new(Namespace, GYearMonthLiteral)
749
+
750
+ def initialize(value = nil)
751
+ init(Type, value)
752
+ end
753
+
754
+ private
755
+
756
+ def screen_data_str(t)
757
+ /^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
758
+ unless Regexp.last_match
759
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
760
+ end
761
+ year = $1.to_i
762
+ if year < 0
763
+ year += 1
764
+ end
765
+ mon = $2.to_i
766
+ zonestr = $3
767
+ DateTime.civil(year, mon, 1, 0, 0, 0, tz2of(zonestr))
768
+ end
769
+
770
+ def _to_s
771
+ year = (@data.year > 0) ? @data.year : @data.year - 1
772
+ s = format('%.4d-%02d', year, @data.mon)
773
+ add_tz(s)
774
+ end
775
+ end
776
+
777
+ class XSDGYear < XSDAnySimpleType
778
+ include XSDDateTimeImpl
779
+ Type = QName.new(Namespace, GYearLiteral)
780
+
781
+ def initialize(value = nil)
782
+ init(Type, value)
783
+ end
784
+
785
+ private
786
+
787
+ def screen_data_str(t)
788
+ /^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
789
+ unless Regexp.last_match
790
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
791
+ end
792
+ year = $1.to_i
793
+ if year < 0
794
+ year += 1
795
+ end
796
+ zonestr = $2
797
+ DateTime.civil(year, 1, 1, 0, 0, 0, tz2of(zonestr))
798
+ end
799
+
800
+ def _to_s
801
+ year = (@data.year > 0) ? @data.year : @data.year - 1
802
+ s = format('%.4d', year)
803
+ add_tz(s)
804
+ end
805
+ end
806
+
807
+ class XSDGMonthDay < XSDAnySimpleType
808
+ include XSDDateTimeImpl
809
+ Type = QName.new(Namespace, GMonthDayLiteral)
810
+
811
+ def initialize(value = nil)
812
+ init(Type, value)
813
+ end
814
+
815
+ private
816
+
817
+ def screen_data_str(t)
818
+ /^--(\d\d)-(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
819
+ unless Regexp.last_match
820
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
821
+ end
822
+ mon = $1.to_i
823
+ mday = $2.to_i
824
+ zonestr = $3
825
+ DateTime.civil(1, mon, mday, 0, 0, 0, tz2of(zonestr))
826
+ end
827
+
828
+ def _to_s
829
+ s = format('--%02d-%02d', @data.mon, @data.mday)
830
+ add_tz(s)
831
+ end
832
+ end
833
+
834
+ class XSDGDay < XSDAnySimpleType
835
+ include XSDDateTimeImpl
836
+ Type = QName.new(Namespace, GDayLiteral)
837
+
838
+ def initialize(value = nil)
839
+ init(Type, value)
840
+ end
841
+
842
+ private
843
+
844
+ def screen_data_str(t)
845
+ /^---(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
846
+ unless Regexp.last_match
847
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
848
+ end
849
+ mday = $1.to_i
850
+ zonestr = $2
851
+ DateTime.civil(1, 1, mday, 0, 0, 0, tz2of(zonestr))
852
+ end
853
+
854
+ def _to_s
855
+ s = format('---%02d', @data.mday)
856
+ add_tz(s)
857
+ end
858
+ end
859
+
860
+ class XSDGMonth < XSDAnySimpleType
861
+ include XSDDateTimeImpl
862
+ Type = QName.new(Namespace, GMonthLiteral)
863
+
864
+ def initialize(value = nil)
865
+ init(Type, value)
866
+ end
867
+
868
+ private
869
+
870
+ def screen_data_str(t)
871
+ /^--(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
872
+ unless Regexp.last_match
873
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
874
+ end
875
+ mon = $1.to_i
876
+ zonestr = $2
877
+ DateTime.civil(1, mon, 1, 0, 0, 0, tz2of(zonestr))
878
+ end
879
+
880
+ def _to_s
881
+ s = format('--%02d', @data.mon)
882
+ add_tz(s)
883
+ end
884
+ end
885
+
886
+ class XSDHexBinary < XSDAnySimpleType
887
+ Type = QName.new(Namespace, HexBinaryLiteral)
888
+
889
+ # String in Ruby could be a binary.
890
+ def initialize(value = nil)
891
+ init(Type, value)
892
+ end
893
+
894
+ def set_encoded(value)
895
+ if /^[0-9a-fA-F]*$/ !~ value
896
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
897
+ end
898
+ @data = String.new(value).strip
899
+ @is_nil = false
900
+ end
901
+
902
+ def string
903
+ [@data].pack("H*")
904
+ end
905
+
906
+ private
907
+
908
+ def screen_data(value)
909
+ value.unpack("H*")[0].tr('a-f', 'A-F')
910
+ end
911
+ end
912
+
913
+ class XSDBase64Binary < XSDAnySimpleType
914
+ Type = QName.new(Namespace, Base64BinaryLiteral)
915
+
916
+ # String in Ruby could be a binary.
917
+ def initialize(value = nil)
918
+ init(Type, value)
919
+ end
920
+
921
+ def set_encoded(value)
922
+ if /^[A-Za-z0-9+\/=]*$/ !~ value
923
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
924
+ end
925
+ @data = String.new(value).strip
926
+ @is_nil = false
927
+ end
928
+
929
+ def string
930
+ @data.unpack("m")[0]
931
+ end
932
+
933
+ private
934
+
935
+ def screen_data(value)
936
+ [value].pack("m").strip
937
+ end
938
+ end
939
+
940
+ class XSDAnyURI < XSDAnySimpleType
941
+ Type = QName.new(Namespace, AnyURILiteral)
942
+
943
+ def initialize(value = nil)
944
+ init(Type, value)
945
+ end
946
+
947
+ private
948
+
949
+ def screen_data(value)
950
+ begin
951
+ URI.parse(value.to_s.strip)
952
+ rescue URI::InvalidURIError
953
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.", $!)
954
+ end
955
+ end
956
+ end
957
+
958
+ class XSDQName < XSDAnySimpleType
959
+ Type = QName.new(Namespace, QNameLiteral)
960
+
961
+ def initialize(value = nil)
962
+ init(Type, value)
963
+ end
964
+
965
+ private
966
+
967
+ def screen_data(value)
968
+ /^(?:([^:]+):)?([^:]+)$/ =~ value.to_s.strip
969
+ unless Regexp.last_match
970
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
971
+ end
972
+ prefix = $1
973
+ localpart = $2
974
+ [prefix, localpart]
975
+ end
976
+
977
+ def _set(data)
978
+ if data.nil?
979
+ @prefix = @localpart = @data = nil
980
+ return
981
+ end
982
+ @prefix, @localpart = data
983
+ @data = _to_s
984
+ @data.freeze
985
+ end
986
+
987
+ def _to_s
988
+ if @prefix
989
+ "#{ @prefix }:#{ @localpart }"
990
+ else
991
+ "#{ @localpart }"
992
+ end
993
+ end
994
+ end
995
+
996
+
997
+ ###
998
+ ## Derived types
999
+ #
1000
+ class XSDNormalizedString < XSDString
1001
+ Type = QName.new(Namespace, NormalizedStringLiteral)
1002
+
1003
+ def initialize(value = nil)
1004
+ init(Type, value)
1005
+ end
1006
+
1007
+ private
1008
+
1009
+ def screen_data(value)
1010
+ super
1011
+ if /[\t\r\n]/ =~ value
1012
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
1013
+ end
1014
+ value
1015
+ end
1016
+ end
1017
+
1018
+ class XSDToken < XSDNormalizedString
1019
+ Type = QName.new(Namespace, TokenLiteral)
1020
+
1021
+ def initialize(value = nil)
1022
+ init(Type, value)
1023
+ end
1024
+
1025
+ private
1026
+
1027
+ def screen_data(value)
1028
+ super
1029
+ if /\A / =~ value or / \Z/ =~ value or value.index(' ')
1030
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
1031
+ end
1032
+ value
1033
+ end
1034
+ end
1035
+
1036
+ class XSDLanguage < XSDToken
1037
+ Type = QName.new(Namespace, LanguageLiteral)
1038
+
1039
+ def initialize(value = nil)
1040
+ init(Type, value)
1041
+ end
1042
+
1043
+ private
1044
+
1045
+ def screen_data(value)
1046
+ super
1047
+ # RFC 3066 syntax check
1048
+ if /\A[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})?\z/ !~ value
1049
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
1050
+ end
1051
+ value
1052
+ end
1053
+ end
1054
+
1055
+ class XSDNMTOKEN < XSDToken
1056
+ Type = QName.new(Namespace, NMTOKENLiteral)
1057
+
1058
+ def initialize(value = nil)
1059
+ init(Type, value)
1060
+ end
1061
+
1062
+ private
1063
+
1064
+ def screen_data(value)
1065
+ super
1066
+ # TODO: check lexical space and convert to a value
1067
+ value
1068
+ end
1069
+ end
1070
+
1071
+ class XSDNMTOKENS < XSDNMTOKEN
1072
+ Type = QName.new(Namespace, NMTOKENSLiteral)
1073
+
1074
+ def initialize(value = nil)
1075
+ init(Type, value)
1076
+ end
1077
+
1078
+ private
1079
+
1080
+ def screen_data(value)
1081
+ # derived by list
1082
+ # TODO: check lexical space and convert to a value
1083
+ value
1084
+ end
1085
+ end
1086
+
1087
+ class XSDName < XSDToken
1088
+ Type = QName.new(Namespace, NameLiteral)
1089
+
1090
+ def initialize(value = nil)
1091
+ init(Type, value)
1092
+ end
1093
+
1094
+ private
1095
+
1096
+ def screen_data(value)
1097
+ super
1098
+ # TODO: check lexical space and convert to a value
1099
+ value
1100
+ end
1101
+ end
1102
+
1103
+ class XSDNCName < XSDName
1104
+ Type = QName.new(Namespace, NCNameLiteral)
1105
+
1106
+ def initialize(value = nil)
1107
+ init(Type, value)
1108
+ end
1109
+
1110
+ private
1111
+
1112
+ def screen_data(value)
1113
+ super
1114
+ # TODO: check lexical space and convert to a value
1115
+ value
1116
+ end
1117
+ end
1118
+
1119
+ class XSDID < XSDNCName
1120
+ Type = QName.new(Namespace, IDLiteral)
1121
+
1122
+ def initialize(value = nil)
1123
+ init(Type, value)
1124
+ end
1125
+
1126
+ private
1127
+
1128
+ def screen_data(value)
1129
+ super
1130
+ # TODO: check lexical space and convert to a value
1131
+ value
1132
+ end
1133
+ end
1134
+
1135
+ class XSDIDREF < XSDNCName
1136
+ Type = QName.new(Namespace, IDREFLiteral)
1137
+
1138
+ def initialize(value = nil)
1139
+ init(Type, value)
1140
+ end
1141
+
1142
+ private
1143
+
1144
+ def screen_data(value)
1145
+ super
1146
+ # TODO: check lexical space and convert to a value
1147
+ value
1148
+ end
1149
+ end
1150
+
1151
+ class XSDIDREFS < XSDIDREF
1152
+ Type = QName.new(Namespace, IDREFSLiteral)
1153
+
1154
+ def initialize(value = nil)
1155
+ init(Type, value)
1156
+ end
1157
+
1158
+ private
1159
+
1160
+ def screen_data(value)
1161
+ # derived by list
1162
+ # TODO: check lexical space and convert to a value
1163
+ value
1164
+ end
1165
+ end
1166
+
1167
+ class XSDENTITY < XSDNCName
1168
+ Type = QName.new(Namespace, ENTITYLiteral)
1169
+
1170
+ def initialize(value = nil)
1171
+ init(Type, value)
1172
+ end
1173
+
1174
+ private
1175
+
1176
+ def screen_data(value)
1177
+ super
1178
+ # TODO: check lexical space and convert to a value
1179
+ value
1180
+ end
1181
+ end
1182
+
1183
+ class XSDENTITIES < XSDENTITY
1184
+ Type = QName.new(Namespace, ENTITIESLiteral)
1185
+
1186
+ def initialize(value = nil)
1187
+ init(Type, value)
1188
+ end
1189
+
1190
+ private
1191
+
1192
+ def screen_data(value)
1193
+ # derived by list
1194
+ # TODO: check lexical space and convert to a value
1195
+ value
1196
+ end
1197
+ end
1198
+
1199
+ class XSDInteger < XSDDecimal
1200
+ Type = QName.new(Namespace, IntegerLiteral)
1201
+
1202
+ def initialize(value = nil)
1203
+ init(Type, value)
1204
+ end
1205
+
1206
+ private
1207
+
1208
+ def screen_data_str(str)
1209
+ begin
1210
+ data = Integer(str)
1211
+ rescue ArgumentError
1212
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.", $!)
1213
+ end
1214
+ unless validate(data)
1215
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
1216
+ end
1217
+ data
1218
+ end
1219
+
1220
+ def _set(value)
1221
+ @data = value
1222
+ end
1223
+
1224
+ def _to_s()
1225
+ @data.to_s
1226
+ end
1227
+
1228
+ def validate(v)
1229
+ max = maxinclusive
1230
+ min = mininclusive
1231
+ (max.nil? or v <= max) and (min.nil? or v >= min)
1232
+ end
1233
+
1234
+ def maxinclusive
1235
+ nil
1236
+ end
1237
+
1238
+ def mininclusive
1239
+ nil
1240
+ end
1241
+
1242
+ PositiveMinInclusive = 1
1243
+ def positive(v)
1244
+ PositiveMinInclusive <= v
1245
+ end
1246
+ end
1247
+
1248
+ class XSDNonPositiveInteger < XSDInteger
1249
+ Type = QName.new(Namespace, NonPositiveIntegerLiteral)
1250
+
1251
+ def initialize(value = nil)
1252
+ init(Type, value)
1253
+ end
1254
+
1255
+ private
1256
+
1257
+ def maxinclusive
1258
+ 0
1259
+ end
1260
+
1261
+ def mininclusive
1262
+ nil
1263
+ end
1264
+ end
1265
+
1266
+ class XSDNegativeInteger < XSDNonPositiveInteger
1267
+ Type = QName.new(Namespace, NegativeIntegerLiteral)
1268
+
1269
+ def initialize(value = nil)
1270
+ init(Type, value)
1271
+ end
1272
+
1273
+ private
1274
+
1275
+ def maxinclusive
1276
+ -1
1277
+ end
1278
+
1279
+ def mininclusive
1280
+ nil
1281
+ end
1282
+ end
1283
+
1284
+ class XSDLong < XSDInteger
1285
+ Type = QName.new(Namespace, LongLiteral)
1286
+
1287
+ def initialize(value = nil)
1288
+ init(Type, value)
1289
+ end
1290
+
1291
+ private
1292
+
1293
+ def maxinclusive
1294
+ +9223372036854775807
1295
+ end
1296
+
1297
+ def mininclusive
1298
+ -9223372036854775808
1299
+ end
1300
+ end
1301
+
1302
+ class XSDInt < XSDLong
1303
+ Type = QName.new(Namespace, IntLiteral)
1304
+
1305
+ def initialize(value = nil)
1306
+ init(Type, value)
1307
+ end
1308
+
1309
+ private
1310
+
1311
+ def maxinclusive
1312
+ +2147483647
1313
+ end
1314
+
1315
+ def mininclusive
1316
+ -2147483648
1317
+ end
1318
+ end
1319
+
1320
+ class XSDShort < XSDInt
1321
+ Type = QName.new(Namespace, ShortLiteral)
1322
+
1323
+ def initialize(value = nil)
1324
+ init(Type, value)
1325
+ end
1326
+
1327
+ private
1328
+
1329
+ def maxinclusive
1330
+ +32767
1331
+ end
1332
+
1333
+ def mininclusive
1334
+ -32768
1335
+ end
1336
+ end
1337
+
1338
+ class XSDByte < XSDShort
1339
+ Type = QName.new(Namespace, ByteLiteral)
1340
+
1341
+ def initialize(value = nil)
1342
+ init(Type, value)
1343
+ end
1344
+
1345
+ private
1346
+
1347
+ def maxinclusive
1348
+ +127
1349
+ end
1350
+
1351
+ def mininclusive
1352
+ -128
1353
+ end
1354
+ end
1355
+
1356
+ class XSDNonNegativeInteger < XSDInteger
1357
+ Type = QName.new(Namespace, NonNegativeIntegerLiteral)
1358
+
1359
+ def initialize(value = nil)
1360
+ init(Type, value)
1361
+ end
1362
+
1363
+ private
1364
+
1365
+ def maxinclusive
1366
+ nil
1367
+ end
1368
+
1369
+ def mininclusive
1370
+ 0
1371
+ end
1372
+ end
1373
+
1374
+ class XSDUnsignedLong < XSDNonNegativeInteger
1375
+ Type = QName.new(Namespace, UnsignedLongLiteral)
1376
+
1377
+ def initialize(value = nil)
1378
+ init(Type, value)
1379
+ end
1380
+
1381
+ private
1382
+
1383
+ def maxinclusive
1384
+ +18446744073709551615
1385
+ end
1386
+
1387
+ def mininclusive
1388
+ 0
1389
+ end
1390
+ end
1391
+
1392
+ class XSDUnsignedInt < XSDUnsignedLong
1393
+ Type = QName.new(Namespace, UnsignedIntLiteral)
1394
+
1395
+ def initialize(value = nil)
1396
+ init(Type, value)
1397
+ end
1398
+
1399
+ private
1400
+
1401
+ def maxinclusive
1402
+ +4294967295
1403
+ end
1404
+
1405
+ def mininclusive
1406
+ 0
1407
+ end
1408
+ end
1409
+
1410
+ class XSDUnsignedShort < XSDUnsignedInt
1411
+ Type = QName.new(Namespace, UnsignedShortLiteral)
1412
+
1413
+ def initialize(value = nil)
1414
+ init(Type, value)
1415
+ end
1416
+
1417
+ private
1418
+
1419
+ def maxinclusive
1420
+ +65535
1421
+ end
1422
+
1423
+ def mininclusive
1424
+ 0
1425
+ end
1426
+ end
1427
+
1428
+ class XSDUnsignedByte < XSDUnsignedShort
1429
+ Type = QName.new(Namespace, UnsignedByteLiteral)
1430
+
1431
+ def initialize(value = nil)
1432
+ init(Type, value)
1433
+ end
1434
+
1435
+ private
1436
+
1437
+ def maxinclusive
1438
+ +255
1439
+ end
1440
+
1441
+ def mininclusive
1442
+ 0
1443
+ end
1444
+ end
1445
+
1446
+ class XSDPositiveInteger < XSDNonNegativeInteger
1447
+ Type = QName.new(Namespace, PositiveIntegerLiteral)
1448
+
1449
+ def initialize(value = nil)
1450
+ init(Type, value)
1451
+ end
1452
+
1453
+ private
1454
+
1455
+ def maxinclusive
1456
+ nil
1457
+ end
1458
+
1459
+ def mininclusive
1460
+ 1
1461
+ end
1462
+ end
1463
+
1464
+
1465
+ end