You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-dev@ws.apache.org by as...@apache.org on 2005/08/10 13:39:43 UTC
cvs commit: ws-wsif/java/src/org/apache/wsif/schema ElementType.java
aslom 2005/08/10 04:39:43
Modified: java/src/org/apache/wsif/schema ElementType.java
Log:
applied patch "schema parsing incorrect/incomplete for <element>"
http://issues.apache.org/jira/browse/WSIF-68
reported by Jeff Greif (thanks!)
Revision Changes Path
1.8 +73 -66 ws-wsif/java/src/org/apache/wsif/schema/ElementType.java
Index: ElementType.java
===================================================================
RCS file: /home/cvs/ws-wsif/java/src/org/apache/wsif/schema/ElementType.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ElementType.java 1 Mar 2004 23:53:18 -0000 1.7
+++ ElementType.java 10 Aug 2005 11:39:43 -0000 1.8
@@ -1,12 +1,12 @@
/*
* Copyright 2002-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,83 +35,90 @@
/**
* A class to represent a top level <element> element in a schema
- *
+ *
* @author Owen Burroughs <ow...@apache.org>
*/
public class ElementType extends SchemaType implements Serializable {
-
- static final long serialVersionUID = 1L;
-
- private String name = "";
- private QName typeName = null;
- private QName elementType = null;
- private List childTypes = new ArrayList();
- private boolean nillable = false;
-
- /**
- * Constructor
- * @param el The dom element for this element
- */
+
+ static final long serialVersionUID = 1L;
+
+ private String name = "";
+ private QName typeName = null;
+ private QName elementType = null;
+ private List childTypes = new ArrayList();
+ private boolean nillable = false;
+
+ /**
+ * Constructor
+ * @param el The dom element for this element
+ */
ElementType(Element el, String tns) {
- elementType = getAttributeQName(el, "type", tns);
+ // jgreif Webalo, Inc. -- incorrect to use tns as default namespace
+ // for type or ref attribute value !
+ //elementType = getAttributeQName(el, "type", tns);
+ elementType = getAttributeQName(el, "type");
typeName = getAttributeQName(el, "name", tns);
+ // jgreif Webalo, Inc. -- ref attr may appear rather than name attr
+ if (typeName == null) {
+ typeName = getAttributeQName(el, "ref");
+ }
QName nillableAttr = getAttributeQName(el, "nillable", null);
String stTrue = "true";
if (nillableAttr != null && stTrue.equals(nillableAttr.getLocalPart())) {
- nillable = true;
+ nillable = true;
}
// If the element has no name, we cannot map it. Don't do any more processing
// of this type
if (typeName == null) return;
-
+
name = typeName.getLocalPart();
- NodeList children = el.getChildNodes();
- for (int i=0; i<children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- Element subEl = (Element) child;
- String elType = subEl.getLocalName();
- if (elType.equals("complexType")) {
- childTypes.add(new ComplexType(subEl, tns));
- } else if (elType.equals("simpleType")) {
- childTypes.add(new SimpleType(subEl, tns));
- } else if (elType.equals("element")) {
- childTypes.add(new ElementType(subEl, tns));
- } else {
- //ignore all other types
- }
- }
- }
+ NodeList children = el.getChildNodes();
+ for (int i=0; i<children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element subEl = (Element) child;
+ String elType = subEl.getLocalName();
+ if (elType.equals("complexType")) {
+ childTypes.add(new ComplexType(subEl, tns));
+ } else if (elType.equals("simpleType")) {
+ childTypes.add(new SimpleType(subEl, tns));
+ } else if (elType.equals("element")) {
+ childTypes.add(new ElementType(subEl, tns));
+ } else {
+ //ignore all other types
+ }
+ }
+ }
+ }
+
+ /**
+ * @see SchemaType#isElement()
+ */
+ public boolean isElement() {
+ return true;
+ }
+
+ /**
+ * @see SchemaType#getTypeName()
+ */
+ public QName getTypeName() {
+ return typeName;
+ }
+
+ public QName getElementType() {
+ return elementType;
+ }
+
+ public boolean isNillable() {
+ return nillable;
+ }
+
+ /**
+ * @see SchemaType#getChildren()
+ */
+ public List getChildren() {
+ return childTypes;
}
-
- /**
- * @see SchemaType#isElement()
- */
- public boolean isElement() {
- return true;
- }
-
- /**
- * @see SchemaType#getTypeName()
- */
- public QName getTypeName() {
- return typeName;
- }
-
- public QName getElementType() {
- return elementType;
- }
-
- public boolean isNillable() {
- return nillable;
- }
-
- /**
- * @see SchemaType#getChildren()
- */
- public List getChildren() {
- return childTypes;
- }
}