Permalink
Browse files

Merge pull request #51 from tonyskn/support_for_enumeration

Add support for enumeration restrictions on <xsd:simpleType...>
  • Loading branch information...
2 parents 1f70a94 + f59001c commit cf7a6a18764957fdbf0cbd1a7e63f2c68b68e485 @milewise milewise committed May 8, 2012
Showing with 26 additions and 1 deletion.
  1. +26 −1 lib/wsdl.js
View
@@ -134,6 +134,8 @@ var ElementElement = Element.createSubClass();
var InputElement = Element.createSubClass();
var OutputElement = Element.createSubClass();
var SimpleTypeElement = Element.createSubClass();
+var RestrictionElement = Element.createSubClass();
+var EnumerationElement = Element.createSubClass();
var ComplexTypeElement = Element.createSubClass();
var SequenceElement = Element.createSubClass();
var AllElement = Element.createSubClass();
@@ -152,7 +154,9 @@ var ElementTypeMap = {
types: [TypesElement, 'schema'],
schema: [SchemaElement, 'element complexType simpleType include import'],
element: [ElementElement, 'annotation complexType'],
- simpleType: [SimpleTypeElement, ''],
+ simpleType: [SimpleTypeElement, 'restriction'],
+ restriction: [RestrictionElement, 'enumeration'],
+ enumeration: [EnumerationElement, ''],
complexType: [ComplexTypeElement, 'annotation sequence all'],
sequence: [SequenceElement, 'element'],
all: [AllElement, 'element'],
@@ -439,6 +443,25 @@ ServiceElement.prototype.postProcess = function(definitions) {
this.deleteFixedAttrs();
}
+SimpleTypeElement.prototype.description = function(definitions) {
+ var children = this.children;
+ for (var i=0, child; child=children[i]; i++) {
+ if (child instanceof RestrictionElement)
+ return this.$name+"|"+child.description();
+ }
+ return {};
+}
+
+RestrictionElement.prototype.description = function() {
+ var base = this.$base ? this.$base+"|" : "";
+ return base + this.children.map( function(child) {
+ return child.description();
+ } ).join(",");
+}
+
+EnumerationElement.prototype.description = function() {
+ return this.$value;
+}
ComplexTypeElement.prototype.description = function(definitions) {
var children = this.children;
@@ -952,3 +975,5 @@ function open_wsdl(uri, options, callback) {
exports.open_wsdl = open_wsdl;
exports.WSDL = WSDL;
+
+

0 comments on commit cf7a6a1

Please sign in to comment.