Line | |
---|
1 | # WSDL4R - XMLSchema simpleContent definition for WSDL.
|
---|
2 | # Copyright (C) 2004, 2005 NAKAMURA, Hiroshi <[email protected]>.
|
---|
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 'wsdl/info'
|
---|
10 | require 'xsd/namedelements'
|
---|
11 |
|
---|
12 |
|
---|
13 | module WSDL
|
---|
14 | module XMLSchema
|
---|
15 |
|
---|
16 |
|
---|
17 | class SimpleContent < Info
|
---|
18 | attr_reader :restriction
|
---|
19 | attr_reader :extension
|
---|
20 |
|
---|
21 | def check_lexical_format(value)
|
---|
22 | check(value)
|
---|
23 | end
|
---|
24 |
|
---|
25 | def initialize
|
---|
26 | super
|
---|
27 | @restriction = nil
|
---|
28 | @extension = nil
|
---|
29 | end
|
---|
30 |
|
---|
31 | def base
|
---|
32 | content.base
|
---|
33 | end
|
---|
34 |
|
---|
35 | def targetnamespace
|
---|
36 | parent.targetnamespace
|
---|
37 | end
|
---|
38 |
|
---|
39 | def parse_element(element)
|
---|
40 | case element
|
---|
41 | when RestrictionName
|
---|
42 | @restriction = SimpleRestriction.new
|
---|
43 | @restriction
|
---|
44 | when ExtensionName
|
---|
45 | @extension = SimpleExtension.new
|
---|
46 | @extension
|
---|
47 | end
|
---|
48 | end
|
---|
49 |
|
---|
50 | private
|
---|
51 |
|
---|
52 | def content
|
---|
53 | @restriction || @extension
|
---|
54 | end
|
---|
55 |
|
---|
56 | def check(value)
|
---|
57 | unless content.valid?(value)
|
---|
58 | raise XSD::ValueSpaceError.new("#{@name}: cannot accept '#{value}'")
|
---|
59 | end
|
---|
60 | end
|
---|
61 | end
|
---|
62 |
|
---|
63 |
|
---|
64 | end
|
---|
65 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.