org.yawlfoundation.yawl.schema
Class XMLToolsForYAWL

java.lang.Object
  extended by org.yawlfoundation.yawl.schema.XMLToolsForYAWL

public class XMLToolsForYAWL
extends Object

/**

Author:
Lachlan Aldred Date: 13/09/2004 Time: 10:33:10

Constructor Summary
XMLToolsForYAWL()
           
 
Method Summary
 Instruction[] buildInstructions(Collection params)
           
 String createYAWLSchema(Instruction[] instructions, String rootElementName)
          Creates a Schema in String format with a root element called data.
 String createYAWLSchema(List<Instruction> instructions, String rootElementName)
           
 Set getPrimarySchemaElementNames()
          Returns a Set of global element names.
 Set getPrimarySchemaTypeNames()
          Returns a Set of the global type names as strings.
static String getSchema4SchemaNameSpace()
           
 String getSchemaString()
          Returns a string representation of the primary schema set into this object.
 boolean isSchemaForSchemaType(String name)
          Returns is schema for schema type
 boolean isValidType(String typename, boolean isSchem4Schema)
          Returns is a valid type contained by the Schema library or a valid schema for schema type.
 void setPrimarySchema(String schemaStr)
          Helper method to set the primary Schema for use later.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLToolsForYAWL

public XMLToolsForYAWL()
Method Detail

setPrimarySchema

public void setPrimarySchema(String schemaStr)
                      throws YSchemaBuildingException,
                             YSyntaxException
Helper method to set the primary Schema for use later.

Parameters:
schemaStr - the entire schema as a string
Throws:
YSchemaBuildingException
YSyntaxException

getPrimarySchemaTypeNames

public Set getPrimarySchemaTypeNames()
Returns a Set of the global type names as strings.

Returns:
global type names Set.

getPrimarySchemaElementNames

public Set getPrimarySchemaElementNames()
Returns a Set of global element names.

Returns:
global element names Set.

createYAWLSchema

public String createYAWLSchema(Instruction[] instructions,
                               String rootElementName)
                        throws YSchemaBuildingException
Creates a Schema in String format with a root element called data. This data element then contains sub-elements that are the union of the desired type names and desired element names. For each desired type one element is created and for each desired element it is used directly. Note that it is a syntax error to desired element names and type names to overlap.

Parameters:
instructions - a 2 dimensional array of strings to strings all in QName format. For example you could create a schema using only built in types like this:
 String [][] desiredElementNamesToTypes = new String[2][];
 desiredElementNamesToTypes[0] = new String[]{"number",
                                              "integer",
                                              "http://www.w3.org/2001/XMLSchema"};
 desiredElementNamesToTypes[1] = new String[]{"address",
                                              "string",
                                              "http://www.w3.org/2001/XMLSchema"};
 String schemaStr = createYAWLSchema(desiredElementNamesToTypes);
Will result in a schema like this:
    
    
      
         
            
               
               
            
         
      
   
 
Note that the sequence of elements described in the String[][] is preserved in the resulting schema. Also note that this is the way that you use the method to create elements using Schema's built in types.

Now imagine that you have set a primary Schema like this one:

     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
A slightly more complicated use of the library could be:
 String [][] desiredElementNamesToTypes = new String[6][];
 desiredElementNamesToTypes[0] = new String[]{"number", null};
 desiredElementNamesToTypes[1] = new String[]{"address", null};
 desiredElementNamesToTypes[2] = new String[]{"person", "PersonType"};
 desiredElementNamesToTypes[3] = new String[]{"person2", "PersonType"};
 desiredElementNamesToTypes[4] = new String[]{"myState", "StateType"};
 desiredElementNamesToTypes[5] = new String[]{"yourState", "StateType"};
 
Note you specify the element name first (mandatory) then the type name (optional). An instruction to specify the element name only means that there is an existing element to be retrieved. The resulting schema could look like this:
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
Note that unlike the input schema there are no global elements and no global types. If possible the returned schema should look like this, but it will at least be valid.
Returns:
a schema built accordingly
Throws:
YSchemaBuildingException

createYAWLSchema

public String createYAWLSchema(List<Instruction> instructions,
                               String rootElementName)
                        throws YSchemaBuildingException
Throws:
YSchemaBuildingException

getSchemaString

public String getSchemaString()
Returns a string representation of the primary schema set into this object.

Returns:
schema in string format.

getSchema4SchemaNameSpace

public static String getSchema4SchemaNameSpace()
Returns:
the Schema 4 Schema Namespace (2001).

isSchemaForSchemaType

public boolean isSchemaForSchemaType(String name)
Returns is schema for schema type

Parameters:
name -
Returns:
true if the name passed is a schema for schema type definition

isValidType

public boolean isValidType(String typename,
                           boolean isSchem4Schema)
Returns is a valid type contained by the Schema library or a valid schema for schema type.

Parameters:
typename - of the type in question
isSchem4Schema - is schema 4 schema type
Returns:
true if typename is a valid type contained by the Schema library or a valid schema for schema type.

buildInstructions

public Instruction[] buildInstructions(Collection params)


Copyright © 2004-2012 The YAWL Foundation.