You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by di...@apache.org on 2006/06/21 04:07:00 UTC
svn commit: r415873 - in /webservices/commons/trunk/modules/XmlSchema:
src/org/apache/ws/commons/schema/SchemaBuilder.java
test-resources/constraints.xsd test-resources/notation.xsd
test/tests/ConstraintsTest.java test/tests/NotationTest.java
Author: dims
Date: Tue Jun 20 19:06:59 2006
New Revision: 415873
URL: http://svn.apache.org/viewvc?rev=415873&view=rev
Log:
Fix for WSCOMMONS-37 - SchemaBuilder needs support for notation
Fix for WSCOMMONS-36 - SchemaBuilder.java not setting constraints in handleElement method
Added:
webservices/commons/trunk/modules/XmlSchema/test-resources/constraints.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/notation.xsd
webservices/commons/trunk/modules/XmlSchema/test/tests/ConstraintsTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/NotationTest.java
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java?rev=415873&r1=415872&r2=415873&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java Tue Jun 20 19:06:59 2006
@@ -1,5 +1,6 @@
/*
* Copyright 2004,2005 The Apache Software Foundation.
+ * Portions Copyright 2006 International Business Machines Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -150,7 +151,9 @@
el, schemaEl);
schema.includes.add(redefine);
} else if (el.getLocalName().equals("notation")) {
- //TODO: implement Notation
+ XmlSchemaNotation notation = handleNotation(schema, el, schemaEl);
+ schema.notations.collection.put(notation.name, notation);
+ schema.items.add(notation);
} else if (el.getLocalName().equals("annotation")) {
// Vidyanand : added this part
XmlSchemaAnnotation annotation = handleAnnotation(schema, el, schemaEl);
@@ -178,6 +181,39 @@
return annotation;
}
+ private XmlSchemaNotation handleNotation(XmlSchema schema,
+ Element notationEl,
+ Element schemaEl) {
+
+ XmlSchemaNotation notation = new XmlSchemaNotation();
+
+ if (notationEl.hasAttribute("id")) {
+ notation.id = notationEl.getAttribute("id");
+ }
+
+ if (notationEl.hasAttribute("name")) {
+ notation.name = notationEl.getAttribute("name");
+ }
+
+ if (notationEl.hasAttribute("public")) {
+ notation.publicNotation = notationEl.getAttribute("public");
+ }
+
+ if (notationEl.hasAttribute("system")) {
+ notation.system = notationEl.getAttribute("system");
+ }
+
+ Element annotationEl =
+ XDOMUtil.getFirstChildElementNS(notationEl,
+ XmlSchema.SCHEMA_NS, "annotation");
+
+ if (annotationEl != null) {
+ XmlSchemaAnnotation annotation = handleAnnotation(annotationEl);
+ notation.setAnnotation(annotation);
+ }
+
+ return notation;
+ }
private XmlSchemaRedefine handleRedefine(XmlSchema schema,
Element redefineEl, Element schemaEl) {
@@ -1522,13 +1558,17 @@
handleComplexType(schema, complexTypeEl, schemaEl);
element.schemaType = complexType;
- } else if ((keyEl =
+ }
+
+ if ((keyEl =
XDOMUtil.getFirstChildElementNS(el, XmlSchema.SCHEMA_NS, "key")) != null) {
XmlSchemaIdentityConstraint key =
handleConstraint(schema, keyEl, schemaEl, "Key");
element.constraints.add(key);
- } else if ((keyrefEl = XDOMUtil.getFirstChildElementNS(el, XmlSchema.SCHEMA_NS, "keyref")) != null) {
+ }
+
+ if ((keyrefEl = XDOMUtil.getFirstChildElementNS(el, XmlSchema.SCHEMA_NS, "keyref")) != null) {
XmlSchemaKeyref keyRef =
(XmlSchemaKeyref) handleConstraint(schema, keyrefEl,
@@ -1551,7 +1591,9 @@
element.constraints.add(keyRef);
- } else if ((uniqueEl =
+ }
+
+ if ((uniqueEl =
XDOMUtil.getFirstChildElementNS(el,
XmlSchema.SCHEMA_NS, "unique")) != null) {
@@ -1647,7 +1689,6 @@
namespace = schema.targetNamespace;
name = Tokenizer.lastToken(name, ":")[1];
- constraint.name = name; // need to confirm as it is not name but refer
((XmlSchemaKeyref) constraint).refer =
new QName(namespace, name);
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/constraints.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/constraints.xsd?rev=415873&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/constraints.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/constraints.xsd Tue Jun 20 19:06:59 2006
@@ -0,0 +1,86 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Brent Ulbricht
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types"
+ elementFormDefault="qualified">
+
+ <element name="constraintTest">
+ <complexType>
+ <sequence>
+ <element name="manufacturers" type="tns:ManufacturerType"/>
+ <element name="products" type="tns:ProductType"/>
+ </sequence>
+ </complexType>
+
+ <unique name="uniqueTest">
+ <selector xpath="tns:manufacturers/tns:location"/>
+ <field xpath="@district"/>
+ </unique>
+
+ <key name="keyTest">
+ <selector xpath="tns:products/tns:productName"/>
+ <field xpath="@productId"/>
+ </key>
+
+ <keyref name="keyRefTest" refer="tns:keyTest">
+ <selector xpath="tns:manufacturers/tns:location/tns:productName"/>
+ <field xpath="@productId"/>
+ </keyref>
+
+ </element>
+
+ <complexType name="ManufacturerType">
+ <sequence>
+ <element name="location" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" maxOccurs="unbounded">
+ <complexType>
+ <complexContent>
+ <extension base="string">
+ <attribute name="productId" type="integer"/>
+ <attribute name="units" type="integer"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ </element>
+ </sequence>
+ <attribute name="district" type="integer"/>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <complexType name="ProductType">
+ <sequence>
+ <element name="productName" maxOccurs="unbounded">
+ <complexType>
+ <simpleContent>
+ <extension base="string">
+ <attribute name="productId" type="integer"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/notation.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/notation.xsd?rev=415873&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/notation.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/notation.xsd Tue Jun 20 19:06:59 2006
@@ -0,0 +1,51 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Brent Ulbricht
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <notation name="teamLogo"
+ system="com/team/graphics/teamLogo"
+ public="http://www.team.com/graphics/teamLogo"
+ id="notation.teamLogo">
+ <annotation>
+ <documentation xml:lang="en">Location of the corporate logo.</documentation>
+ </annotation>
+ </notation>
+
+ <notation name="teamMascot"
+ system="com/team/graphics/teamMascot"
+ public="http://www.team.com/graphics/teamMascot"
+ id="notation.teamMascot">
+ <annotation>
+ <documentation xml:lang="en">Location of the corporate mascot.</documentation>
+ </annotation>
+ </notation>
+
+ <element name="demoNotation">
+ <simpleType>
+ <restriction base="NOTATION">
+ <enumeration value="tns:teamLogo"/>
+ <enumeration value="tns:teamMascot"/>
+ </restriction>
+ </simpleType>
+ </element>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/ConstraintsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/ConstraintsTest.java?rev=415873&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/ConstraintsTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/ConstraintsTest.java Tue Jun 20 19:06:59 2006
@@ -0,0 +1,212 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaKey;
+import org.apache.ws.commons.schema.XmlSchemaKeyref;
+import org.apache.ws.commons.schema.XmlSchemaUnique;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaXPath;
+import org.apache.ws.commons.schema.XmlSchemaUnique;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Brent Ulbricht
+ */
+public class ConstraintsTest extends TestCase {
+
+ /**
+ * This method will test the unique, key, and
+ * keyref constaints.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testConstraints() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types"
+ elementFormDefault="qualified">
+
+ <element name="constraintTest">
+ <complexType>
+ <sequence>
+ <element name="manufacturers" type="tns:ManufacturerType"/>
+ <element name="products" type="tns:ProductType"/>
+ </sequence>
+ </complexType>
+
+ <unique name="uniqueTest">
+ <selector xpath="tns:manufacturers/tns:location"/>
+ <field xpath="@district"/>
+ </unique>
+
+ <key name="keyTest">
+ <selector xpath="tns:products/tns:productName"/>
+ <field xpath="@productId"/>
+ </key>
+
+ <keyref name="keyRefTest" refer="tns:keyTest">
+ <selector xpath="tns:manufacturers/tns:location/tns:productName"/>
+ <field xpath="@productId"/>
+ </keyref>
+
+ </element>
+
+ <complexType name="ManufacturerType">
+ <sequence>
+ <element name="location" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" maxOccurs="unbounded"/>
+ <complexType>
+ <complexContent>
+ <extension base="string">
+ <attribute name="productId" type="integer"/>
+ <attribute name="units" type="integer"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ </element>
+ </sequence>
+ <attribute name="district" type="integer"/>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <complexType name="ProductType">
+ <sequence>
+ <element name="productName" maxOccurs="unbounded">
+ <complexType>
+ <simpleContent>
+ <extension base="string">
+ <attribute name="productId" type="integer"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "constraintTest");
+ InputStream is = new FileInputStream("test-resources/constraints.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("constraintTest", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "constraintTest"),
+ elem.getQName());
+
+ System.out.println("*** " + elem.toString("xsd", 4) + " ***");
+
+ XmlSchemaObjectCollection c = elem.getConstraints();
+ assertEquals(3, c.getCount());
+
+ Set s = new HashSet();
+ s.add(XmlSchemaKey.class.getName());
+ s.add(XmlSchemaKeyref.class.getName());
+ s.add(XmlSchemaUnique.class.getName());
+ for (int i = 0; i < c.getCount(); i++) {
+ Object o = c.getItem(i);
+ if (o instanceof XmlSchemaKey) {
+ XmlSchemaKey key = (XmlSchemaKey)o;
+ assertEquals("keyTest", key.getName());
+
+ XmlSchemaXPath selectorXpath = key.getSelector();
+ assertEquals("tns:products/tns:productName",
+ selectorXpath.getXPath());
+
+ XmlSchemaObjectCollection fields = key.getFields();
+ assertEquals(1, fields.getCount());
+ XmlSchemaXPath fieldXpath = null;
+ for (int j = 0; j < fields.getCount(); j++) {
+ fieldXpath = (XmlSchemaXPath)fields.getItem(j);
+ }
+ assertNotNull(fieldXpath);
+ assertEquals("@productId", fieldXpath.getXPath());
+ } else if (o instanceof XmlSchemaKeyref) {
+ XmlSchemaKeyref keyref = (XmlSchemaKeyref)o;
+ assertNotNull(keyref);
+ assertEquals("keyRefTest", keyref.getName());
+ assertEquals(new QName("http://soapinterop.org/types",
+ "keyTest"),
+ keyref.getRefer());
+
+ XmlSchemaXPath selectorXpath = keyref.getSelector();
+ assertEquals("tns:manufacturers/tns:location/tns:productName",
+ selectorXpath.getXPath());
+
+ XmlSchemaObjectCollection fields = keyref.getFields();
+ assertEquals(1, fields.getCount());
+ XmlSchemaXPath fieldXpath = null;
+ for (int j = 0; j < fields.getCount(); j++) {
+ fieldXpath = (XmlSchemaXPath)fields.getItem(j);
+ }
+ assertNotNull(fieldXpath);
+ assertEquals("@productId", fieldXpath.getXPath());
+ } else if (o instanceof XmlSchemaUnique) {
+ XmlSchemaUnique unique = (XmlSchemaUnique)o;
+ assertNotNull(unique);
+ assertEquals("uniqueTest", unique.getName());
+ XmlSchemaXPath selectorXpath = unique.getSelector();
+ assertEquals("tns:manufacturers/tns:location",
+ selectorXpath.getXPath());
+
+ XmlSchemaObjectCollection fields = unique.getFields();
+ assertEquals(1, fields.getCount());
+ XmlSchemaXPath fieldXpath = null;
+ for (int j = 0; j < fields.getCount(); j++) {
+ fieldXpath = (XmlSchemaXPath)fields.getItem(j);
+ }
+ assertNotNull(fieldXpath);
+ assertEquals("@district", fieldXpath.getXPath());
+ } else {
+ fail("An unexpected constraint of \""
+ + o.getClass().getName() + "\" was found.");
+ }
+ s.remove(o.getClass().getName());
+ }
+
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/NotationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/NotationTest.java?rev=415873&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/NotationTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/NotationTest.java Tue Jun 20 19:06:59 2006
@@ -0,0 +1,211 @@
+package tests;
+
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.ws.commons.schema.XmlSchemaNotation;
+import org.apache.ws.commons.schema.XmlSchemaDocumentation;
+import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Brent Ulbricht
+ */
+public class NotationTest extends TestCase {
+
+ /**
+ * This method will test the notation.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testNotation() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <notation name="teamLogo"
+ system="com/team/graphics/teamLogo"
+ public="http://www.team.com/graphics/teamLogo"
+ id="notation.teamLogo">
+ <annotation>
+ <documentation xml:lang="en">Location of the corporate logo.</documentation>
+ </annotation>
+ </notation>
+
+ <notation name="teamMascot"
+ system="com/team/graphics/teamMascot"
+ public="http://www.team.com/graphics/teamMascot"
+ id="notation.teamMascot">
+ <annotation>
+ <documentation xml:lang="en">Location of the corporate mascot.</documentation>
+ </annotation>
+ </notation>
+
+ <element name="demoNotation">
+ <simpleType>
+ <restriction base="NOTATION">
+ <enumeration value="tns:teamLogo"/>
+ <enumeration value="tns:teamMascot"/>
+ </restriction>
+ </simpleType>
+ </element>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "demoNotation");
+ InputStream is = new FileInputStream("test-resources/notation.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("demoNotation", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "demoNotation"),
+ elem.getQName());
+
+ XmlSchemaSimpleType type =
+ (XmlSchemaSimpleType)elem.getSchemaType();
+ assertNotNull(type);
+
+ XmlSchemaSimpleTypeRestriction xsstc =
+ (XmlSchemaSimpleTypeRestriction)type.getContent();
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema","NOTATION"),
+ xsstc.getBaseTypeName());
+
+ XmlSchemaObjectCollection xsoc = xsstc.getFacets();
+ assertEquals(2, xsoc.getCount());
+ Set s = new HashSet();
+ s.add("tns:teamLogo");
+ s.add("tns:teamMascot");
+ for (int i = 0; i < xsoc.getCount(); i++) {
+ XmlSchemaEnumerationFacet xsef =
+ (XmlSchemaEnumerationFacet)xsoc.getItem(i);
+ String value = (String)xsef.getValue();
+ System.out.println("*** value = " + value + " ***");
+ if (!(value.equals("tns:teamLogo")
+ || value.equals("tns:teamMascot"))) {
+ fail("An unexpected value of \"" + value
+ + "\" was found.");
+ }
+ assertTrue(s.remove(value));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ System.out.println("*** " + elem.toString("xsd", 4) + " ***");
+
+ XmlSchemaObjectTable xsot = schema.getNotations();
+ assertEquals(2, xsot.getCount());
+
+ s.clear();
+ s.add("teamMascot");
+ s.add("teamLogo");
+ for (Iterator i = xsot.getNames(); i.hasNext(); ) {
+ String name = (String)i.next();
+ if (!(name.equals("teamLogo")
+ || name.equals("teamMascot"))) {
+ fail("An unexpected name of \"" + name
+ + "\" was found.");
+ }
+ assertTrue(s.remove(name));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ s.clear();
+ s.add("teamMascot");
+ s.add("teamLogo");
+ for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ XmlSchemaNotation xsn = (XmlSchemaNotation)i.next();
+ String name = xsn.getName();
+ XmlSchemaAnnotation xsa = xsn.getAnnotation();
+ XmlSchemaObjectCollection col = xsa.getItems();
+ assertEquals(1, col.getCount());
+ XmlSchemaDocumentation xsd = null;
+ for (int k = 0; k < col.getCount(); k++) {
+ xsd = (XmlSchemaDocumentation)col.getItem(k);
+ }
+ if (name.equals("teamMascot")) {
+ assertEquals("http://www.team.com/graphics/teamMascot",
+ xsn.getPublic());
+ assertEquals("com/team/graphics/teamMascot",
+ xsn.getSystem());
+ assertEquals("notation.teamMascot", xsn.getId());
+ assertEquals("en", xsd.getLanguage());
+ NodeList nl = xsd.getMarkup();
+ for (int j = 0; j < nl.getLength(); j++) {
+ Node n = nl.item(j);
+ if (n.getNodeType() == Node.TEXT_NODE) {
+ assertEquals("Location of the corporate mascot.",
+ n.getTextContent());
+ }
+ }
+ } else if (name.equals("teamLogo")) {
+ assertEquals("http://www.team.com/graphics/teamLogo",
+ xsn.getPublic());
+ assertEquals("com/team/graphics/teamLogo",
+ xsn.getSystem());
+ assertEquals("notation.teamLogo", xsn.getId());
+ assertEquals("en", xsd.getLanguage());
+ NodeList nl = xsd.getMarkup();
+ for (int j = 0; j < nl.getLength(); j++) {
+ Node n = nl.item(j);
+ if (n.getNodeType() == Node.TEXT_NODE) {
+ assertEquals("Location of the corporate logo.",
+ n.getTextContent());
+ }
+ }
+ } else {
+ fail("An unexpected name of \"" + name
+ + "\" was found.");
+ }
+ assertTrue(s.remove(name));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org