/*
 * Created on Sep 7, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.biomoby.shared.schema;

import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

/**
 * @author Eddie
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class ServiceInstanceWSDL {

    protected String XSNamespace = "http://www.w3.org/2001/XMLSchema";

    protected String MobyNamespace = "http://biomoby.org/moby";

    public Element createSecondaryParameterSchema(String articleName,
            String Datatype, String defaultValue, String min, String max,
            String[] enumerations) {
        // create the root element and add attributes
        Element schema = new Element("schema", "xs", XSNamespace);
        schema.addNamespaceDeclaration(Namespace.getNamespace("moby", MobyNamespace));
        schema.setAttribute("targetNamespace", MobyNamespace);
        schema.setAttribute("elementFormDefault","qualified");
        schema.setAttribute("attributeFormDefault","qualified");
        
        // create a name for the parameter element
        return schema;
    }

    public static void main(String[] args) {
        Element e = new ServiceInstanceWSDL().createSecondaryParameterSchema(
                "mySecondary", "Integer", "2", "1", "5", new String[] { "1",
                        "2", "3", "4", "5" });
        XMLOutputter fmt = new XMLOutputter();
        Format format = Format.getPrettyFormat();
        fmt.setFormat(format);
        System.out.println(fmt.outputString(e));
    }

    /*
     * <xs:element name="Parameter"> <xs:complexType> <xs:sequence> <xs:element
     * ref="moby:datatype" minOccurs="1" maxOccurs="1"/> <xs:element
     * ref="moby:default" minOccurs="1" maxOccurs="1"/> <xs:element
     * ref="moby:max" minOccurs="1" maxOccurs="1"/> <xs:element ref="moby:min"
     * minOccurs="1" maxOccurs="1"/> <xs:element ref="moby:enum" minOccurs="1"
     * maxOccurs="5"/> </xs:sequence> <xs:attribute name="articleName"
     * type="moby:secondaryParamArticleNameType" use="required"
     * form="qualified"/> </xs:complexType> <!-- specify that the article name
     * is unique --> <xs:unique name="uniqueArticleName"> <xs:selector
     * xpath="moby:Parameter"/> <xs:field xpath="@moby:articleName"/>
     * </xs:unique> <!-- if necessary, explicitly specify the default value -->
     * <xs:unique name="uniqueDefault"> <xs:selector xpath="moby:default"/>
     * <xs:field xpath="@moby:default"/> </xs:unique> <!-- if necessary,
     * explicitly specify the max value --> <xs:unique name="uniqueMaxValue">
     * <xs:selector xpath="moby:max"/> <xs:field xpath="@moby:max"/>
     * </xs:unique> <!-- if necessary, explicitly specify the min value -->
     * <xs:unique name="uniqueMinValue"> <xs:selector xpath="moby:min"/>
     * <xs:field xpath="@moby:min"/> </xs:unique> <!-- if necessary, explicitly
     * specify the enum values --> <xs:unique name="uniqueEnumValues">
     * <xs:selector xpath="moby:enum"/> <xs:field xpath="@moby:enum"/>
     * </xs:unique> </xs:element> <!-- Secondary Parameter Article Name Value
     * --> <xs:simpleType name="secondaryParamArticleNameType"> <xs:restriction
     * base="xs:string"> <xs:enumeration value="__NAME__OF__SECONDARY__"/>
     * </xs:restriction> </xs:simpleType> <!-- Specify the data type (need to
     * choose between Integer, Float, String, DateTime) --> <xs:element
     * name="datatype"> <xs:simpleType> <xs:restriction base="xs:string">
     * <xs:enumeration value="Integer"/> </xs:restriction> </xs:simpleType>
     * </xs:element> <!-- TODO - add a unique block if a default exists and
     * specify it below --> <xs:element name="default"> <xs:simpleType>
     * <xs:restriction base="xs:int"> <xs:enumeration value="2"/>
     * </xs:restriction> </xs:simpleType> </xs:element> <!-- TODO - add a unique
     * block if an enum exists and specify the values below --> <xs:element
     * name="enum"> <xs:simpleType> <xs:restriction base="xs:int">
     * <xs:enumeration value="1"/> <xs:enumeration value="2"/> <xs:enumeration
     * value="3"/> <xs:enumeration value="4"/> <xs:enumeration value="5"/>
     * </xs:restriction> </xs:simpleType> </xs:element> <!-- TODO - add a unique
     * block if a max exists and specify it below --> <xs:element name="max">
     * <xs:simpleType> <xs:restriction base="xs:int"> <xs:enumeration
     * value="5"/> </xs:restriction> </xs:simpleType> </xs:element> <!-- TODO -
     * add a unique block if a min exists and specify it below --> <xs:element
     * name="min"> <xs:simpleType> <xs:restriction base="xs:int">
     * <xs:enumeration value="0"/> </xs:restriction> </xs:simpleType>
     * </xs:element>
     */
}