Author: jochen
Date: Sat Aug 13 17:34:05 2005
New Revision: 232552

URL: http://svn.apache.org/viewcvs?rev=232552&view=rev
Log:
The IDREF type has been implemented as string and not
as a reference to another object, as it should be.
PR: JAXME-58
Submitted by: Fredrik Vraalsen <fredrik at vraalsen.no>


Added:
    webservices/jaxme/trunk/src/test/jaxb/jira/jaxme-58.xsd
Modified:
    webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMElement.java
    webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMManager.java
    webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/ValidationEvents.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/MarshalChildsMethodGeneratingVisitor.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitor.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitorImpl.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDREFSG.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDSG.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Configuration.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JAXBContextImpl.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMMarshallerImpl.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMSAXDriverController.java
    
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMUnmarshallerHandlerImpl.java
    webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java
    webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/JavaMethod.java
    webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/Parameter.java
    webservices/jaxme/trunk/src/test/jaxb/defaults.xsd
    webservices/jaxme/trunk/status.xml

Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMElement.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMElement.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMElement.java 
(original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMElement.java Sat 
Aug 13 17:34:05 2005
@@ -12,7 +12,6 @@
  * 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.
-
  */
 package org.apache.ws.jaxme;
 

Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMManager.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMManager.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMManager.java 
(original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/JMManager.java Sat 
Aug 13 17:34:05 2005
@@ -21,6 +21,7 @@
 
 import org.apache.ws.jaxme.impl.JAXBContextImpl;
 import org.apache.ws.jaxme.impl.JMSAXDriver;
+import org.apache.ws.jaxme.impl.JMSAXDriverController;
 import org.apache.ws.jaxme.impl.JMSAXElementParser;
 import org.xml.sax.SAXException;
 
@@ -78,13 +79,21 @@
    */
   public JMSAXElementParser getHandler() throws SAXException;
 
-  /** Returns the document types driverr class.
+  /** Returns the document types driver class.
    */
   public Class getDriverClass();
 
   /** Returns an instance of the document types driver class.
    */
   public JMSAXDriver getDriver() throws SAXException;
+
+  /** Returns the document types driver controller class.
+   */
+  public Class getDriverControllerClass();
+
+  /** Returns an instance of the document types driver controller class.
+   */
+  public JMSAXDriverController getDriverController() throws SAXException;
 
   /** <p>Returns the persistency class. The persistency class
    * must be able to store documents in a database, update,

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/ValidationEvents.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/ValidationEvents.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/ValidationEvents.java 
(original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/ValidationEvents.java 
Sat Aug 13 17:34:05 2005
@@ -26,80 +26,88 @@
         * been used.
         */
        public static final String EVENT_CHOICE_GROUP_REUSE = 
"JM_EVENT_CHOICE_GROUP_REUSE";
-
-/** <p>A processing instruction was found. JaxMe doesn't know
-   * how to handle processing instruction, thus they are treated
-   * as a validation event, possibly throwing an exception.</p>
-   * <p>This behaviour is questionable. It may very well be changed
-   * at a later time, if another way of handling processing
-   * instructions is defined. However, if we throw an event now,
-   * the possible change is upwards compatible.</p>
-   */
-  public static final String EVENT_PROCESSING_INSTRUCTION = 
"JM_EVENT_PROCESSING_INSTRUCTION";
-
-  /** <p>A skipped entity was found. JaxMe doesn't know
-   * how to handle skipped entities, thus they are treated
-   * as a validation event, possibly throwing an exception.</p>
-   * <p>This behaviour is questionable. It may very well be changed
-   * at a later time, if another way of handling skipped
-   * entities is defined. However, if we throw an event now,
-   * the possible change is upwards compatible.</p>
-   */
-  public static final String EVENT_SKIPPED_ENTITY = "JM_EVENT_SKIPPED_ENTITY";
-
-  /** <p>Unexpected textual contents have been found. For example,
-   * a sequence must not have embedded text, because it would have
-   * mixed content otherwise. Textual content is ignored, if it
-   * consists of whitespace characters only.</p>
-   */
-  public static final String EVENT_UNEXPECTED_TEXTUAL_CONTENTS = 
"JM_EVENT_UNEXPECTED_TEXTUAL_CONTENTS";
-
-  /** <p>An unexpected child was found in an atomic element or in a
-   * complex element with simple content.</p>
-   */
-  public static final String EVENT_UNEXPECTED_CHILD_ELEMENT = 
"JM_EVENT_UNEXPECTED_CHILD_ELEMENT";
-
-  /**A childs of an all group was used more than once.
-   */
-  public static final String EVENT_ALL_GROUP_REUSE = 
"JM_EVENT_ALL_GROUP_REUSE";
-
-  /** <p>A child element was not expected at this place. For example,
-   * in the case of a choice, this may indicate that more than one
-   * of the possible elements have been found. In the case of a
-   * sequence, this can indicate a mismatch in the order of the
-   * child elements.</p>
-   */
-  public static final String EVENT_UNEXPECTED_CHILD_STATE = 
"JM_EVENT_UNEXPECTED_CHILD_STATE";
-
-  /** <p>A complex elements child is unknown. A possible reason
-   * is an error in the child elements name.</p>
-   */
-  public static final String EVENT_ADDITIONAL_CHILD_ELEMENT = 
"JM_EVENT_ADDITIONAL_CHILD_ELEMENT";
-
-  /** <p>An element occurred more than expected. In other words,
-   * the elements <code>maxOccurs</code> facet was violated.</p>
-   */
-  public static final String EVENT_MULTIPLE_OCCURRENCIES = 
"JM_EVENT_MULTIPLE_OCCURRENCIES";
-
-  /** <p>The root elements type was wrong.</p>
-   */
-  public static final String EVENT_WRONG_ROOT_ELEMENT = 
"JM_EVENT_WRONG_ROOT_ELEMENT";
-
-  /** <p>An element or attribute value was invalid. For example, in the
-   * case of a dateTime instance, this may indicate an unparseable date.</p>
-   */
-  public static final String EVENT_ILLEGAL_VALUE = "JM_EVENT_ILLEGAL_VALUE";
-
-  /** <p>An attribute was unknown.</p>
-   */
-  public static final String EVENT_UNKNOWN_ATTRIBUTE = 
"JM_EVENT_UNKNOWN_ATTRIBUTE";
-
-  /** <p>An attribute with an invalid namespace was detected in an
-   * element with an "anyAttribute" declaration.</p>
-   */
-  public static final String EVENT_UNKNOWN_ANY_ATTRIBUTE = 
"JM_EVENT_UNKNOWN_ANY_ATTRIBUTE";
-
-  /** Some of an elements child are missing.
-   */
-  public static final String EVENT_PREMATURE_END_ELEMENT = null;
+       
+       /** <p>A processing instruction was found. JaxMe doesn't know
+        * how to handle processing instruction, thus they are treated
+        * as a validation event, possibly throwing an exception.</p>
+        * <p>This behaviour is questionable. It may very well be changed
+        * at a later time, if another way of handling processing
+        * instructions is defined. However, if we throw an event now,
+        * the possible change is upwards compatible.</p>
+        */
+       public static final String EVENT_PROCESSING_INSTRUCTION = 
"JM_EVENT_PROCESSING_INSTRUCTION";
+       
+       /** <p>A skipped entity was found. JaxMe doesn't know
+        * how to handle skipped entities, thus they are treated
+        * as a validation event, possibly throwing an exception.</p>
+        * <p>This behaviour is questionable. It may very well be changed
+        * at a later time, if another way of handling skipped
+        * entities is defined. However, if we throw an event now,
+        * the possible change is upwards compatible.</p>
+        */
+       public static final String EVENT_SKIPPED_ENTITY = 
"JM_EVENT_SKIPPED_ENTITY";
+       
+       /** <p>Unexpected textual contents have been found. For example,
+        * a sequence must not have embedded text, because it would have
+        * mixed content otherwise. Textual content is ignored, if it
+        * consists of whitespace characters only.</p>
+        */
+       public static final String EVENT_UNEXPECTED_TEXTUAL_CONTENTS = 
"JM_EVENT_UNEXPECTED_TEXTUAL_CONTENTS";
+       
+       /** <p>An unexpected child was found in an atomic element or in a
+        * complex element with simple content.</p>
+        */
+       public static final String EVENT_UNEXPECTED_CHILD_ELEMENT = 
"JM_EVENT_UNEXPECTED_CHILD_ELEMENT";
+       
+       /**A childs of an all group was used more than once.
+        */
+       public static final String EVENT_ALL_GROUP_REUSE = 
"JM_EVENT_ALL_GROUP_REUSE";
+       
+       /** <p>A child element was not expected at this place. For example,
+        * in the case of a choice, this may indicate that more than one
+        * of the possible elements have been found. In the case of a
+        * sequence, this can indicate a mismatch in the order of the
+        * child elements.</p>
+        */
+       public static final String EVENT_UNEXPECTED_CHILD_STATE = 
"JM_EVENT_UNEXPECTED_CHILD_STATE";
+       
+       /** <p>A complex elements child is unknown. A possible reason
+        * is an error in the child elements name.</p>
+        */
+       public static final String EVENT_ADDITIONAL_CHILD_ELEMENT = 
"JM_EVENT_ADDITIONAL_CHILD_ELEMENT";
+       
+       /** <p>An element occurred more than expected. In other words,
+        * the elements <code>maxOccurs</code> facet was violated.</p>
+        */
+       public static final String EVENT_MULTIPLE_OCCURRENCIES = 
"JM_EVENT_MULTIPLE_OCCURRENCIES";
+       
+       /** <p>The root elements type was wrong.</p>
+        */
+       public static final String EVENT_WRONG_ROOT_ELEMENT = 
"JM_EVENT_WRONG_ROOT_ELEMENT";
+       
+       /** <p>An element or attribute value was invalid. For example, in the
+        * case of a dateTime instance, this may indicate an unparseable 
date.</p>
+        */
+       public static final String EVENT_ILLEGAL_VALUE = 
"JM_EVENT_ILLEGAL_VALUE";
+       
+       /** <p>An attribute was unknown.</p>
+        */
+       public static final String EVENT_UNKNOWN_ATTRIBUTE = 
"JM_EVENT_UNKNOWN_ATTRIBUTE";
+       
+       /** <p>An attribute with an invalid namespace was detected in an
+        * element with an "anyAttribute" declaration.</p>
+        */
+       public static final String EVENT_UNKNOWN_ANY_ATTRIBUTE = 
"JM_EVENT_UNKNOWN_ANY_ATTRIBUTE";
+       
+       /** Some of an elements child are missing.
+        */
+       public static final String EVENT_PREMATURE_END_ELEMENT = 
"JM_EVENT_PREMATURE_END_ELEMENT";
+
+       /** Ad ID attribute was declared twice.
+        */
+       public static final String EVENT_DUPLICATE_ID = "JM_EVENT_DUPLICATE_ID";
+
+    /** An IDREF attributes value was never declared as ID.
+     */
+    public static final String EVENT_IDREF_UNDECLARED = 
"JM_EVENT_IDREF_UNDECLARED";
 }

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
 Sat Aug 13 17:34:05 2005
@@ -155,4 +155,14 @@
    * "set" method <code>pMethod</code>.</p>
    */
   public void addValidation(JavaMethod pMethod, DirectAccessible pValue) 
throws SAXException;
+
+       /** Returns, whether the simple type is an instance of
+        * <code>xs:id</code>.
+        */
+       public boolean isXsId();
+
+       /** Returns, whether the simple type is an instance of
+        * <code>xs:idref</code>.
+        */
+       public boolean isXsIdRef();
 }

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java
 Sat Aug 13 17:34:05 2005
@@ -33,6 +33,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.ws.jaxme.XMLWriter;
+import org.apache.ws.jaxme.generator.sg.AttributeSG;
 import org.apache.ws.jaxme.generator.sg.ComplexContentSG;
 import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
 import org.apache.ws.jaxme.generator.sg.Context;
@@ -43,7 +44,10 @@
 import org.apache.ws.jaxme.generator.sg.SchemaSG;
 import org.apache.ws.jaxme.generator.sg.SchemaSGChain;
 import org.apache.ws.jaxme.generator.sg.TypeSG;
+import org.apache.ws.jaxme.generator.sg.impl.ccsg.SchemaVisitorImpl;
+import org.apache.ws.jaxme.generator.sg.impl.ccsg.SchemaWalker;
 import org.apache.ws.jaxme.impl.JAXBContextImpl;
+import org.apache.ws.jaxme.impl.JMSAXDriverController;
 import org.apache.ws.jaxme.impl.XMLWriterImpl;
 import org.apache.ws.jaxme.js.JavaConstructor;
 import org.apache.ws.jaxme.js.JavaField;
@@ -52,6 +56,7 @@
 import org.apache.ws.jaxme.js.JavaQNameImpl;
 import org.apache.ws.jaxme.js.JavaSource;
 import org.apache.ws.jaxme.js.JavaSourceFactory;
+import org.apache.ws.jaxme.js.LocalJavaField;
 import org.apache.ws.jaxme.js.Parameter;
 import org.apache.ws.jaxme.js.TextFile;
 import org.apache.ws.jaxme.logging.Logger;
@@ -343,6 +348,80 @@
     return new XsQName[]{XSNCName.getInstance().getName()};
   }
 
+  /** Used for generating the method
+   * [EMAIL PROTECTED] JMSAXDriverController#getXsIdAttribute(Object)}.
+   */
+  private class AttributeIdGenerator extends SchemaVisitorImpl {
+         private final List types = new ArrayList();
+         private final Map packages = new HashMap();
+         private final JavaSourceFactory factory;
+
+         AttributeIdGenerator(JavaSourceFactory pFactory) {
+                 factory = pFactory;
+         }
+
+         private AttributeSG getIdAttribute(TypeSG pType) {
+                 if (pType.isComplex()) {
+                         /* Check, if the super class has an ID attribute.
+                          * If so, do nothing and leave the ID handling to
+                          * super class.
+                          */
+                         if (!pType.isExtension()  ||
+                             getIdAttribute(pType.getExtendedType()) == null) {
+                                 AttributeSG[] attributes = 
pType.getComplexTypeSG().getAttributes();
+                                 for (int i = 0;  i < attributes.length;  i++) 
{
+                                         AttributeSG attr = attributes[i];
+                                         TypeSG type = attr.getTypeSG();
+                                         if (type != null  &&  
type.getSimpleTypeSG().isXsId()) {
+                                                 return attr;
+                                         }
+                                 }
+                         }
+                 }
+                 return null;
+         }
+
+         public void visit(TypeSG pType) {
+                       AttributeSG attr = getIdAttribute(pType);
+                       if (attr != null) {
+                               types.add(pType);
+                       }
+         }
+
+         protected JavaQName getJMSAXDriverControllerClass(String pPackage) 
throws SAXException {
+                 if (types.size() == 0) {
+                         return 
JavaQNameImpl.getInstance(JMSAXDriverController.class);
+                 }
+                 JavaQName qName = (JavaQName) packages.get(pPackage);
+                 if (qName == null) {
+                         qName = newDriverControllerClass(pPackage);
+                         packages.put(pPackage, qName);
+                 }
+                 return qName;
+         }
+
+         private JavaQName newDriverControllerClass(String pPackage) throws 
SAXException {
+                 JavaQName qName;
+                 qName = JavaQNameImpl.getInstance(pPackage + ".runtime", 
"JMSAXDriverController");
+                 JavaSource js = factory.newJavaSource(qName, 
JavaSource.PUBLIC);
+                 js.addExtends(JMSAXDriverController.class);
+                 JavaMethod jm = js.newJavaMethod("getXsIdAttribute", 
String.class, JavaSource.PUBLIC);
+                 Parameter param = jm.addParam(Object.class, "pObject");
+                 for (int i = 0;  i < types.size();  i++) {
+                         TypeSG tSG = (TypeSG) types.get(i);
+                         jm.addIf(i == 0, param, " instanceof ", 
tSG.getRuntimeType());
+                         LocalJavaField f = 
jm.newJavaField(tSG.getRuntimeType());
+                         f.addLine("(", tSG.getRuntimeType(), ") ", param);
+                         AttributeSG attr = getIdAttribute(tSG);
+                         jm.addLine("return ", 
attr.getPropertySG().getValue(f), ";");
+                 }
+                 jm.addElse();
+                 jm.addLine("return null;");
+                 jm.addEndIf();
+                 return qName;
+         }
+  }
+
   public Document getConfigFile(SchemaSG pController, String pPackageName, 
List pContextList)
       throws SAXException {
     final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@@ -360,6 +439,9 @@
     root.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns", uri);
     doc.appendChild(root);
 
+    AttributeIdGenerator attrIdGen = new 
AttributeIdGenerator(pController.getJavaSourceFactory());
+    new SchemaWalker(attrIdGen).walk(pController);
+
     for (Iterator iter = pContextList.iterator();  iter.hasNext();  ) {
       Object o = iter.next();
       Context ctx, typeCtx;
@@ -380,12 +462,16 @@
         continue;
       }
 
+      JavaQName implQName = ctx.getXMLImplementationName();
+      JavaQName jmSaxDriverControllerClass = 
attrIdGen.getJMSAXDriverControllerClass(implQName.getPackageName());
+
       Element manager = doc.createElementNS(uri, "Manager");
       root.appendChild(manager);
       manager.setAttributeNS(null, "elementInterface", 
ctx.getXMLInterfaceName().toString());
-      manager.setAttributeNS(null, "elementClass", 
ctx.getXMLImplementationName().toString());
+      manager.setAttributeNS(null, "elementClass", implQName.toString());
       manager.setAttributeNS(null, "handlerClass", 
typeCtx.getXMLHandlerName().toString());
       manager.setAttributeNS(null, "driverClass", 
typeCtx.getXMLSerializerName().toString());
+      manager.setAttributeNS(null, "driverControllerClass", 
jmSaxDriverControllerClass.toString());
       manager.setAttributeNS(null, "validatorClass", 
ctx.getXMLValidatorName().toString());
       if (o instanceof ObjectSG) {
                  XsQName name = ((ObjectSG) o).getName();
@@ -509,7 +595,7 @@
 
          generateCreateMethod(js, contextSet, typeSG, null);
     }
-    
+
     return js;
   }
 

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
 Sat Aug 13 17:34:05 2005
@@ -17,11 +17,13 @@
 
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 
 import javax.xml.bind.ValidationEvent;
 import javax.xml.namespace.QName;
 
+import org.apache.ws.jaxme.IDREF;
 import org.apache.ws.jaxme.ValidationEvents;
 import org.apache.ws.jaxme.generator.sg.AttributeSG;
 import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
@@ -34,10 +36,14 @@
 import org.apache.ws.jaxme.js.JavaQNameImpl;
 import org.apache.ws.jaxme.js.JavaSource;
 import org.apache.ws.jaxme.js.LocalJavaField;
+import org.apache.ws.jaxme.js.Parameter;
 import org.apache.ws.jaxme.js.TypedValue;
 import org.apache.ws.jaxme.js.impl.TypedValueImpl;
+import org.apache.ws.jaxme.xs.xml.XsQName;
 import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
 
 /** Base implementation of
@@ -106,9 +112,9 @@
                }
                
                JavaMethod jm = getJavaSource().newJavaMethod("addAttribute", 
JavaQNameImpl.VOID, JavaSource.PUBLIC);
-               DirectAccessible pURI = jm.addParam(String.class, "pURI");
-               DirectAccessible pLocalName = jm.addParam(String.class, 
"pLocalName");
-               DirectAccessible pValue = jm.addParam(String.class, "pValue");
+               Parameter pURI = jm.addParam(String.class, "pURI");
+               Parameter pLocalName = jm.addParam(String.class, "pLocalName");
+               Parameter pValue = jm.addParam(String.class, "pValue");
                jm.addThrows(SAXException.class);
                jm.addIf(pURI, " == null");
                jm.addLine(pURI, " = \"\";");
@@ -116,6 +122,7 @@
                
                JavaQName resultType = 
ctSG.getClassContext().getXMLInterfaceName();
                LocalJavaField result = jm.newJavaField(resultType);
+               result.setFinal(true);
                result.addLine("(", resultType, ") result");
 
                Set uris = createSetOfExplicitURIs(myAttributes);
@@ -138,9 +145,57 @@
                                
                                jm.addIf(firstInNamespace, 
JavaSource.getQuoted(attr.getName().getLocalName()), ".equals(", pLocalName, 
")");
                                firstInNamespace = false;
-                               createSimpleTypeConversion(jm, 
myAttributes[i].getTypeSG(), pValue,
-                                                                               
   "@" + myAttributes[i].getName(),
-                                                                               
   attr.getPropertySG(), result);
+                               boolean idref = false;
+                               if 
(attr.getTypeSG().getSimpleTypeSG().isXsId()) {
+                                       jm.addIf("!getHandler().addId(", 
pValue, ", ", result, ")");
+                                       
jm.addLine("getHandler().validationEvent(",
+                                                          
javax.xml.bind.ValidationEvent.class,
+                                                          ".ERROR, ",
+                                                          
JavaSource.getQuoted("Duplicate ID: "),
+                                                          " + ", pValue, ", ",
+                                                          
ValidationEvents.class,
+                                                          
".EVENT_DUPLICATE_ID, null);");
+                                       jm.addEndIf();
+                               } else if 
(attr.getTypeSG().getSimpleTypeSG().isXsIdRef()) {
+                                       idref = true;
+                                       try {
+                                               pValue.setFinal(true);
+                                               LocalJavaField locator = 
jm.newJavaField(Locator.class);
+                                               locator.setFinal(true);
+                                               
locator.addLine("getHandler().getDocumentLocator()");
+                                               
+                                               // FIXME how to properly create 
anonymous innner class?
+                                               LocalJavaField idrefField = 
jm.newJavaField(IDREF.class, "idref");
+                                               idrefField.addLine("new ", 
IDREF.class, "() {");
+                                               idrefField.addLine("  public 
void validate(", Map.class, " pIds) throws ", SAXException.class, " {");
+                                               idrefField.addLine("    Object 
o = pIds.get(", pValue, ");");
+                                               idrefField.addLine("    if (o 
!= null) {");
+                                               idrefField.addLine("      ", 
result, ".", attr.getPropertySG().getXMLSetMethodName(), "(", "o", ");");
+                                               idrefField.addLine("    } else 
{");
+                                               idrefField.addLine("      final 
String msg = ",
+                                                                               
   JavaSource.getQuoted("ID attribute '"),
+                                                                               
   " + ", pValue, " + ",
+                                                                               
   JavaSource.getQuoted("' was referenced but never declared"), ";");
+                                               idrefField.addLine("      ", 
SAXParseException.class, " e = new ",
+                                                                              
SAXParseException.class, "(msg, ", locator, ");");
+                                               idrefField.addLine("      
getHandler().validationEvent(",
+                                                                               
   javax.xml.bind.ValidationEvent.class,
+                                                                               
   ".ERROR, msg,",
+                                                                               
   ValidationEvents.class,
+                                                                               
   ".EVENT_IDREF_UNDECLARED, e);");
+                                               idrefField.addLine("    }");
+                                               idrefField.addLine("  }");
+                                               idrefField.addLine("};");
+                                               
jm.addLine("getHandler().addIdref(", idrefField, ");");
+                                       } catch (Exception e) {
+                                               e.printStackTrace();
+                                       }
+                               }
+                               if (!idref) {
+                                       createSimpleTypeConversion(jm, 
myAttributes[i].getTypeSG(), pValue,
+                                                                               
           "@" + myAttributes[i].getName(),
+                                                                               
           attr.getPropertySG(), result);
+                               }
                                jm.addLine("return;");
                        }
                        if (!firstInNamespace) {

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/MarshalChildsMethodGeneratingVisitor.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/MarshalChildsMethodGeneratingVisitor.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/MarshalChildsMethodGeneratingVisitor.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/MarshalChildsMethodGeneratingVisitor.java
 Sat Aug 13 17:34:05 2005
@@ -1,5 +1,17 @@
-/**
+/*
+ * Copyright 2005  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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.ws.jaxme.generator.sg.impl.ccsg;
 

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitor.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitor.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitor.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitor.java
 Sat Aug 13 17:34:05 2005
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2005  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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.ws.jaxme.generator.sg.impl.ccsg;
 
 import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitorImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitorImpl.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitorImpl.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/ParticleVisitorImpl.java
 Sat Aug 13 17:34:05 2005
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2005  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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.ws.jaxme.generator.sg.impl.ccsg;
 
 import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDREFSG.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDREFSG.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDREFSG.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDREFSG.java
 Sat Aug 13 17:34:05 2005
@@ -17,17 +17,71 @@
 package org.apache.ws.jaxme.generator.types;
 
 import org.apache.ws.jaxme.generator.sg.SGFactory;
+import org.apache.ws.jaxme.generator.sg.SGlet;
 import org.apache.ws.jaxme.generator.sg.SchemaSG;
+import org.apache.ws.jaxme.generator.sg.SimpleTypeSG;
+import org.apache.ws.jaxme.js.DirectAccessible;
+import org.apache.ws.jaxme.js.JavaMethod;
+import org.apache.ws.jaxme.js.JavaQName;
+import org.apache.ws.jaxme.js.JavaQNameImpl;
+import org.apache.ws.jaxme.js.JavaSource;
+import org.apache.ws.jaxme.js.LocalJavaField;
+import org.apache.ws.jaxme.js.TypedValue;
+import org.apache.ws.jaxme.js.impl.TypedValueImpl;
 import org.apache.ws.jaxme.xs.XSType;
 import org.xml.sax.SAXException;
 
 /**
  * @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
  */
-public class IDREFSG extends StringSG {
-  /** <p>Creates a new instance of IDREFSG.</p>
-   */
-  public IDREFSG(SGFactory pFactory, SchemaSG pSchema, XSType pType) throws 
SAXException {
-    super(pFactory, pSchema, pType);
-  }
+public class IDREFSG extends SimpleTypeSGImpl {
+       private static final JavaQName OBJECT_TYPE = 
JavaQNameImpl.getInstance(Object.class);
+
+       /** <p>Creates a new instance of IDREFSG.</p>
+        */
+       public IDREFSG(SGFactory pFactory, SchemaSG pSchema, XSType pType) 
throws SAXException {
+               super(pFactory, pSchema, pType);
+       }
+
+       public JavaQName getRuntimeType(SimpleTypeSG pController) { return 
OBJECT_TYPE; }
+       public boolean isCausingParseConversionEvent(SimpleTypeSG pController) 
{ return false; }
+       public boolean isXsIdRef(SimpleTypeSG pController) { return true; }
+
+       public TypedValue getCastFromString(SimpleTypeSG pController, 
JavaMethod pMethod, Object pValue, Object pData) throws SAXException {
+           return new TypedValueImpl(null, OBJECT_TYPE);
+       }
+
+       public TypedValue getCastToString(SimpleTypeSG pController, JavaMethod 
pMethod, Object pValue, DirectAccessible pData) throws SAXException {
+               LocalJavaField s = pMethod.newJavaField(String.class);
+               pMethod.addIf(pValue, " == null");
+               pMethod.addLine(s, " = null;");
+               pMethod.addElse();
+               pMethod.addLine(s, " = ", pData, ".getXsIdAttribute(", pValue, 
");");
+               pMethod.addIf(s, " == null");
+               pMethod.addThrowNew(IllegalStateException.class,
+                                                       
JavaSource.getQuoted("ID attribute not set"));
+               pMethod.addEndIf();
+               pMethod.addEndIf();
+               return s;
+       }
+
+       public TypedValue getCastFromString(SimpleTypeSG pController, String 
pValue) throws SAXException {
+               throw new IllegalStateException("Unable to resolve ID's at 
compile time.");
+       }
+
+       public void forAllValues(SimpleTypeSG pController, JavaMethod pMethod, 
Object pValue, SGlet pSGlet) throws SAXException {
+           pSGlet.generate(pMethod, pValue);
+       }
+
+       public void forAllNonNullValues(SimpleTypeSG pController, JavaMethod 
pMethod, Object pValue, SGlet pSGlet) throws SAXException {
+           LocalJavaField f = pMethod.newJavaField(OBJECT_TYPE);
+           f.addLine(pValue);
+           pMethod.addIf(f, " != null");
+           pSGlet.generate(pMethod, pValue);
+           pMethod.addEndIf();
+       }
+
+       public Object getEqualsCheck(SimpleTypeSG pController, JavaMethod 
pMethod, Object pValue1, Object pValue2) throws SAXException {
+           return new Object[]{pValue1, ".equals(", pValue2, ")"};
+       }
 }

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDSG.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDSG.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDSG.java 
(original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/IDSG.java 
Sat Aug 13 17:34:05 2005
@@ -18,19 +18,20 @@
 
 import org.apache.ws.jaxme.generator.sg.SGFactory;
 import org.apache.ws.jaxme.generator.sg.SchemaSG;
+import org.apache.ws.jaxme.generator.sg.SimpleTypeSG;
 import org.apache.ws.jaxme.xs.XSType;
 import org.xml.sax.SAXException;
 
 
-/**
- * @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
+/** Implementation of [EMAIL PROTECTED] 
org.apache.ws.jaxme.generator.sg.SimpleTypeSG}
+ * for <code>xs:id</code>.
  */
 public class IDSG extends StringSG {
+       /** Creates a new instance of IDSG.
+        */
+       public IDSG(SGFactory pFactory, SchemaSG pSchema, XSType pType) throws 
SAXException {
+               super(pFactory, pSchema, pType);
+       }
 
-  /** <p>Creates a new instance of IDSG.</p>
-   */
-  public IDSG(SGFactory pFactory, SchemaSG pSchema, XSType pType) throws 
SAXException {
-    super(pFactory, pSchema, pType);
-  }
-
+       public boolean isXsId(SimpleTypeSG pController) { return true; }
 }

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java
 Sat Aug 13 17:34:05 2005
@@ -56,6 +56,8 @@
   public boolean isAtomic(SimpleTypeSG pController) { return false; }
   public boolean isList(SimpleTypeSG pController) { return false; }
   public boolean isUnion(SimpleTypeSG pController) { return false; }
+  public boolean isXsId(SimpleTypeSG pController) { return false; }
+  public boolean isXsIdRef(SimpleTypeSG pController) { return false; }
   public boolean hasSetMethod(SimpleTypeSG pController) { return true; }
   public void setNullable(SimpleTypeSG pController, boolean pNullable) {
     setNullable(pNullable);

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Configuration.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Configuration.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Configuration.java 
(original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Configuration.java 
Sat Aug 13 17:34:05 2005
@@ -77,6 +77,7 @@
     private Class elementClass;
     private Class handlerClass;
     private Class driverClass;
+    private Class driverControllerClass;
     private Class pmClass;
        private String prefix;
     private Map properties;
@@ -189,13 +190,44 @@
                try {
                        return elementClass.newInstance();
                } catch (InstantiationException e) {
-                       throw new SAXException("Unable to instantiate handler 
class "
-                                                                  + 
jmUnmarshallerClass.getName(), e);
+                       throw new SAXException("Unable to instantiate element 
class "
+                                                                  + 
elementClass.getName(), e);
                } catch (IllegalAccessException e) {
-                       throw new SAXException("Illegal access to handler class 
"
-                                                                  + 
jmUnmarshallerClass.getName(), e);
+                       throw new SAXException("Illegal access to element class 
"
+                                                                  + 
elementClass.getName(), e);
                }
     }
+
+       public JMSAXDriverController getDriverController() throws SAXException {
+               try {
+                       return (JMSAXDriverController) 
driverControllerClass.newInstance();
+               } catch (InstantiationException e) {
+                       throw new SAXException("Unable to instantiate driver 
controller class "
+                                                                  + 
driverControllerClass.getName(), e);
+               } catch (IllegalAccessException e) {
+                       throw new SAXException("Illegal access to driver 
controller class "
+                                                                  + 
driverControllerClass.getName(), e);
+               }
+       }
+
+       /** Returns the subclass of [EMAIL PROTECTED] JMSAXDriverController},
+        * which is being used for marshalling this object.
+        */
+       public Class getDriverControllerClass() {
+               return driverControllerClass;
+       }
+
+       /** Sets the subclass of [EMAIL PROTECTED] JMSAXDriverController},
+        * which is being used for marshalling this object.
+        */
+       public void setDriverControllerClass(String pDriverControllerClass) 
throws ClassNotFoundException {
+               driverControllerClass = 
context.getClassLoader().loadClass(pDriverControllerClass);
+               if 
(!JMSAXDriverController.class.isAssignableFrom(driverControllerClass)) {
+                       throw new IllegalStateException("The class " + 
driverControllerClass.getName()
+                                                                               
        + " is not implementing "
+                                                                               
        + JMSAXDriverController.class.getName());
+               }
+       }
   }
 
   /** <p>Creates a new Manager.</p>

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JAXBContextImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JAXBContextImpl.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JAXBContextImpl.java 
(original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JAXBContextImpl.java 
Sat Aug 13 17:34:05 2005
@@ -458,10 +458,13 @@
        if (pManager.getDriverClass() == null) {
                throw new IllegalStateException("Missing driver class for " + 
pManager.getQName());
        }
+       if (pManager.getDriverControllerClass() == null) {
+               throw new IllegalStateException("Missing driver controller 
class for " + pManager.getQName());
+       }
        if (pManager.getHandlerClass() == null) {
                throw new IllegalStateException("Missing driver class for " + 
pManager.getQName());
        }
-       
+
     QName qName = pManager.getQName();
     if (qName != null  &&  managersByQName.containsKey(qName)) {
       throw new JAXBException("A Manager for document type " + qName +

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMMarshallerImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMMarshallerImpl.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMMarshallerImpl.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMMarshallerImpl.java
 Sat Aug 13 17:34:05 2005
@@ -12,7 +12,6 @@
  * 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.
-
  */
 package org.apache.ws.jaxme.impl;
 
@@ -360,7 +359,8 @@
     try {
                JMManager manager = getJAXBContextImpl().getManager(qName);
                JMSAXDriver driver = manager.getDriver();
-               JMSAXDriverController controller = new 
JMSAXDriverController(this, pHandler);
+               JMSAXDriverController controller = 
manager.getDriverController();
+               controller.init(this, pHandler);
                controller.marshal(driver, qName.getPrefix(), 
qName.getNamespaceURI(), qName.getLocalPart(), element);
     } catch (SAXException e) {
       throw new MarshalException(e);

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMSAXDriverController.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMSAXDriverController.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMSAXDriverController.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMSAXDriverController.java
 Sat Aug 13 17:34:05 2005
@@ -36,9 +36,9 @@
  */
 public class JMSAXDriverController {
        private static final Attributes ZERO_ATTRIBUTES = new AttributesImpl();
-       private final JMMarshallerImpl marshaller;
-       private final DatatypeConverterInterface converter;
-       private final ContentHandler target;
+       private JMMarshallerImpl marshaller;
+       private DatatypeConverterInterface converter;
+       private ContentHandler target;
     private final NamespaceSupport nss = new NamespaceSupport();
        private int cnt;
 
@@ -61,9 +61,9 @@
                return nss;
     }
 
-       /** Creates a new instance with the given marshaller and target.
+       /** Initializes the controller by setting marshaller and target.
         */
-       public JMSAXDriverController(JMMarshallerImpl pMarshaller, 
ContentHandler pTarget) throws SAXException {
+       public void init(JMMarshallerImpl pMarshaller, ContentHandler pTarget) 
throws SAXException {
                marshaller = pMarshaller;
                target = pTarget;
                converter = marshaller.getDatatypeConverter();
@@ -260,6 +260,8 @@
                }
        }
 
+       /** Fires a [EMAIL PROTECTED] javax.xml.bind.PrintConversionEvent}.
+        */
        public void printConversionEvent(Object pObject, String pMsg, Exception 
pException) throws SAXException {
                ValidationEventHandler handler = 
getJMMarshaller().getEventHandler();
                if (handler != null) {
@@ -269,6 +271,17 @@
                                return;
                        }
                }
-               throw new SAXException(pMsg, pException);
+               if (pException instanceof SAXException) {
+                       throw (SAXException) pException;
+               } else {
+                       throw new SAXException(pMsg, pException);
+               }
        }
+
+       /** Returns an ID for the object <code>pObject</code>.
+        * The default implementation returns null. This method
+        * is being overwritten by subclasses.
+        * @param pObject The object for which an ID is being queried.
+        */
+       public String getXsIdAttribute(Object pObject) { return null; }
 }

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMUnmarshallerHandlerImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMUnmarshallerHandlerImpl.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMUnmarshallerHandlerImpl.java
 (original)
+++ 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/JMUnmarshallerHandlerImpl.java
 Sat Aug 13 17:34:05 2005
@@ -17,17 +17,22 @@
 package org.apache.ws.jaxme.impl;
 
 import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.bind.DatatypeConverterInterface;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.ValidationEvent;
 import javax.xml.bind.ValidationEventHandler;
 import javax.xml.bind.helpers.ParseConversionEventImpl;
+import javax.xml.bind.helpers.PrintConversionEventImpl;
 import javax.xml.bind.helpers.ValidationEventImpl;
 import javax.xml.bind.helpers.ValidationEventLocatorImpl;
 import javax.xml.namespace.QName;
 
+import org.apache.ws.jaxme.IDREF;
 import org.apache.ws.jaxme.JMManager;
 import org.apache.ws.jaxme.JMUnmarshaller;
 import org.apache.ws.jaxme.JMUnmarshallerHandler;
@@ -74,6 +79,8 @@
     private final StringBuffer sb = new StringBuffer();
        private Observer observer;
        private Object result;
+       private final Map idMap = new HashMap();
+       private final List idrefs = new ArrayList();
 
     public int getLevel() { return level; }
 
@@ -131,6 +138,10 @@
     }
 
     public void endDocument() throws SAXException {
+       for (Iterator i = idrefs.iterator(); i.hasNext();) {
+                       IDREF idref = (IDREF) i.next();
+                       idref.validate(idMap);
+               }
     }
 
     public void startPrefixMapping(String pPrefix, String pURI) throws 
SAXException {
@@ -313,6 +324,9 @@
         */
        public void parseConversionEvent(String pMsg, Exception pException) 
throws SAXException {
                ParseConversionEventImpl event = new 
ParseConversionEventImpl(ValidationEvent.FATAL_ERROR, pMsg, null);
+               if (locator != null) {
+                       event.setLocator(new 
ValidationEventLocatorImpl(locator));
+               }
                handleEvent(event, pException);
        }
 
@@ -320,15 +334,22 @@
         */
        public void validationEvent(int pSeverity, String pMsg, String 
pErrorCode,
                                                                Exception 
pException) throws SAXException {
+               validationEvent(pSeverity, pMsg, pErrorCode, pException, 
locator);
+       }
+
+       /** Posts a [EMAIL PROTECTED] ValidationEvent}.
+        */
+       public void validationEvent(int pSeverity, String pMsg, String 
pErrorCode,
+                                                               Exception 
pException, Locator pLocator) throws SAXException {
                org.apache.ws.jaxme.impl.ValidationEventImpl event = new 
org.apache.ws.jaxme.impl.ValidationEventImpl(pSeverity, pMsg, null);
                event.setErrorCode(pErrorCode);
+               if (pLocator != null) {
+                       event.setLocator(new 
ValidationEventLocatorImpl(pLocator));
+               }
                handleEvent(event, pException);
        }
 
        private void handleEvent(ValidationEventImpl pEvent, Exception 
pException) throws SAXException {
-               if (locator != null) {
-                       pEvent.setLocator(new 
ValidationEventLocatorImpl(locator));
-               }
                if (pException != null) {
                        pEvent.setLinkedException(pException);
                }
@@ -339,6 +360,9 @@
                        throw new SAXException(e);
                }
                if (eventHandler == null  ||  
!eventHandler.handleEvent(pEvent)) {
+                       if (pException != null  &&  pException instanceof 
SAXParseException) {
+                               throw (SAXParseException) pException;
+                       }
                        String msg = pEvent.getMessage();
                        if (pEvent instanceof 
org.apache.ws.jaxme.impl.ValidationEventImpl) {
                                String errorCode = 
((org.apache.ws.jaxme.impl.ValidationEventImpl) pEvent).getErrorCode();
@@ -394,4 +418,25 @@
                        state = STATE_GROUP;
                }
        }
+       
+       /**
+        * @param id XML ID attribute of JAXB object
+        * @param jaxbObject the JAXB object
+        * @throws SAXException if duplicate ID
+        */
+       public boolean addId(String id, Object jaxbObject) throws SAXException {
+               if (idMap.containsKey(id)) {
+                       return false;
+               }
+               idMap.put(id, jaxbObject);
+               return true;
+       }
+       
+       /**
+        * @param idref
+        */
+       public void addIdref(IDREF idref) {
+               idrefs.add(idref);
+       }
+       
 }

Modified: 
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java 
(original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java 
Sat Aug 13 17:34:05 2005
@@ -16,12 +16,17 @@
 import net.dspc.commons.activitymodel2.Body2;
 import net.dspc.commons.activitymodel2.ObjectFactory;
 
+import org.apache.ws.jaxme.ValidationEvents;
 import org.apache.ws.jaxme.generator.Generator;
 import org.apache.ws.jaxme.generator.SchemaReader;
 import org.apache.ws.jaxme.generator.impl.GeneratorImpl;
 import org.apache.ws.jaxme.generator.sg.SchemaSG;
 import org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader;
 import org.apache.ws.jaxme.generator.util.JavaNamer;
+import org.apache.ws.jaxme.impl.ValidationEventImpl;
+import org.apache.ws.jaxme.test.jira.jaxme58.AuthorType;
+import org.apache.ws.jaxme.test.jira.jaxme58.BookType;
+import org.apache.ws.jaxme.test.jira.jaxme58.Booklist;
 import org.apache.ws.jaxme.test.jira.jaxme65.Jaxme65;
 import org.apache.ws.jaxme.test.jira.jaxme65.Jaxme65Type;
 import org.apache.ws.jaxme.test.misc.types.Jira62;
@@ -175,12 +180,15 @@
        }
 
        private static class EventDetector implements ValidationEventHandler {
-               private boolean gotEvent = false;
+               private ValidationEvent event;
                public boolean handleEvent(ValidationEvent pEvent) {
-                       gotEvent = true;
+                       if (event == null) {
+                               event = pEvent;
+                       }
                        return true;
                }
-               boolean isSuccess() { return !gotEvent; }
+               boolean isSuccess() { return event == null; }
+               ValidationEventImpl getEvent() { return (ValidationEventImpl) 
event; }
        };
 
        private void runFacetTest(int i, String pAttrName, boolean pSuccess) 
throws JAXBException {
@@ -256,5 +264,56 @@
                List list2 = text2.getContent();
                assertEquals(1, list2.size());
                assertEquals("some text", list2.get(0));
+       }
+
+       /** Test for <a 
href="http://issues.apache.org/jira/browse/JAXME-58";>JAXME-58</a>.
+        */
+       public void testJAXME58() throws Exception {
+               final String xml1 = getBooklist(false, false);
+               final JAXBContext ctx = getJAXBContext(Booklist.class);
+               Unmarshaller unmarshaller = ctx.createUnmarshaller();
+               final Booklist booklist = (Booklist) unmarshaller.unmarshal(new 
InputSource(new StringReader(xml1)));
+               final List books = booklist.getBook();
+               assertEquals(2, books.size());
+               final BookType hi = (BookType) books.get(0);
+               final BookType helloAgain = (BookType) books.get(1);
+               final List authors = booklist.getAuthor();
+               assertEquals(2, authors.size());
+               final AuthorType bill = (AuthorType) authors.get(0);
+               final AuthorType bob = (AuthorType) authors.get(1);
+               assertSame(hi.getAuthor(), bill);
+               assertSame(helloAgain.getAuthor(), bob);
+
+               final String xml2 = getBooklist(true, false);
+               EventDetector detector2 = new EventDetector();
+               unmarshaller.setEventHandler(detector2);
+               unmarshaller.unmarshal(new InputSource(new StringReader(xml2)));
+               assertTrue(!detector2.isSuccess());
+               assertEquals(ValidationEvents.EVENT_IDREF_UNDECLARED, 
detector2.getEvent().getErrorCode());
+
+               final String xml3 = getBooklist(false, true);
+               EventDetector detector3 = new EventDetector();
+               unmarshaller.setEventHandler(detector3);
+               unmarshaller.unmarshal(new InputSource(new StringReader(xml3)));
+               assertTrue(!detector3.isSuccess());
+               assertEquals(ValidationEvents.EVENT_DUPLICATE_ID, 
detector3.getEvent().getErrorCode());
+       }
+
+       private String getBooklist(boolean pUndeclaredId, boolean pDuplicateId) 
{
+               String result =
+                       "<booklist 
xmlns='http://ws.apache.org/jaxme/test/jira/jaxme58'>\n"
+                       + "  <book title='hi' author='a1'/>\n"
+                       + "  <book title='hello again' author='a2'/>\n";
+               if (pUndeclaredId) {
+                       result += "  <book title='hello there!' 
author='a3'/>\n";
+               }
+               result +=
+                       "  <author id='a1' name='Bill'/>\n"
+                       + "  <author id='a2' name='Bob'/>\n";
+               if (pDuplicateId) {
+                       result += "  <author id='a2' name='Ben'/>\n";
+               }
+               result += "</booklist>\n";
+               return result;
        }
 }

Modified: webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/JavaMethod.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/JavaMethod.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/JavaMethod.java 
(original)
+++ webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/JavaMethod.java Sat 
Aug 13 17:34:05 2005
@@ -76,6 +76,9 @@
         pTarget.write(", ");
       }
       Parameter p = params[i];
+      if (p.isFinal()) {
+         pTarget.write("final ");
+      }
       pTarget.write(pTarget.asString(p.getType()) );
       pTarget.write(" ");
       pTarget.write(p.getName());

Modified: webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/Parameter.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/Parameter.java?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/Parameter.java 
(original)
+++ webservices/jaxme/trunk/src/js/org/apache/ws/jaxme/js/Parameter.java Sat 
Aug 13 17:34:05 2005
@@ -24,21 +24,32 @@
  * @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
  */
 public class Parameter implements DirectAccessible, IndentedObject {
-  private final JavaQName type;
-  private final String name;
-  private boolean isNullable = true;
-
-  public Parameter(JavaQName pType, String pName) {
-    type = pType;
-    name = pName;
-  }
-  public JavaQName getType() { return type; }
-  public String getName() { return name; }
-  public String toString() { return type.toString() + " " + name; }
-  public void write(IndentationEngine pEngine, IndentationTarget pTarget)
-      throws IOException {
-    pEngine.write(pTarget, getName());
-  }
-  public boolean isNullable() { return isNullable; }
-  public void setNullable(boolean pNullable) { isNullable = pNullable; }
+       private final JavaQName type;
+       private final String name;
+       private boolean isNullable = true;
+       private boolean isFinal;
+       
+       public Parameter(JavaQName pType, String pName) {
+               type = pType;
+               name = pName;
+       }
+       public JavaQName getType() { return type; }
+       public String getName() { return name; }
+       public String toString() { return type.toString() + " " + name; }
+       public void write(IndentationEngine pEngine, IndentationTarget pTarget)
+       throws IOException {
+               pEngine.write(pTarget, getName());
+       }
+       public boolean isNullable() { return isNullable; }
+       public void setNullable(boolean pNullable) { isNullable = pNullable; }
+       /** Sets, whether the parameter is final.
+        */
+       public void setFinal(boolean pFinal) {
+               isFinal = pFinal;
+       }
+       /** Returns, whether the parameter is final.
+        */
+       public boolean isFinal() {
+               return isFinal;
+       }
 }

Modified: webservices/jaxme/trunk/src/test/jaxb/defaults.xsd
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/test/jaxb/defaults.xsd?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
Binary files - no diff available.

Added: webservices/jaxme/trunk/src/test/jaxb/jira/jaxme-58.xsd
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/test/jaxb/jira/jaxme-58.xsd?rev=232552&view=auto
==============================================================================
--- webservices/jaxme/trunk/src/test/jaxb/jira/jaxme-58.xsd (added)
+++ webservices/jaxme/trunk/src/test/jaxb/jira/jaxme-58.xsd Sat Aug 13 17:34:05 
2005
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<xs:schema targetNamespace="http://ws.apache.org/jaxme/test/jira/jaxme58"; 

+               xmlns="http://ws.apache.org/jaxme/test/jira/jaxme58"; 

+               xmlns:xs="http://www.w3.org/2001/XMLSchema"; 

+               elementFormDefault="qualified">

+  <xs:complexType name="bookType">

+    <xs:attribute name="title" type="xs:string"/>

+    <xs:attribute name="author" type="xs:IDREF"/>

+  </xs:complexType>

+

+  <xs:complexType name="authorType">

+    <xs:attribute name="id" type="xs:ID"/>

+       <xs:attribute name="name" type="xs:string"/>

+  </xs:complexType>

+

+  <xs:element name="booklist">

+    <xs:complexType>

+      <xs:sequence>

+        <xs:element name="book" type="bookType" maxOccurs="unbounded"/>

+               <xs:element name="author" type="authorType" 
maxOccurs="unbounded"/>

+         </xs:sequence>

+       </xs:complexType>

+  </xs:element>

+</xs:schema>


Modified: webservices/jaxme/trunk/status.xml
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/status.xml?rev=232552&r1=232551&r2=232552&view=diff
==============================================================================
--- webservices/jaxme/trunk/status.xml (original)
+++ webservices/jaxme/trunk/status.xml Sat Aug 13 17:34:05 2005
@@ -40,6 +40,11 @@
         The ChoiceHandlerSG did not treat a choice
         with minOccurs="0" as optional. (JAXME-65)
       </action>
+      <action dev="JW" type="fix" context="generator">
+        The IDREF type has been implemented as string and not
+        as a reference to another object, as it should be.
+        (JAXME-58, Fredrik Vraalsen <fredrik at vraalsen.no>)
+      </action>
     </release>
        <release version="0.5" date="2005-Aug-08">
       <action dev="JW" type="enhancement" context="js">



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to