You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2004/01/24 23:16:46 UTC
cvs commit: ws-jaxme/src/xs/org/apache/ws/jaxme/xs/jaxb/impl JAXBWildcardImpl.java
jochen 2004/01/24 14:16:46
Modified: src/xs/org/apache/ws/jaxme/xs/impl XSAnyImpl.java
XSWildcardImpl.java
src/jaxme/org/apache/ws/jaxme/generator/sg/impl
JAXBGroupSG.java JAXBPropertySG.java
JAXBObjectSG.java JAXBParticleSG.java
JAXBSGFactory.java AnyAttributePropertySG.java
src/test/jaxb build.xml wildcards.xsd
src/xs/org/apache/ws/jaxme/xs/junit ParserTest.java
src/jaxme/org/apache/ws/jaxme/generator/sg SGFactory.java
src/xs/org/apache/ws/jaxme/xs XSAny.java
Added: src/jaxme/org/apache/ws/jaxme/generator/sg/impl
AnyElementPropertySG.java
src/test/jaxb simpleTypeRestriction.xsd rss.xsd
src/xs/org/apache/ws/jaxme/xs/jaxb JAXBAny.java
JAXBWildcard.java
src/xs/org/apache/ws/jaxme/xs/jaxb/impl
JAXBWildcardImpl.java
Log:
First steps on the wildcard implementation.
Revision Changes Path
1.3 +1 -1 ws-jaxme/src/xs/org/apache/ws/jaxme/xs/impl/XSAnyImpl.java
Index: XSAnyImpl.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/xs/org/apache/ws/jaxme/xs/impl/XSAnyImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSAnyImpl.java 26 Oct 2003 04:17:29 -0000 1.2
+++ XSAnyImpl.java 24 Jan 2004 22:16:46 -0000 1.3
@@ -57,7 +57,7 @@
/**
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
-public class XSAnyImpl extends XSOpenAttrsImpl implements XSAny {
+public class XSAnyImpl extends XSWildcardImpl implements XSAny {
protected XSAnyImpl(XSObject pParent, XsEAny pBaseObject) {
super(pParent, pBaseObject);
}
1.4 +29 -1 ws-jaxme/src/xs/org/apache/ws/jaxme/xs/impl/XSWildcardImpl.java
Index: XSWildcardImpl.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/xs/org/apache/ws/jaxme/xs/impl/XSWildcardImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSWildcardImpl.java 7 Jan 2004 02:07:19 -0000 1.3
+++ XSWildcardImpl.java 24 Jan 2004 22:16:46 -0000 1.4
@@ -48,8 +48,10 @@
*/
package org.apache.ws.jaxme.xs.impl;
+import org.apache.ws.jaxme.xs.XSAnnotation;
import org.apache.ws.jaxme.xs.XSObject;
import org.apache.ws.jaxme.xs.XSWildcard;
+import org.apache.ws.jaxme.xs.xml.XsEAnnotation;
import org.apache.ws.jaxme.xs.xml.XsNamespaceList;
import org.apache.ws.jaxme.xs.xml.XsSchemaHeader;
import org.apache.ws.jaxme.xs.xml.XsTWildcard;
@@ -60,8 +62,13 @@
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public class XSWildcardImpl extends XSOpenAttrsImpl implements XSWildcard {
- protected XSWildcardImpl(XSObject pParent, XsTWildcard pBaseObject) {
+ private boolean isValidated;
+ private XSAnnotation[] annotations;
+ private final XsEAnnotation xsAnnotation;
+
+ protected XSWildcardImpl(XSObject pParent, XsTWildcard pBaseObject) {
super(pParent, pBaseObject);
+ xsAnnotation = pBaseObject.getAnnotation();
}
public XsNamespaceList getNamespaceList() {
@@ -72,10 +79,31 @@
return ((XsTWildcard) getXsObject()).getProcessContents();
}
+ protected boolean isValidated() {
+ return isValidated;
+ }
+
public void validate() throws SAXException {
+ if (isValidated()) {
+ return;
+ } else {
+ isValidated = true;
+ }
+
+ if (xsAnnotation == null) {
+ annotations = new XSAnnotation[0];
+ } else {
+ XSAnnotation ann = getXSSchema().getXSObjectFactory().newXSAnnotation(this, xsAnnotation);
+ annotations = new XSAnnotation[]{ ann };
+ ann.validate();
+ }
}
public XsSchemaHeader getSchemaHeader() {
return getXsObject().getXsESchema();
+ }
+
+ public XSAnnotation[] getAnnotations() {
+ return annotations;
}
}
1.6 +145 -129 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBGroupSG.java
Index: JAXBGroupSG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBGroupSG.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JAXBGroupSG.java 7 Jan 2004 02:07:19 -0000 1.5
+++ JAXBGroupSG.java 24 Jan 2004 22:16:46 -0000 1.6
@@ -90,7 +90,6 @@
import org.apache.ws.jaxme.logging.LoggerAccess;
import org.apache.ws.jaxme.xs.XSGroup;
import org.apache.ws.jaxme.xs.XSParticle;
-import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
import org.apache.ws.jaxme.xs.xml.XsQName;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
@@ -188,13 +187,11 @@
PropertySG elementSG = particle.getPropertySG();
elementSG.generate(pSource);
} else if (particle.isGroup()) {
- // TODO: Implement groups referencing groups
- //throw new LocSAXException("Nested groups are yet unsupported", particle.getLocator());
GroupSG groupSG = particle.getGroupSG();
groupSG.generateProperties(pSource);
} else if (particle.isWildcard()) {
- // TODO: Implement Wildcard handling
- throw new LocSAXException("Wildcard handling is not implemented", particle.getLocator());
+ PropertySG wildcardSG = particle.getPropertySG();
+ wildcardSG.generate(pSource);
} else {
throw new IllegalStateException("Unknown particle type: Neither of element, group, or wildcard");
}
@@ -216,13 +213,10 @@
complexTypeSG.getXMLInterface(pSource);
}
} else if (particle.isGroup()) {
- // TODO: Implement groups referencing groups
- //throw new LocSAXException("Nested groups are yet unsupported", particle.getLocator());
GroupSG groupSG = particle.getGroupSG();
groupSG.generateXMLInterfaceSubclasses(pSource);
} else if (particle.isWildcard()) {
- // TODO: Implement Wildcard handling
- throw new LocSAXException("Wildcard handling is not implemented", particle.getLocator());
+ // Do nothing
} else {
throw new IllegalStateException("Unknown particle type: Neither of element, group, or wildcard");
}
@@ -244,13 +238,10 @@
complexTypeSG.getXMLImplementation(pSource);
}
} else if (particle.isGroup()) {
- // TODO: Implement groups referencing groups
- //throw new LocSAXException("Nested groups are yet unsupported", particle.getLocator());
GroupSG groupSG = particle.getGroupSG();
groupSG.generateXMLImplementationSubclasses(pSource);
} else if (particle.isWildcard()) {
- // TODO: Implement Wildcard handling
- throw new LocSAXException("Wildcard handling is not implemented", particle.getLocator());
+ // Do nothing
} else {
throw new IllegalStateException("Unknown particle type: Neither of element, group, or wildcard");
}
@@ -469,9 +460,17 @@
jc.addLine(" 1 = Parsing an unknown element");
jc.addLine(" 2 = After parsing the element");
for (int i = 0; i < myParticles.length; i++) {
- // TODO: process group case properly.
- if (myParticles[i].isGroup()) continue;
- jc.addLine(" " + (3+i) + " = While parsing the child element " + myParticles[i].getObjectSG().getName());
+ ParticleSG particle = myParticles[i];
+ if (particle.isGroup()) {
+ // TODO: process group case properly.
+ continue;
+ } else if (particle.isElement()) {
+ jc.addLine(" " + (3+i) + " = While parsing the child element " + myParticles[i].getObjectSG().getName());
+ } else if (particle.isWildcard()) {
+ jc.addLine(" " + (3+i) + " = While parsing the wildcard");
+ } else {
+ throw new IllegalStateException("Invalid particle type.");
+ }
}
JavaMethod[] methods = pSource.getMethods();
@@ -521,127 +520,144 @@
}
}
- private void extendXMLHandlersStartElementMethod(GroupSG pController, JavaSource pSource,
- DirectAccessible pStateVar,
- DirectAccessible pHandlerVar) throws SAXException {
- ParticleSG[] myParticles = pController.getParticles();
- if (myParticles.length == 0) {
- return;
- }
-
- JavaQName STRING_TYPE = JavaQNameImpl.getInstance(String.class);
- JavaQName ATTRIBUTES_TYPE = JavaQNameImpl.getInstance(Attributes.class);
- JavaMethod jm = pSource.getMethod("startElement", new JavaQName[]{STRING_TYPE, STRING_TYPE, STRING_TYPE,
- ATTRIBUTES_TYPE});
- if (jm == null) {
- throw new IllegalStateException("No such method: 'startElement' in '" + pSource.getQName() + "'.");
- }
- PlaceHolder placeHolder = jm.getPlaceHolder("GroupSG");
- if (placeHolder == null) {
- throw new IllegalStateException("No such placeholder: 'GroupSG' in method 'startElement'");
- }
- placeHolder.remove();
- Parameter[] parameters = jm.getParams();
- Parameter pNamespaceURI = parameters[0];
- Parameter pLocalName = parameters[1];
- Parameter pQName = parameters[2];
- Parameter pAttr = parameters[3];
-
- jm.addCase("1");
- Set namespaces = new HashSet();
- for (int i = 0; i < myParticles.length; i++) {
- ParticleSG child = myParticles[i];
- // TODO: process group case properly.
- if (myParticles[i].isGroup()) continue;
- // Did we have the same namespace before? If so, skip
- String uri = child.getObjectSG().getName().getNamespaceURI();
- if (namespaces.contains(uri)) {
- continue;
- }
-
- if ("".equals(uri)) {
- jm.addIf(namespaces.isEmpty(), pNamespaceURI, " == null || ", pNamespaceURI, ".length() == 0");
- } else {
- jm.addIf(namespaces.isEmpty(), JavaSource.getQuoted(uri), ".equals(", pNamespaceURI, ")");
- }
- namespaces.add(uri);
-
+ private void extendXMLHandlersStartElementMethodAddNamespace(GroupSG pController,
+ DirectAccessible pHandlerVar,
+ DirectAccessible pStateVar,
+ JavaMethod pMethod,
+ String pURI,
+ Parameter pQName,
+ Parameter pLocalName,
+ ParticleSG[] pParticles) throws SAXException {
// Now handle all elements with the namespace uri
- for (int j = i; j < myParticles.length; j++) {
- child = myParticles[j];
- // TODO: process group case properly.
- if (myParticles[j].isGroup()) continue;
- XsQName name = child.getObjectSG().getName();
- if (!name.getNamespaceURI().equals(uri)) {
- continue;
- }
- jm.addIf(j == i, JavaSource.getQuoted(name.getLocalName()), ".equals(", pLocalName, ")");
+ boolean first = true;
+ for (int j = 0; j < pParticles.length; j++) {
+ ParticleSG child = pParticles[j];
+ if (!child.isElement()) {
+ continue;
+ }
+ XsQName name = child.getObjectSG().getName();
+ if (!name.getNamespaceURI().equals(pURI)) {
+ continue;
+ }
+ pMethod.addIf(first, JavaSource.getQuoted(name.getLocalName()), ".equals(", pLocalName, ")");
+ first = false;
- List validStates = new ArrayList();
- if (child.isMultiple()) {
- validStates.add(new Integer(j+3));
- }
- if (pController.isChoice()) {
- validStates.add(new Integer(0));
- } else if (pController.isSequence()) {
- boolean stateZeroIsValid = true;
- for (int k = j-1; k >= 0; k--) {
- ParticleSG kChild = myParticles[k];
- validStates.add(new Integer(k+3));
- if (kChild.getMinOccurs() > 0) {
- stateZeroIsValid = false;
- break;
- }
+ List validStates = new ArrayList();
+ if (child.isMultiple()) {
+ validStates.add(new Integer(j+3));
}
- if (stateZeroIsValid) {
- validStates.add(new Integer(0));
+ if (pController.isChoice()) {
+ validStates.add(new Integer(0));
+ } else if (pController.isSequence()) {
+ boolean stateZeroIsValid = true;
+ for (int k = j-1; k >= 0; k--) {
+ ParticleSG kChild = pParticles[k];
+ validStates.add(new Integer(k+3));
+ if (kChild.getMinOccurs() > 0) {
+ stateZeroIsValid = false;
+ break;
+ }
+ }
+ if (stateZeroIsValid) {
+ validStates.add(new Integer(0));
+ }
+ } else if (pController.isAll()) {
+ validStates.add(new Integer(0));
+ for (int k = 0; k < pParticles.length; k++) {
+ validStates.add(new Integer(k));
+ }
+ } else {
+ throw new IllegalStateException("Don't know how to handle type which is neither sequence nor choice, or all.");
}
- } else if (pController.isAll()) {
- validStates.add(new Integer(0));
- for (int k = 0; k < myParticles.length; k++) {
- validStates.add(new Integer(k));
+ Collections.sort(validStates);
+ pMethod.addSwitch(pStateVar);
+ for (int k = 0; k < validStates.size(); k++) {
+ pMethod.addCase(validStates.get(k));
}
- } else {
- throw new IllegalStateException("Don't know how to handle type which is neither sequence nor choice, or all.");
- }
- Collections.sort(validStates);
- jm.addSwitch(pStateVar);
- for (int k = 0; k < validStates.size(); k++) {
- jm.addCase(validStates.get(k));
- }
-
- jm.addLine(pStateVar, " = " + (j+3) + ";");
- if (child.getObjectSG().getTypeSG().isComplex()) {
- String handlerMethodName = getXMLHandlersMethodName(child.getPropertySG());
- jm.addLine(pHandlerVar, " = ", handlerMethodName, "();");
- } else {
- jm.addLine(pHandlerVar, " = getData().getAtomicHandler();");
- }
- jm.addLine(pHandlerVar, ".startDocument();");
- jm.addLine(pHandlerVar, ".startElement(pNamespaceURI, pLocalName, pQName, pAttr);");
-
- jm.addBreak();
- jm.addDefault();
- jm.addLine("validationEvent(", ValidationEvent.class, ".WARNING, ",
- JavaSource.getQuoted("The element "), " + ", pQName, " + ",
- JavaSource.getQuoted(" was unexpected at this place."),
- ", ", ValidationEvents.class,
- ".EVENT_UNEXPECTED_CHILD_STATE);");
- jm.addBreak();
- jm.addEndSwitch();
+
+ pMethod.addLine(pStateVar, " = " + (j+3) + ";");
+ if (child.getObjectSG().getTypeSG().isComplex()) {
+ String handlerMethodName = getXMLHandlersMethodName(child.getPropertySG());
+ pMethod.addLine(pHandlerVar, " = ", handlerMethodName, "();");
+ } else {
+ pMethod.addLine(pHandlerVar, " = getData().getAtomicHandler();");
+ }
+ pMethod.addLine(pHandlerVar, ".startDocument();");
+ pMethod.addLine(pHandlerVar, ".startElement(pNamespaceURI, pLocalName, pQName, pAttr);");
+
+ pMethod.addBreak();
+ pMethod.addDefault();
+ pMethod.addLine("validationEvent(", ValidationEvent.class, ".WARNING, ",
+ JavaSource.getQuoted("The element "), " + ", pQName, " + ",
+ JavaSource.getQuoted(" was unexpected at this place."),
+ ", ", ValidationEvents.class,
+ ".EVENT_UNEXPECTED_CHILD_STATE);");
+ pMethod.addBreak();
+ pMethod.addEndSwitch();
}
+ }
+ private void extendXMLHandlersStartElementMethod(GroupSG pController, JavaSource pSource,
+ DirectAccessible pStateVar,
+ DirectAccessible pHandlerVar) throws SAXException {
+ ParticleSG[] myParticles = pController.getParticles();
+ if (myParticles.length == 0) {
+ return;
+ }
+
+ JavaQName STRING_TYPE = JavaQNameImpl.getInstance(String.class);
+ JavaQName ATTRIBUTES_TYPE = JavaQNameImpl.getInstance(Attributes.class);
+ JavaMethod jm = pSource.getMethod("startElement", new JavaQName[]{STRING_TYPE, STRING_TYPE, STRING_TYPE,
+ ATTRIBUTES_TYPE});
+ if (jm == null) {
+ throw new IllegalStateException("No such method: 'startElement' in '" + pSource.getQName() + "'.");
+ }
+ PlaceHolder placeHolder = jm.getPlaceHolder("GroupSG");
+ if (placeHolder == null) {
+ throw new IllegalStateException("No such placeholder: 'GroupSG' in method 'startElement'");
+ }
+ placeHolder.remove();
+ Parameter[] parameters = jm.getParams();
+ Parameter pNamespaceURI = parameters[0];
+ Parameter pLocalName = parameters[1];
+ Parameter pQName = parameters[2];
+ Parameter pAttr = parameters[3];
+
+ jm.addCase("1");
+ Set namespaces = new HashSet();
+ for (int i = 0; i < myParticles.length; i++) {
+ ParticleSG child = myParticles[i];
+ if (child.isGroup()) {
+ // TODO: process group case properly.
+ } else if (child.isWildcard()) {
+ throw new IllegalStateException();
+ } else if (child.isElement()) {
+ // Did we have the same namespace before? If so, skip
+ String uri = child.getObjectSG().getName().getNamespaceURI();
+ if (namespaces.contains(uri)) {
+ continue;
+ }
+
+ if ("".equals(uri)) {
+ jm.addIf(namespaces.isEmpty(), pNamespaceURI, " == null || ", pNamespaceURI, ".length() == 0");
+ } else {
+ jm.addIf(namespaces.isEmpty(), JavaSource.getQuoted(uri), ".equals(", pNamespaceURI, ")");
+ }
+ namespaces.add(uri);
+ extendXMLHandlersStartElementMethodAddNamespace(pController, pHandlerVar, pStateVar,
+ jm, uri, pQName, pLocalName, myParticles);
+ jm.addEndIf();
+ }
+ }
+ jm.addEndIf();
+ jm.addBreak();
+
+ jm.addDefault();
+ jm.addIf(pHandlerVar, " == null");
+ jm.addLine("super.startElement(", pNamespaceURI, ", ", pLocalName, ", ", pQName, ", ", pAttr, ");");
+ jm.addElse();
+ jm.addLine(pHandlerVar, ".startElement(", pNamespaceURI, ", ", pLocalName, ", ", pQName, ", ", pAttr, ");");
jm.addEndIf();
- }
- jm.addEndIf();
- jm.addBreak();
-
- jm.addDefault();
- jm.addIf(pHandlerVar, " == null");
- jm.addLine("super.startElement(", pNamespaceURI, ", ", pLocalName, ", ", pQName, ", ", pAttr, ");");
- jm.addElse();
- jm.addLine(pHandlerVar, ".startElement(", pNamespaceURI, ", ", pLocalName, ", ", pQName, ", ", pAttr, ");");
- jm.addEndIf();
}
public JavaMethod getXMLHandlersEndElementMethod(GroupSG pController, JavaSource pSource,
1.5 +34 -96 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBPropertySG.java
Index: JAXBPropertySG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBPropertySG.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JAXBPropertySG.java 7 Jan 2004 02:07:19 -0000 1.4
+++ JAXBPropertySG.java 24 Jan 2004 22:16:46 -0000 1.5
@@ -67,13 +67,10 @@
import org.apache.ws.jaxme.js.LocalJavaField;
import org.apache.ws.jaxme.xs.XSAttribute;
import org.apache.ws.jaxme.xs.XSElement;
-import org.apache.ws.jaxme.xs.XSSimpleContentType;
+import org.apache.ws.jaxme.xs.XSObject;
import org.apache.ws.jaxme.xs.XSType;
-import org.apache.ws.jaxme.xs.jaxb.JAXBAttribute;
-import org.apache.ws.jaxme.xs.jaxb.JAXBElement;
import org.apache.ws.jaxme.xs.jaxb.JAXBProperty;
import org.apache.ws.jaxme.xs.jaxb.JAXBPropertyOwner;
-import org.apache.ws.jaxme.xs.jaxb.JAXBSimpleContentType;
import org.xml.sax.SAXException;
/**
@@ -82,110 +79,51 @@
*/
public class JAXBPropertySG implements PropertySGChain {
private final String propertyName;
- private final TypeSG typeSG;
private final String collectionType;
private final boolean generateIsSetMethod;
private final String defaultValue;
-
- JAXBPropertySG(String pPropertyName, TypeSG pTypeSG, String pCollectionType,
- boolean pGenerateIsSetMethod, String pDefaultValue) {
- propertyName = pPropertyName;
- typeSG = pTypeSG;
- collectionType = pCollectionType;
- generateIsSetMethod = pGenerateIsSetMethod;
- defaultValue = pDefaultValue;
+ private final TypeSG typeSG;
+
+ protected JAXBPropertySG(String pDefaultPropertyName, SchemaSG pSchema, XSObject pXSObject,
+ String pDefaultValue, TypeSG pTypeSG) {
+ typeSG = pTypeSG;
+ defaultValue = pDefaultValue;
+ String myPropertyName = null;
+ boolean myGeneratedIsSetMethod = pSchema.isGeneratingIsSetMethod();
+ String myCollectionType = null;
+ if (pXSObject instanceof JAXBPropertyOwner) {
+ JAXBPropertyOwner jaxbPropertyOwner = (JAXBPropertyOwner) pXSObject;
+ JAXBProperty jaxbProperty = jaxbPropertyOwner.getJAXBProperty();
+ if (jaxbProperty != null) {
+ myPropertyName = jaxbProperty.getName();
+ Boolean jaxbGeneratedIsSetMethod = jaxbProperty.isGenerateIsSetMethod();
+ if (jaxbGeneratedIsSetMethod != null) {
+ myGeneratedIsSetMethod = jaxbGeneratedIsSetMethod.booleanValue();
+ myCollectionType = jaxbProperty.getCollectionType();
+ }
+ }
+ }
+
+ collectionType = myCollectionType == null ? pSchema.getCollectionType() : myCollectionType;
+ propertyName = myPropertyName == null ? JavaNamer.convert(pDefaultPropertyName, pSchema) : myPropertyName;
+ generateIsSetMethod = myGeneratedIsSetMethod;
}
-
+
protected JAXBPropertySG(AttributeSG pAttribute, XSAttribute pXSAttribute) {
- typeSG = pAttribute.getTypeSG();
- String myDefaultValue = pXSAttribute.getDefault();
- SimpleTypeSG simpleType = typeSG.getSimpleTypeSG();
- if (simpleType == null) {
- defaultValue = null;
- } else {
- defaultValue = myDefaultValue;
- }
- String myPropertyName = null;
- boolean myGeneratedIsSetMethod = pAttribute.getSchema().isGeneratingIsSetMethod();
- JAXBAttribute jaxbAttribute = null;
- if (pXSAttribute instanceof JAXBAttribute) {
- jaxbAttribute = (JAXBAttribute) pXSAttribute;
- JAXBProperty jaxbProperty = jaxbAttribute.getJAXBProperty();
- if (jaxbProperty != null) {
- myPropertyName = jaxbProperty.getName();
- Boolean jaxbGeneratedIsSetMethod = jaxbProperty.isGenerateIsSetMethod();
- if (jaxbGeneratedIsSetMethod != null) {
- myGeneratedIsSetMethod = jaxbGeneratedIsSetMethod.booleanValue();
- }
- }
- }
- propertyName = myPropertyName == null ?
- JavaNamer.convert(pAttribute.getName().getLocalName(), typeSG.getSchema()) : myPropertyName;
- collectionType = getCollectionType(pAttribute.getSchema(), jaxbAttribute);
- generateIsSetMethod = myGeneratedIsSetMethod;
+ this(pAttribute.getName().getLocalName(), pAttribute.getSchema(), pXSAttribute, pXSAttribute.getDefault(),
+ pAttribute.getTypeSG());
}
protected JAXBPropertySG(ObjectSG pElement, XSElement pXSElement) {
- typeSG = pElement.getTypeSG();
- if ((!typeSG.isComplex()) && (typeSG.getSimpleTypeSG() != null)) {
- defaultValue = pXSElement.getDefault();
- } else {
- defaultValue = null;
- }
- String myPropertyName = null;
- boolean myGeneratedIsSetMethod = pElement.getSchema().isGeneratingIsSetMethod();
- JAXBElement jaxbElement = null;
- if (pXSElement instanceof JAXBElement) {
- jaxbElement = (JAXBElement) pXSElement;
- JAXBProperty jaxbProperty = jaxbElement.getJAXBProperty();
- if (jaxbProperty != null) {
- myPropertyName = jaxbProperty.getName();
- Boolean jaxbGeneratedIsSetMethod = jaxbProperty.isGenerateIsSetMethod();
- if (jaxbGeneratedIsSetMethod != null) {
- myGeneratedIsSetMethod = jaxbGeneratedIsSetMethod.booleanValue();
- }
- }
- }
- propertyName = myPropertyName == null ?
- JavaNamer.convert(pElement.getName().getLocalName(), typeSG.getSchema()) : myPropertyName;
- collectionType = getCollectionType(pElement.getSchema(), jaxbElement);
- generateIsSetMethod = myGeneratedIsSetMethod;
+ this(pElement.getName().getLocalName(), pElement.getSchema(), pXSElement, pXSElement.getDefault(),
+ pElement.getTypeSG());
}
protected JAXBPropertySG(TypeSG pComplexType, XSType pType) throws SAXException {
- defaultValue = null;
- typeSG = pComplexType.getComplexTypeSG().getSimpleContentSG().getTypeSG();
- String myPropertyName = null;
- boolean myGeneratedIsSetMethod = pComplexType.getSchema().isGeneratingIsSetMethod();
- XSSimpleContentType simpleContentType = pType.getComplexType().getSimpleContent();
- JAXBSimpleContentType jaxbSimpleContentType = null;
- if (simpleContentType instanceof JAXBSimpleContentType) {
- jaxbSimpleContentType = (JAXBSimpleContentType) simpleContentType;
- JAXBProperty jaxbProperty = jaxbSimpleContentType.getJAXBProperty();
- if (jaxbProperty != null) {
- myPropertyName = jaxbProperty.getName();
- Boolean jaxbGeneratedIsSetMethod = jaxbProperty.isGenerateIsSetMethod();
- if (jaxbGeneratedIsSetMethod != null) {
- myGeneratedIsSetMethod = jaxbGeneratedIsSetMethod.booleanValue();
- }
- }
- }
- propertyName = (myPropertyName == null) ? "value" : myPropertyName;
- collectionType = getCollectionType(pComplexType.getSchema(), jaxbSimpleContentType);
- generateIsSetMethod = myGeneratedIsSetMethod;
- }
-
- private String getCollectionType(SchemaSG pSchema, JAXBPropertyOwner pPropertyOwner) {
- String result = null;
- if (pPropertyOwner != null) {
- JAXBProperty property = pPropertyOwner.getJAXBProperty();
- if (property != null) {
- result = property.getCollectionType();
- }
- }
- return result == null ? pSchema.getCollectionType() : result;
+ this("value", pComplexType.getSchema(), pType, null,
+ pComplexType.getComplexTypeSG().getSimpleContentSG().getContentTypeSG());
}
-
+
public void init(PropertySG pController) throws SAXException {}
public boolean hasIsSetMethod(PropertySG pController) { return generateIsSetMethod; }
1.3 +12 -0 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBObjectSG.java
Index: JAXBObjectSG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBObjectSG.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JAXBObjectSG.java 23 Oct 2003 16:38:57 -0000 1.2
+++ JAXBObjectSG.java 24 Jan 2004 22:16:46 -0000 1.3
@@ -70,6 +70,7 @@
import org.apache.ws.jaxme.js.JavaSourceFactory;
import org.apache.ws.jaxme.logging.Logger;
import org.apache.ws.jaxme.logging.LoggerAccess;
+import org.apache.ws.jaxme.xs.XSAny;
import org.apache.ws.jaxme.xs.XSAttribute;
import org.apache.ws.jaxme.xs.XSElement;
import org.apache.ws.jaxme.xs.XSObject;
@@ -180,6 +181,17 @@
name = null;
classContext = pComplexType.getComplexTypeSG().getClassContext();
typeSG = pFactory.getTypeSG(type, classContext, null);
+ }
+
+ /** <p>Creates a new instance of JAXBObjectSG generating the given
+ * wildcard object.</p>
+ */
+ public JAXBObjectSG(SGFactory pFactory, SchemaSG pSchema, XSAny pAny) {
+ super(pFactory, pSchema, pAny);
+ type = null;
+ name = null;
+ classContext = null;
+ typeSG = null;
}
public void init(ObjectSG pController) throws SAXException {
1.2 +109 -100 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBParticleSG.java
Index: JAXBParticleSG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBParticleSG.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JAXBParticleSG.java 23 Sep 2003 12:34:45 -0000 1.1
+++ JAXBParticleSG.java 24 Jan 2004 22:16:46 -0000 1.2
@@ -59,6 +59,7 @@
import org.apache.ws.jaxme.generator.sg.TypeSG;
import org.apache.ws.jaxme.js.DirectAccessible;
import org.apache.ws.jaxme.js.JavaMethod;
+import org.apache.ws.jaxme.xs.XSAny;
import org.apache.ws.jaxme.xs.XSElement;
import org.apache.ws.jaxme.xs.XSParticle;
import org.xml.sax.Locator;
@@ -69,105 +70,113 @@
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public class JAXBParticleSG implements ParticleSGChain {
- private final int minOccurs, maxOccurs;
- private final XSParticle.Type type;
- private PropertySG propertySG;
- private final GroupSG groupSG;
- private final ObjectSG objectSG;
- private final Locator locator;
- private XSElement element;
-
- /** <p>Creates a new instance of JAXBParticleSG.java.</p>
- */
- public JAXBParticleSG(GroupSG pGroup, XSParticle pParticle, Context pClassContext) throws SAXException {
- minOccurs = pParticle.getMinOccurs();
- maxOccurs = pParticle.getMaxOccurs();
- type = pParticle.getType();
- if (pParticle.isGroup()) {
- groupSG = pGroup.getFactory().getGroupSG(pParticle.getGroup(), pClassContext);
- objectSG = null;
- } else if (pParticle.isElement()) {
- objectSG = pGroup.getFactory().getObjectSG(pParticle.getElement(), pClassContext);
- groupSG = null;
- element = pParticle.getElement();
- } else {
- // TODO: Implement wildcard support
- objectSG = null;
- groupSG = null;
- }
- locator = pParticle.getLocator();
- }
-
- public Object newPropertySGChain(ParticleSG pController) {
- if (element == null) {
- throw new IllegalStateException("A new PropertySGChain cannot be obtained.");
- }
- PropertySGChain result = new JAXBPropertySG(objectSG, element);
- element = null; // Make this available for garbage collection
- if (maxOccurs > 1 || maxOccurs == -1) {
- result = new MultiplePropertySG(result, objectSG, minOccurs, maxOccurs);
- }
- return result;
- }
-
- public void init(ParticleSG pController) throws SAXException {
- if (element != null) {
- PropertySGChain chain = (PropertySGChain) pController.newPropertySGChain();
- propertySG = new PropertySGImpl(chain);
- propertySG.init();
- }
- }
-
- public Locator getLocator(ParticleSG pController) { return locator; }
- public int getMinOccurs(ParticleSG pController) { return minOccurs; }
- public int getMaxOccurs(ParticleSG pController) { return maxOccurs; }
- public boolean isMultiple(ParticleSG pController) { return maxOccurs == -1 || maxOccurs > 1; }
- public boolean isGroup(ParticleSG pController) { return type.equals(XSParticle.GROUP); }
- public boolean isElement(ParticleSG pController) { return type.equals(XSParticle.ELEMENT); }
- public boolean isWildcard(ParticleSG pController) { return type.equals(XSParticle.WILDCARD); }
-
- public PropertySG getPropertySG(ParticleSG pController) {
- if (propertySG == null) {
- throw new IllegalStateException("This particle has no PropertySG.");
- }
- return propertySG;
- }
-
- public ObjectSG getObjectSG(ParticleSG pController) {
- if (objectSG == null) {
- throw new IllegalStateException("This particle is neither an element nor a wildcard.");
- }
- return objectSG;
- }
-
- public GroupSG getGroupSG(ParticleSG pController) {
- if (groupSG == null) {
- throw new IllegalStateException("This particle is no group.");
- }
- return groupSG;
- }
-
- public void forAllNonNullValues(ParticleSG pController, JavaMethod pMethod,
- DirectAccessible pElement, SGlet pSGlet) throws SAXException {
- if (pController.isElement()) {
- PropertySG pSG = pController.getPropertySG();
- boolean hasIsSetMethod = pSG.hasIsSetMethod();
- if (hasIsSetMethod) {
- pMethod.addIf(pSG.getXMLIsSetMethodName(), "()");
- }
- TypeSG typeSG = pController.getObjectSG().getTypeSG();
- Object v = pController.getPropertySG().getValue(pElement);
- if (typeSG.isComplex()) {
- pSGlet.generate(pMethod, v);
- } else {
- typeSG.getSimpleTypeSG().forAllValues(pMethod, v, pSGlet);
- }
- if (hasIsSetMethod) {
- pMethod.addEndIf();
- }
- } else {
- // TODO: Implement support for wildcards and subgroups
- throw new IllegalStateException("Wildcards and subgroups are not yet supported.");
+ private final int minOccurs, maxOccurs;
+ private final XSParticle.Type type;
+ private PropertySG propertySG;
+ private final GroupSG groupSG;
+ private final ObjectSG objectSG;
+ private final Locator locator;
+ private XSElement element;
+ private XSAny wildcard;
+
+ /** <p>Creates a new instance of JAXBParticleSG.java.</p>
+ */
+ public JAXBParticleSG(GroupSG pGroup, XSParticle pParticle, Context pClassContext) throws SAXException {
+ minOccurs = pParticle.getMinOccurs();
+ maxOccurs = pParticle.getMaxOccurs();
+ type = pParticle.getType();
+ if (pParticle.isGroup()) {
+ groupSG = pGroup.getFactory().getGroupSG(pParticle.getGroup(), pClassContext);
+ objectSG = null;
+ } else if (pParticle.isElement()) {
+ objectSG = pGroup.getFactory().getObjectSG(pParticle.getElement(), pClassContext);
+ groupSG = null;
+ element = pParticle.getElement();
+ } else if (pParticle.isWildcard()) {
+ objectSG = pGroup.getFactory().getObjectSG(pParticle.getWildcard(), pClassContext);
+ groupSG = null;
+ wildcard = pParticle.getWildcard();
+ } else {
+ throw new IllegalStateException("Particle is neither group, nor element, or wildcard.");
+ }
+ locator = pParticle.getLocator();
+ }
+
+ public Object newPropertySGChain(ParticleSG pController) {
+ PropertySGChain result;
+ if (element != null) {
+ result = new JAXBPropertySG(objectSG, element);
+ element = null;
+ } else if (wildcard != null) {
+ result = new AnyElementPropertySG(objectSG, wildcard);
+ wildcard = null;
+ } else {
+ throw new IllegalStateException("A new PropertySGChain cannot be obtained.");
+ }
+ if (maxOccurs > 1 || maxOccurs == -1) {
+ result = new MultiplePropertySG(result, objectSG, minOccurs, maxOccurs);
+ }
+ return result;
+ }
+
+ public void init(ParticleSG pController) throws SAXException {
+ if (element != null || wildcard != null) {
+ PropertySGChain chain = (PropertySGChain) pController.newPropertySGChain();
+ propertySG = new PropertySGImpl(chain);
+ propertySG.init();
+ }
+ }
+
+ public Locator getLocator(ParticleSG pController) { return locator; }
+ public int getMinOccurs(ParticleSG pController) { return minOccurs; }
+ public int getMaxOccurs(ParticleSG pController) { return maxOccurs; }
+ public boolean isMultiple(ParticleSG pController) { return maxOccurs == -1 || maxOccurs > 1; }
+ public boolean isGroup(ParticleSG pController) { return type.equals(XSParticle.GROUP); }
+ public boolean isElement(ParticleSG pController) { return type.equals(XSParticle.ELEMENT); }
+ public boolean isWildcard(ParticleSG pController) { return type.equals(XSParticle.WILDCARD); }
+
+ public PropertySG getPropertySG(ParticleSG pController) {
+ if (propertySG == null) {
+ throw new IllegalStateException("This particle has no PropertySG.");
+ }
+ return propertySG;
+ }
+
+ public ObjectSG getObjectSG(ParticleSG pController) {
+ if (objectSG == null) {
+ throw new IllegalStateException("This particle is neither an element nor a wildcard.");
+ }
+ return objectSG;
+ }
+
+ public GroupSG getGroupSG(ParticleSG pController) {
+ if (groupSG == null) {
+ throw new IllegalStateException("This particle is no group.");
+ }
+ return groupSG;
+ }
+
+ public void forAllNonNullValues(ParticleSG pController, JavaMethod pMethod,
+ DirectAccessible pElement, SGlet pSGlet) throws SAXException {
+ if (pController.isElement()) {
+ PropertySG pSG = pController.getPropertySG();
+ boolean hasIsSetMethod = pSG.hasIsSetMethod();
+ if (hasIsSetMethod) {
+ pMethod.addIf(pSG.getXMLIsSetMethodName(), "()");
+ }
+ TypeSG typeSG = pController.getObjectSG().getTypeSG();
+ Object v = pController.getPropertySG().getValue(pElement);
+ if (typeSG.isComplex()) {
+ pSGlet.generate(pMethod, v);
+ } else {
+ typeSG.getSimpleTypeSG().forAllValues(pMethod, v, pSGlet);
+ }
+ if (hasIsSetMethod) {
+ pMethod.addEndIf();
+ }
+ } else {
+ // TODO: Implement support for wildcards and subgroups
+ throw new IllegalStateException("Wildcards and subgroups are not yet supported.");
+ }
}
- }
}
1.5 +16 -1 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSGFactory.java
Index: JAXBSGFactory.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSGFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JAXBSGFactory.java 27 Dec 2003 22:10:40 -0000 1.4
+++ JAXBSGFactory.java 24 Jan 2004 22:16:46 -0000 1.5
@@ -69,6 +69,7 @@
import org.apache.ws.jaxme.generator.sg.TypeSGChain;
import org.apache.ws.jaxme.logging.Logger;
import org.apache.ws.jaxme.logging.LoggerAccess;
+import org.apache.ws.jaxme.xs.XSAny;
import org.apache.ws.jaxme.xs.XSElement;
import org.apache.ws.jaxme.xs.XSEnumeration;
import org.apache.ws.jaxme.xs.XSGroup;
@@ -163,7 +164,21 @@
}
return result;
}
-
+
+ public Object newObjectSG(SGFactory pController, XSAny pAny) {
+ if (schemaSG == null) {
+ throw new IllegalStateException("A schema has not yet been created.");
+ }
+ return new JAXBObjectSG(pController, schemaSG, pAny);
+ }
+
+ public ObjectSG getObjectSG(SGFactory pController, XSAny pAny, Context pContext) throws SAXException {
+ ObjectSGChain chain = (ObjectSGChain) pController.newObjectSG(pAny);
+ ObjectSG result = new ObjectSGImpl(chain);
+ result.init();
+ return result;
+ }
+
public Object newObjectSG(SGFactory pController, XSElement pElement, Context pContext) throws SAXException {
if (schemaSG == null) {
throw new IllegalStateException("A schema has not yet been created.");
1.2 +1 -1 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AnyAttributePropertySG.java
Index: AnyAttributePropertySG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AnyAttributePropertySG.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AnyAttributePropertySG.java 7 Jan 2004 02:07:19 -0000 1.1
+++ AnyAttributePropertySG.java 24 Jan 2004 22:16:46 -0000 1.2
@@ -85,7 +85,7 @@
private final XsSchemaHeader schemaHeader;
protected AnyAttributePropertySG(AttributeSG pAttribute, XSWildcard pWildcard) {
- super("anyAttribute", null, null, false, null);
+ super("anyAttribute", pAttribute.getSchema(), pWildcard, null, null);
namespaceList = pWildcard.getNamespaceList();
schemaHeader = pWildcard.getSchemaHeader();
}
1.1 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AnyElementPropertySG.java
Index: AnyElementPropertySG.java
===================================================================
package org.apache.ws.jaxme.generator.sg.impl;
import org.apache.ws.jaxme.generator.sg.ObjectSG;
import org.apache.ws.jaxme.generator.sg.PropertySG;
import org.apache.ws.jaxme.js.JavaField;
import org.apache.ws.jaxme.js.JavaMethod;
import org.apache.ws.jaxme.js.JavaSource;
import org.apache.ws.jaxme.js.Parameter;
import org.apache.ws.jaxme.xs.XSAny;
import org.xml.sax.SAXException;
/**
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public class AnyElementPropertySG extends JAXBPropertySG {
protected AnyElementPropertySG(ObjectSG pObjectSG, XSAny pAny) {
super("any", pObjectSG.getSchema(), pAny, null, null);
}
public JavaField getXMLField(PropertySG pController, JavaSource pSource) throws SAXException {
String fieldName = pController.getXMLFieldName();
JavaField result = pSource.newJavaField(fieldName, Object.class, JavaSource.PRIVATE);
return result;
}
public JavaMethod getXMLGetMethod(PropertySG pController, JavaSource pSource) throws SAXException {
String fieldName = pController.getXMLFieldName();
String methodName = pController.getXMLGetMethodName();
JavaMethod result = pSource.newJavaMethod(methodName, Object.class, JavaSource.PUBLIC);
result.addLine("return ", fieldName, ";");
return result;
}
public JavaMethod getXMLSetMethod(PropertySG pController, JavaSource pSource) throws SAXException {
String fieldName = pController.getXMLFieldName();
String methodName = pController.getXMLSetMethodName();
JavaMethod result = pSource.newJavaMethod(methodName, void.class, JavaSource.PUBLIC);
Parameter param = result.addParam(Object.class, "p" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1));
result.addLine(fieldName, " = ", param, ";");
return result;
}
}
1.6 +0 -7 ws-jaxme/src/test/jaxb/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/ws-jaxme/src/test/jaxb/build.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- build.xml 7 Jan 2004 02:07:19 -0000 1.5
+++ build.xml 24 Jan 2004 22:16:46 -0000 1.6
@@ -84,7 +84,6 @@
</target>
<target name="generate" depends="taskdef">
- <echo>basedir = ${basedir}</echo>
<xjc target="${srcdir}">
<schema dir="${basedir}" includes="*.xsd">
<exclude name="enumeration.xsd"/>
@@ -104,12 +103,6 @@
<produces dir="${srcdir}" includes="org/apache/ws/jaxme/test/misc/enumeration/*"/>
<produces dir="${srcdir}" includes="org/apache/ws/jaxme/test/misc/wildcards/*"/>
</xjc>
-<!--
- <xjc target="${srcdir}" extension="true">
- <schema dir="${basedir}/xkms" includes="xkms_bos.xsd"/>
- <arg line="-catalog ${basedir}/xkms/xkms.catalog"/>
- </xjc>
--->
</target>
<target name="compile" depends="generate">
1.2 +32 -0 ws-jaxme/src/test/jaxb/wildcards.xsd
Index: wildcards.xsd
===================================================================
RCS file: /home/cvs/ws-jaxme/src/test/jaxb/wildcards.xsd,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- wildcards.xsd 7 Jan 2004 02:07:19 -0000 1.1
+++ wildcards.xsd 24 Jan 2004 22:16:46 -0000 1.2
@@ -24,4 +24,36 @@
<xs:anyAttribute namespace="##targetNamespace http://ws.apache.org/jaxme/test/misc/wildcards/2"/>
</xs:complexType>
</xs:element>
+
+<!--
+ <xs:element name="AnyElement">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Header" type="xs:string"/>
+ <xs:any namespace="##any"/>
+ <xs:element name="Footer" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="OtherElement">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Header" type="xs:string"/>
+ <xs:any namespace="##other"/>
+ <xs:element name="Footer" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="ListElement">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Header" type="xs:string"/>
+ <xs:any namespace="##targetNamespace http://ws.apache.org/jaxme/test/misc/wildcards/2"/>
+ <xs:element name="Footer" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+-->
</xs:schema>
1.1 ws-jaxme/src/test/jaxb/simpleTypeRestriction.xsd
Index: simpleTypeRestriction.xsd
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://teamconnect.com"
targetNamespace="http://teamconnect.com">
<xs:simpleType name="ZNSecurityTypeIID">
<xs:annotation>
<xs:documentation/>
</xs:annotation>
<xs:restriction base="xs:int" >
<xs:enumeration value="0" />
<xs:enumeration value="2" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
1.1 ws-jaxme/src/test/jaxb/rss.xsd
Index: rss.xsd
===================================================================
<?xml version='1.0'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
<xs:annotation><xs:appinfo>
<jaxb:schemaBindings><jaxb:package name="org.apache.ws.jaxme.test.misc.rss"/></jaxb:schemaBindings>
</xs:appinfo></xs:annotation>
<xs:element name="rss">
<xs:complexType>
<xs:sequence>
<xs:element name="channel">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="title" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="link" type="xs:string"/>
<xs:element name="language" type="xs:string"/>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="title" type="xs:string"/>
<xs:element name="link" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="rating" minOccurs="0" type="xs:string"/>
<xs:element name="image" minOccurs="0">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="title" type="xs:string"/>
<xs:element name="url" type="xs:string"/>
<xs:element name="link" type="xs:string"/>
<xs:element name="width" type="xs:string"/>
<xs:element name="height" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="textinput" minOccurs="0">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="title" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="link" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="copyright" minOccurs="0" type="xs:string"/>
<xs:element name="pubDate" minOccurs="0" type="xs:string"/>
<xs:element name="lastBuildDate" minOccurs="0" type="xs:string"/>
<xs:element name="docs" minOccurs="0" type="xs:string"/>
<xs:element name="managingEditor" minOccurs="0" type="xs:string"/>
<xs:element name="webMaster" minOccurs="0" type="xs:string"/>
<xs:element name="skipHours" minOccurs="0" type="xs:string"/>
<xs:element name="skipDays" minOccurs="0" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="version" type="xs:string" fixed="0.91"/>
</xs:complexType>
</xs:element>
</xs:schema>
1.11 +30 -1 ws-jaxme/src/xs/org/apache/ws/jaxme/xs/junit/ParserTest.java
Index: ParserTest.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/xs/org/apache/ws/jaxme/xs/junit/ParserTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ParserTest.java 29 Oct 2003 18:38:06 -0000 1.10
+++ ParserTest.java 24 Jan 2004 22:16:46 -0000 1.11
@@ -933,4 +933,33 @@
assertEquals("b", elementOpenAttrs.getLocalName(0));
assertEquals("z", elementOpenAttrs.getValue(0));
}
+
+ public void testSimpleTypeRestriction() throws Exception {
+ final String schemaSource =
+ "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'\n" +
+ " xmlns='http://teamconnect.com'\n" +
+ " targetNamespace='http://teamconnect.com'>\n" +
+ " <xs:simpleType name='ZNSecurityTypeIID'>\n" +
+ " <xs:annotation>\n" +
+ " <xs:documentation/>\n" +
+ " </xs:annotation>\n" +
+ " <xs:restriction base='xs:int'>\n" +
+ " <xs:enumeration value='0'/>\n" +
+ " <xs:enumeration value='2'/>\n" +
+ " </xs:restriction>\n" +
+ " </xs:simpleType>\n" +
+ "</xs:schema>\n";
+ InputSource isource = new InputSource(new StringReader(schemaSource));
+ isource.setSystemId("testSimpleTypeRestriction.xsd");
+ XSParser xsParser = newXSParser();
+ XSSchema schema = xsParser.parse(isource);
+ XSType[] types = schema.getTypes();
+ assertEquals(1, types.length);
+ XSSimpleType simpleType = assertSimpleType(types[0]);
+ assertAtomicType(simpleType);
+ XSEnumeration[] enumerations = simpleType.getEnumerations();
+ assertEquals(2, enumerations.length);
+ assertEquals("0", enumerations[0].getValue());
+ assertEquals("2", enumerations[1].getValue());
+ }
}
1.4 +11 -0 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/SGFactory.java
Index: SGFactory.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/SGFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SGFactory.java 20 Oct 2003 20:32:42 -0000 1.3
+++ SGFactory.java 24 Jan 2004 22:16:46 -0000 1.4
@@ -49,6 +49,7 @@
package org.apache.ws.jaxme.generator.sg;
import org.apache.ws.jaxme.generator.Generator;
+import org.apache.ws.jaxme.xs.XSAny;
import org.apache.ws.jaxme.xs.XSElement;
import org.apache.ws.jaxme.xs.XSEnumeration;
import org.apache.ws.jaxme.xs.XSGroup;
@@ -119,6 +120,16 @@
* element in the given context.</p>
*/
public ObjectSG getObjectSG(XSElement pElement, Context pContext) throws SAXException;
+
+ /** <p>Creates a new instance of {@link ObjectSG} generating the given
+ * wildcard in the given context.</p>
+ */
+ public Object newObjectSG(XSAny any);
+
+ /** <p>Returns an instance of {@link ObjectSG} generating the given
+ * wildcard in the given context.</p>
+ */
+ public ObjectSG getObjectSG(XSAny pWildcard, Context pContext) throws SAXException;
/** <p>Creates a new instance of {@link GroupSG} generating the
* given schema.</p>
1.3 +1 -1 ws-jaxme/src/xs/org/apache/ws/jaxme/xs/XSAny.java
Index: XSAny.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/xs/org/apache/ws/jaxme/xs/XSAny.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSAny.java 26 Oct 2003 04:17:29 -0000 1.2
+++ XSAny.java 24 Jan 2004 22:16:46 -0000 1.3
@@ -51,6 +51,6 @@
/**
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
-public interface XSAny extends XSOpenAttrs {
+public interface XSAny extends XSWildcard {
}
1.1 ws-jaxme/src/xs/org/apache/ws/jaxme/xs/jaxb/JAXBAny.java
Index: JAXBAny.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The name "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package org.apache.ws.jaxme.xs.jaxb;
import org.apache.ws.jaxme.xs.XSAny;
/** <p>JAXB specific extension of XSAny.</p>
*
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public interface JAXBAny extends XSAny, JAXBWildcard {
}
1.1 ws-jaxme/src/xs/org/apache/ws/jaxme/xs/jaxb/JAXBWildcard.java
Index: JAXBWildcard.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The name "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package org.apache.ws.jaxme.xs.jaxb;
import org.apache.ws.jaxme.xs.XSWildcard;
/** <p>JAXB specific extension of XSWildcard.</p>
*
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public interface JAXBWildcard extends JAXBPropertyOwner, XSWildcard {
}
1.1 ws-jaxme/src/xs/org/apache/ws/jaxme/xs/jaxb/impl/JAXBWildcardImpl.java
Index: JAXBWildcardImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The name "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package org.apache.ws.jaxme.xs.jaxb.impl;
import org.apache.ws.jaxme.xs.XSObject;
import org.apache.ws.jaxme.xs.impl.XSUtil;
import org.apache.ws.jaxme.xs.impl.XSWildcardImpl;
import org.apache.ws.jaxme.xs.jaxb.JAXBProperty;
import org.apache.ws.jaxme.xs.jaxb.JAXBSchemaBindings;
import org.apache.ws.jaxme.xs.jaxb.JAXBWildcard;
import org.apache.ws.jaxme.xs.jaxb.JAXBXsSchema;
import org.apache.ws.jaxme.xs.xml.XsTWildcard;
import org.xml.sax.SAXException;
/**
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public class JAXBWildcardImpl extends XSWildcardImpl implements JAXBWildcard {
private JAXBProperty jaxbProperty;
protected JAXBWildcardImpl(XSObject pParent, XsTWildcard pBaseObject) {
super(pParent, pBaseObject);
}
public JAXBProperty getJAXBProperty() { return jaxbProperty; }
public void validate() throws SAXException {
if (isValidated()) {
return;
} else {
super.validate();
jaxbProperty = (JAXBProperty) XSUtil.getSingleAppinfo(getAnnotations(), JAXBProperty.class);
}
}
public JAXBSchemaBindings getJAXBSchemaBindings() {
return ((JAXBXsSchema) getXsObject().getXsESchema()).getJAXBSchemaBindings();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org