You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Andrew McGhee <an...@health.qld.gov.au> on 2008/02/19 00:38:08 UTC

Fwd: axis2 mailing list: Why aren't schema restrictions being generated?

Hi,
 
Does anyone know why my restrictions are not being generated by Axis2 1.3 Wsdl2Java?
 
Here is an extract of the WSDL...
            <xsd:element name="ID">
             <xsd:simpleType>
              <xsd:restriction base="xsd:string">
               <xsd:minLength value="1"></xsd:minLength>
               <xsd:maxLength value="40"></xsd:maxLength>
              </xsd:restriction>
             </xsd:simpleType>
            </xsd:element>
 
And here is the resulting class...

/**
 * ID.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis2 version: #axisVersion# #today#
 */
 
package mypackage;
 
/**
 * ID bean class
 */
 
public class ID implements org.apache.axis2.databinding.ADBBean {
 
    public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
            "urn:SigningServices_v1_0_0.secureServices.health.qld.gov.au", "ID", "ns2");
 
    /**
     * field for ID
     */
 
    protected java.lang.String localID;
 
    /**
     * Auto generated getter method
     * 
     * @return java.lang.String
     */
    public java.lang.String getID() {
        return localID;
    }
 
    /**
     * Auto generated setter method
     * 
     * @param param
     *            ID
     */
    public void setID(java.lang.String param) {
 
        this.localID = param;
 
    }
 
    /**
     * 
     * @param parentQName
     * @param factory
     * @return org.apache.axiom.om.OMElement
     */
    public org.apache.axiom.om.OMElement getOMElement(final javax.xml.namespace.QName parentQName,
            final org.apache.axiom.om.OMFactory factory) {
 
        org.apache.axiom.om.OMDataSource dataSource = new org.apache.axis2.databinding.ADBDataSource(this, parentQName) {
 
            public void serialize(javax.xml.stream.XMLStreamWriter xmlWriter)
                    throws javax.xml.stream.XMLStreamException {
 
                java.lang.String prefix = parentQName.getPrefix();
                java.lang.String namespace = parentQName.getNamespaceURI();
 
                if (namespace != null) {
                    java.lang.String writerPrefix = xmlWriter.getPrefix(namespace);
                    if (writerPrefix != null) {
                        xmlWriter.writeStartElement(namespace, parentQName.getLocalPart());
                    }
                    else {
                        if (prefix == null) {
                            prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
                        }
 
                        xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace);
                        xmlWriter.writeNamespace(prefix, namespace);
                        xmlWriter.setPrefix(prefix, namespace);
                    }
                }
                else {
                    xmlWriter.writeStartElement(parentQName.getLocalPart());
                }
 
                if (localID == null) {
                    // write the nil attribute
 
                    throw new RuntimeException("ID cannot be null!!");
 
                }
                else {
 
                    xmlWriter
                            .writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localID));
 
                }
 
                xmlWriter.writeEndElement();
 
            }
 
            /**
             * Util method to write an attribute with the ns prefix
             */
            private void writeAttribute(java.lang.String prefix, java.lang.String namespace, java.lang.String attName,
                    java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter)
                    throws javax.xml.stream.XMLStreamException {
                if (xmlWriter.getPrefix(namespace) == null) {
                    xmlWriter.writeNamespace(prefix, namespace);
                    xmlWriter.setPrefix(prefix, namespace);
 
                }
 
                xmlWriter.writeAttribute(namespace, attName, attValue);
 
            }
 
            /**
             * Util method to write an attribute without the ns prefix
             */
            private void writeAttribute(java.lang.String namespace, java.lang.String attName,
                    java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter)
                    throws javax.xml.stream.XMLStreamException {
                if (namespace.equals("")) {
                    xmlWriter.writeAttribute(attName, attValue);
                }
                else {
                    registerPrefix(xmlWriter, namespace);
                    xmlWriter.writeAttribute(namespace, attName, attValue);
                }
            }
 
            /**
             * Register a namespace prefix
             */
            private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter,
                    java.lang.String namespace) throws javax.xml.stream.XMLStreamException {
                java.lang.String prefix = xmlWriter.getPrefix(namespace);
 
                if (prefix == null) {
                    prefix = createPrefix();
 
                    while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) {
                        prefix = createPrefix();
                    }
 
                    xmlWriter.writeNamespace(prefix, namespace);
                    xmlWriter.setPrefix(prefix, namespace);
                }
 
                return prefix;
            }
 
            /**
             * Create a prefix
             */
            private java.lang.String createPrefix() {
                return "ns" + (int) Math.random();
            }
        };
 
        return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(MY_QNAME, factory, dataSource);
 
    }
 
    /**
     * databinding method to get an XML representation of this object
     * 
     */
    public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) {
 
        java.util.ArrayList elementList = new java.util.ArrayList();
        java.util.ArrayList attribList = new java.util.ArrayList();
 
        elementList.add(new javax.xml.namespace.QName("urn:SigningServices_v1_0_0.secureServices.health.qld.gov.au",
                "ID"));
 
        if (localID != null) {
            elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localID));
        }
        else {
            throw new RuntimeException("ID cannot be null!!");
        }
 
        return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(),
                attribList.toArray());
 
    }
 
    /**
     * Factory class that keeps the parse method
     */
    public static class Factory {
 
        /**
         * static method to create the object Precondition: If this object is an
         * element, the current or next start element starts this object and any
         * intervening reader events are ignorable If this object is not an
         * element, it is a complex type and the reader is at the event just
         * after the outer start element Postcondition: If this object is an
         * element, the reader is positioned at its end element If this object
         * is a complex type, the reader is positioned at the end element of its
         * outer element
         */
        public static ID parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception {
            ID object = new ID();
            int event;
            try {
 
                while (!reader.isStartElement() && !reader.isEndElement())
                    reader.next();
 
                if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) {
                    java.lang.String fullTypeName = reader.getAttributeValue(
                            "http://www.w3.org/2001/XMLSchema-instance", "type");
                    if (fullTypeName != null) {
                        java.lang.String nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":"));
                        nsPrefix = nsPrefix == null ? "" : nsPrefix;
 
                        java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1);
                        if (!"ID".equals(type)) {
                            // find namespace for the prefix
                            java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix);
                            return (ID) org.w3.www._2005._05.xmlmime.ExtensionMapper.getTypeObject(nsUri, type, reader);
                        }
 
                    }
 
                }
 
                // Note all attributes that were handled. Used to differ normal
                // attributes
                // from anyAttributes.
                java.util.Vector handledAttributes = new java.util.Vector();
 
                boolean isReaderMTOMAware = false;
 
                try {
                    isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader
                            .getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE));
                }
                catch (java.lang.IllegalArgumentException e) {
                    isReaderMTOMAware = false;
                }
 
                while (!reader.isEndElement()) {
                    if (reader.isStartElement() || reader.hasText()) {
 
                        if (reader.isStartElement() || reader.hasText()) {
 
                            java.lang.String content = reader.getElementText();
 
                            object.setID(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content));
 
                        } // End of if for expected property start element
 
                        else {
                            // A start element we are not expecting indicates an
                            // invalid parameter was passed
                            throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName());
                        }
 
                    }
                    else
                        reader.next();
                } // end of while loop
 
            }
            catch (javax.xml.stream.XMLStreamException e) {
                throw new java.lang.Exception(e);
            }
 
            return object;
        }
 
    }// end of factory class
 
 


*****************************************************************
This email, including any attachments sent with it, is
confidential and for the sole use of the intended recipient(s).
This confidentiality is not waived or lost, if you receive it and
you are not the intended recipient(s), or if it is transmitted/
received in error.

Any unauthorised use, alteration, disclosure, distribution or
review of this email is strictly prohibited.  The information
contained in this email, including any attachment sent with
it, may be subject to a statutory duty of confidentiality if it
relates to health service matters.

If you are not the intended recipient(s), or if you have
received this email in error, you are asked to immediately
notify the sender by telephone collect on Australia
+61 1800 198 175 or by return email.  You should also
delete this email, and any copies, from your computer
system network and destroy any hard copies produced.

If not an intended recipient of this email, you must not copy,
distribute or take any action(s) that relies on it; any form of
disclosure, modification, distribution and/or publication of this
email is also prohibited.

Although Queensland Health takes all reasonable steps to
ensure this email does not contain malicious software,
Queensland Health does not accept responsibility for the
consequences if any person's computer inadvertently suffers
any disruption to services, loss of information, harm or is
infected with a virus, other malicious computer programme or
code that may occur as a consequence of receiving this
email.

Unless stated otherwise, this email represents only the views
of the sender and not the views of the Queensland Government.
****************************************************************