<?xml version="1.0" encoding="UTF-8"?>

<!--
	Spring Web Flow 1.0 DTD
	Authors: Keith Donald, Erwin Vervaet
	
	This DTD defines the Spring Web Flow (SWF) XML syntax.
	
	The root "flow" element of this document defines exactly one flow definition.
	A flow definition is a blueprint for an executable task that involves a 
	single user (aka conversation or dialog).
	
	A flow is composed of one or more states that form the steps of the flow.
	Each State executes behavior when entered. What behavior is executed is a
	function of the state's type. Core state types include view states,
	action states, subflow states, decision states, and end states.
    
	Each flow definition must specify exactly one start state.
	Events that occur in transitionable states drive state transitions.
    
	XML documents that conform to this DTD should declare the following doctype:

	<!DOCTYPE flow PUBLIC "-//SPRING//DTD WEBFLOW 1.0//EN"
		"http://www.springframework.org/dtd/spring-webflow-1.0.dtd">
-->

<!--
	Defines exactly one flow definition.
	
	A flow is composed of one or more states that define the steps of a task.
	One of those steps is the startState, which defines the starting point of 
	the task.

	A flow may be annotated with attributes that define custom characteristics that
	can be used to affect flow execution.
	
	A flow may map input provided by callers that start it, and return output 
	to callers that end it.  In addition, a flow may execute custom behavior
	at start time and end time.
	
	A flow can instantiate a set of application variables when started.  It may
	be configured to handle exceptions thrown by its states during execution.
	
	A flow may define transitions shared by all states.
	
	A flow may import one or more local bean definition files defining custom
	flow artifacts (such as actions, exception handlers, view selectors,
	transition criteria, etc).
	
	Finally, a flow may nest one or more other flows within this document to
	use as subflows, referred to as 'inline flows'.
-->
<!ELEMENT flow ( attribute*, var*, input-mapper?, start-actions?, ( action-state | view-state | decision-state | subflow-state | end-state )+, global-transitions?, end-actions?, output-mapper*, exception-handler*, import*, inline-flow* )>

<!--
	The identifier of the start state of this flow.  The start state is the point where flow execution begins.
-->
<!ATTLIST flow start-state IDREF #REQUIRED>

<!--
	The mapper to map input attributes provided at startup for use by this flow during its execution.
	
	For the input mapper the following mapping characteristics apply:
	- The 'source' of each mapping is the flow input map containing input provided by the caller 
	  that launched the flow.
	- The 'target' of each mapping is the flow RequestContext, exposing access to the central 
	  flow data structures such as flowScope.
	  
	For example:
	
	<input-mapper>
	    <mapping source="clientInputAttribute" target="flowScope.myFlowAttribute"/>
	</input-mapper>
	
	... maps the value of "clientInputAttribute" to the "myFlowAttribute" in flow scope.
-->
<!ELEMENT input-mapper ( mapping+ )>

<!--
	A rule that maps a value from a source data structure to a value in a target data structure.
-->
<!ELEMENT mapping EMPTY>

<!--
	The expression resolving the source value to be mapped.
-->
<!ATTLIST mapping source CDATA #REQUIRED>

<!--
	The property expression defining the target property to be set.
-->
<!ATTLIST mapping target CDATA #IMPLIED>

<!--
	The expression resolving the target collection that the source should be added to.
	Use this or the 'target' attribute, not both.
-->
<!ATTLIST mapping target-collection CDATA #IMPLIED>

<!--
	The source value type.  If the source type differs from the target type a type conversion
	will be performed.  The type may be an alias (e.g 'string') or a fully-qualified class (e.g. 'java.lang.String').
-->
<!ATTLIST mapping from CDATA #IMPLIED>

<!--
	The target value type.  If the source type differs from the target type a type conversion
	will be performed.  The type may be an alias (e.g 'int') or a fully-qualified class (e.g. 'java.lang.Integer').
-->
<!ATTLIST mapping to CDATA #IMPLIED>

<!--
	An attribute about this element.
	
	Attributes are simple strings or typed values that allow you to annotate an element with metadata.
	For example:
	- an element's 'caption' attribute might serve a GUI tooltip or logging statement
	- an Action's 'validatorMethod' attribute might specify a target method to invoke on a validator
-->
<!ELEMENT attribute ( value? )>

<!--
	The name of this attribute.
-->
<!ATTLIST attribute name CDATA #REQUIRED>

<!--
	The target type of the attribute value; to facilitate from-string type conversion. This type
	string may be an alias (e.g 'int') or a fully-qualified class (e.g. 'java.lang.Integer').
-->
<!ATTLIST attribute type CDATA #IMPLIED>

<!--
	The value of this attribute; a short-cut alternative to an explicit child 'value' element.
-->
<!ATTLIST attribute value CDATA #IMPLIED>

<!--
	The value of this attribute.
-->
<!ELEMENT value ( #PCDATA )>

<!--
	A flow variable definition.  Flow variables are automatically created in "flow scope" 
	when an execution of this flow starts.
-->
<!ELEMENT var EMPTY>

<!--
	This name of this variable, used as the index of the variable value set in the configured scope.
	
	When specified without the 'class' or 'bean' attributes, this name is also used as the bean name
	of a non-singleton bean in the configured Bean Factory to use as the initial variable value.
-->
<!ATTLIST var name CDATA #REQUIRED>

<!--
	This scope of this variable.  The available scope types are:
	
	1. request
	    - the variable goes out of scope when a call to start the flow completes.
	2. flow
	    - the variable goes out of scope when the flow session ends.  For example, if a
	      flow spawns another flow as a subflow and that subflow allocates flow-scoped
	      variables, those variables will be cleaned up when the subflow ends.
	3. conversation
	    - the variable goes out of scope when the overall conversation governing the 
	      flow execution ends.
	
	The 'default' value is flow scope.
-->
<!ATTLIST var scope (request | flow | conversation | default) "default">

<!--
	The implementation class of the variable's value.  The class may be an alias (e.g 'int') or a
	fully-qualified class (e.g. 'java.lang.Integer').  The class cannot be abstract or an interface.
	Only required if the variable should be instantiated directly by calling the default constructor
	on its class rather than having the initial variable value returned by a Spring Bean Factory.
	
	Use this or the 'bean' attribute, not both.
-->
<!ATTLIST var class CDATA #IMPLIED>

<!--
	The bean defining the initial flow variable value.  The bean *must* be a non-singleton prototype.
	Only required if the bean name differs from the variable name.
-->
<!ATTLIST var bean CDATA #IMPLIED>

<!--
	Defines flow startup logic to execute. This logic will always execute when this flow is started.
-->
<!ELEMENT start-actions ( action+ )>

<!--
	Defines an action state, a state where one or more actions are executed.
	This state type is typically used to invoke application code, often business services.
	An action state is a transitionable state.  A transition out of this state 
	is driven by the result of action execution (e.g. success, error).
-->
<!ELEMENT action-state ( attribute*, entry-actions?, action+, transition*, exit-actions?, exception-handler* )>

<!--
	The unique identifier of this action state; must be unique to this flow.
-->
<!ATTLIST action-state id ID #REQUIRED>

<!--
	Defines a single action to be executed. An action is a command object that executes
	arbitrary behavior.
	
	The action referenced by this element must implement the org.springframework.webflow.Action 
	interface.  If the referenced action is a POJO that does not implement the Action interface
	directly, Spring Web Flow will automatically adapt a method on that POJO to the Action contract.
	See this element's 'method' attribute for more information.
	
	An action may be annotated with attributes that can be used to affect the action's execution.
-->
<!ELEMENT action ( attribute* )>

<!--
	The identifier of the action implementation to execute, typically the id of a bean
	registered in a Spring BeanFactory.
	
	If the referenced bean implements the org.springframework.webflow.Action interface
	directly, it is retrieved from the factory and used as is.  If the referenced bean is
	a POJO that does not implement this interface, the method on the POJO referenced by the
	'method' attribute is adapted to the Action interface automatically.  See the
	'method' attribute for more information.
	
	This is similar to the <ref bean="myBean"/> notation of the Spring beans DTD.
-->
<!ATTLIST action bean CDATA #IMPLIED>

<!--
	An optional name qualifier for this action. When specified this action will
	qualify execution result event ids by this name. For example, if this action is
	named "placeOrder" and signals a "success" result event after execution, the
	fully qualified result event the flow can respond to would be "placeOrder.success".
	
	An action with a name is often referred to as a "named action".
-->
<!ATTLIST action name CDATA #IMPLIED>

<!--
	The name of the target method to invoke to execute this action.  The value
	of this attribute is a method binding expression that evaluates to a method 
	on the referenced action bean.
	
	If this action bean extends org.springframework.webflow.action.MultiAction,
	the expression is simply a static method name.

    For example:
        <action bean="formAction" method="setupForm"/>
    
    The actual signature of this method must be of the form:
	    public Event <method>(RequestContext) throws Exception { ... }
	    
	If this action is an abritrary bean (POJO), the expression can 
	match any public method on the bean's implementation. In this case the
	expression format is as follows: <method>(${arg 1}, ..., ${arg n}) where any 
	${arg n} expressions are evaluated against the flow execution
	org.springframework.webflow.RequestContext.

	For example:
        <action bean="orderClerk" method="placeOrder(${flowScope.order})"/>
-->
<!ATTLIST action method CDATA #IMPLIED>

<!--
	The name of the attribute that will expose the return value of the target action method.
	Used in conjunction with the 'method' and 'result-scope' attributes.
	Only directly applicable when this action invokes a method on a bean (POJO)
	that returns a value.

	For example:
        <action bean="orderClerk" method="placeOrder(${flowScope.order})" result-name="orderConfirmation"/>
        
    ... exposes the 'placeOrder(Order)' method return value in request scope 
    under the attribute name 'orderConfirmation'.
-->
<!ATTLIST action result-name CDATA #IMPLIED>

<!--
	The scope of the attribute that will expose the return value of the target action method.
	Used in conjunction with the 'result-name' attribute, and only directly applicable
	when this action invokes a method on a bean (POJO) that returns a value.

	For example:
        <action bean="bookingAgent" method="suggestItineraries(${flowScope.trip})" result-name="itineraries" result-scope="flow"/>

    ... exposes the 'suggestItineraries(Trip)' method return value in flow scope 
    under the attribute name 'itineraries'.

    The available scope types are:
    
	1. request
	    - the result goes out of scope when the call into the flow that invoked this method completes.
	2. flow
	    - the result goes out of scope when the flow session ends.  For example, if a
	      flow spawns another flow as a subflow and that subflow invokes a method that 
	      exposes a result in "flow scope", that result will be cleaned up when
	      the subflow ends.
	3. conversation
	    - the result goes out of scope when the overall conversation governing this flow 
	      execution ends.
	      
    The default value if not specified is request scope.     
-->
<!ATTLIST action result-scope (request | flow | conversation | default) "default">

<!--
	Defines a transition from one state to another.
	
	A transitions defines a supported path through the flow.
	A transitions may be annotated with attributes and may specify one or more
	actions to execute before executing.
-->
<!ELEMENT transition ( attribute*, action* )>

<!--
	The criteria that guards this transition's execution, typically reasoning on the
	last event that occured in an execution of this flow to determine if this transition 
	should execute.
	
	The most basic value is a static event id. For example:
  	    <transition on="submit" to="state"/>
	
	Sophisticated transitional expressions are also supported. For example:
	    <transition on="${#result == 'submit' &;amp;&amp flowScope.attribute == 'foo'}" to="state"/>
	
	Custom transition criteria implementations can be referenced by id. For example:
	    <transition on="bean:myCustomCriteria" to="state"/>
	    
	The exact interpretation of this attribute value depends on the TextToTransitionCriteria
	converter that is installed.
-->
<!ATTLIST transition on CDATA #IMPLIED>

<!--
    The exception type that should trigger execution of this transition.
    
    The value may be a fully-qualified class name (e.g. example.booking.ItineraryExpiredException) or 
    a short class name (e.g. ItineraryExpiredException).  Superclasses of the configured exception type
    match by default.
    
    Use of this attribute results in an exception handler being attached to the object associated
    with this transition definition.  Use this attribute or the 'on' attribute, not both.
-->
<!ATTLIST transition on-exception CDATA #IMPLIED>

<!--
	The id of the target state of this transition.
	
	The value of this attribute may be a static state identifier (e.g. to="displayForm")
	or an expression to be evaluated at runtime against the request context
	(e.g. to="${flowScope.previousViewState}").
-->
<!ATTLIST transition to CDATA #REQUIRED>

<!--
	Defines a view state, a state where a view will be selected for rendering, the 
	executing flow will be 'paused' and control will be returned to the user.
	A view state allows the user to participate in the flow.

	A view state is a transitionable state. A view state transition is triggered by a
	user input event.
-->
<!ELEMENT view-state ( attribute*, entry-actions?, transition*, exit-actions?, exception-handler* )>

<!--
	The unique identifier of this view state; must be unique to this flow.
-->
<!ATTLIST view-state id ID #REQUIRED>

<!--
	The name of the view to render when this view state is entered.
	
	This value may be a logical application view name or even a direct pointer to a view template.
	For example:
	    "priceForm" or "/WEB-INF/jsp/priceForm.jsp"
	
	This value may also be a view name expression evaluated against the request context.  For example:
	    "${flowScope.view}"
	    
	This value may also be qualified with a prefix to denote a specific (possibly custom)
	ViewSelector strategy.

	Use of the "redirect:" prefix indicates this view state should trigger a redirect to a 
	unique "flow execution URL".  This causes the selected application view to be rendered on
	the subsequent request into the server at that URL.  This allows browsers to easily
	refresh a specific state of the conversation while the conversation remains active.
		"redirect:priceForm"

	Use of the "externalRedirect:" prefix indicates this view state should trigger a 
	redirect to an absolute external URL, typically to interface with an external system.
	External redirect query parameters may be specified using ${expressions} that evaluate
	against the request context. For example:
	    "externalRedirect:/someOtherSystem.htm?orderId=${flowScope.order.id}"
	
	Use of the "bean:" prefix references a custom ViewSelector implementation you define,
	exposed by id in either a flow-local context using the "import" element or in the parent 
	context.
	    "bean:myCustomViewSelector"
	
	The exact semantics regarding the interpretation of this value are determined by the
	installed TextToViewSelector converter.

	Note when no view name is provided, this view state will make a "null" view selection. A null
	view does not request the rendering of a view, it only pauses the flow and returns control 
	the client. Use a null view when another state is expected to generate the response.
-->
<!ATTLIST view-state view CDATA #IMPLIED>

<!--
	Defines state entry logic to be executed. This logic will always execute when the state is entered.
-->
<!ELEMENT entry-actions ( action+ )>

<!--
	Defines state exit logic to be executed. This logic will always execute when the state is exited 
	regardless of what transition is executed.
-->
<!ELEMENT exit-actions ( action+ )>

<!--
	Defines a decision state, a state that evaluates one or more expressions or method 
	return values to decide which state to enter next.  Intended to be used purely as an
	idempotent 'navigation' or 'routing' state and is not intended to execute non-idempotent
	(or mutating) behavior.
	
	A decision state is a transitionable state. A decision state transition can be triggered by
	evaluating a boolean expression against the flow execution request context.  To 
	define expressions, use the 'if' element.
	
	Examples:

	A simple boolean expression test, using the convenient 'if' element:
	
    <decision-state id="requiresShipping">
	    <if test="${flowScope.sale.shipping}" then="enterShippingDetails" else="processSale"/>
    </decision-state>
-->
<!ELEMENT decision-state ( attribute*, entry-actions?, if*, exit-actions?, exception-handler* )>

<!--
	The unique identifier of this decision state; must be unique to this flow.
-->
<!ATTLIST decision-state id ID #REQUIRED>

<!--
	A transition specification that defines a boolean expression to evaluate when this state
	is entered and a state to transition to if that	expression evaluates to true.
	Optionally, this element may also define an 'else' attribute to define a state to
	transition to if the expression evaluates to false.

	The form is:
	    <if test="${criteria}" then="trueStateId" else="falseStateId"/>
-->
<!ELEMENT if EMPTY>

<!--
	The transition criteria expression to be tested. This should be a boolean
    ${expression} that evaluates against this flow's request context.
    
    For example:
	    <if test="${flowScope.sale.shipping} then="enterShippingDetails"/>
	    <if test="${lastEvent.id == 'search'} then="bindSearchParameters"/>
-->
<!ATTLIST if test CDATA #REQUIRED>

<!--
	The state to transition to if the boolean expression is true.

	The value of this attribute may be a static state identifier (e.g. then="displayForm")
	or an expression to be evaluated at runtime against the request context
	(e.g. then="${flowScope.previousViewState}").
-->
<!ATTLIST if then IDREF #REQUIRED>

<!--
	The state to transition to if the boolean expression is false (optional).

	The value of this attribute may be a static state identifier (e.g. else="displayForm")
	or an expression to be evaluated at runtime against the request context
	(e.g. else="${flowScope.previousViewState}").
-->
<!ATTLIST if else IDREF #IMPLIED>

<!--
	Defines a subflow state, a state that spawns another flow as a subflow when entered.  When the
	subflow ends, this state is expected to respond to its result.

	A subflow state is a transitionable state.  A state transition is triggered by a
	subflow result event, which describes the logical subflow outcome that occurred.  Typically the 
	criteria for this transition is the id of the subflow end state that was entered.
	
	While the subflow is active, this flow is suspended waiting for the subflow to complete execution.
	When the subflow completes execution by reaching an end state, this state is expected 
	to respond to the result of that execution. The result of subflow execution, the end state 
	that was reached, should be used as grounds for a transition out of this state.
-->
<!ELEMENT subflow-state ( attribute*, entry-actions?, attribute-mapper?, transition*, exit-actions?, exception-handler* )>

<!--
	The unique identifier of this subflow state; must be unique to this flow.
-->
<!ATTLIST subflow-state id ID #REQUIRED>

<!--
	The id of the flow to be spawned as a subflow when this subflow state is entered.
-->
<!ATTLIST subflow-state flow CDATA #REQUIRED>

<!--
	Defines an attribute mapper to map attributes to and from the subflow.
-->
<!ELEMENT attribute-mapper ( input-mapper?, output-mapper? )>

<!--
	The identifier of a custom flow attribute mapper implementation exported in the
	Spring bean factory. This is similar to the <ref bean="myBean"/> notation of the Spring beans DTD.
	
	Use this as an alternative to the child input-mapper and output-mapper elements
	when you need full control of attribute mapping behavior for this subflow state.
-->
<!ATTLIST attribute-mapper bean CDATA #IMPLIED>

<!--
	Defines an end state, a state that terminates this flow when entered.
	
	A end state is not transitionable, there are no transitions out of an end state.
	When an end-state is entered, a instance of this flow is terminated.
	
	When an end state is entered, if the executingflow is a "root" or top-level flow
	the entire execution (conversation) is terminated. If the executing flow is a subflow
	the subflow session ends and the parent session resumes. To resume, the parent session
	responds to the result of the subflow, typically by reasoning on the id of the end
	state that was reached.
-->
<!ELEMENT end-state ( attribute*, entry-actions?, output-mapper?, exception-handler* )>

<!--
	The unique identifier of this end state; must be unique to this flow.
-->
<!ATTLIST end-state id ID #REQUIRED>

<!--
	The name of the view to to render when this end state is entered.
	
	This value may be a static view name or even a direct pointer to a view template. For example:
	    "priceForm", or "/WEB-INF/jsp/priceForm.jsp"
	
	This value may also be qualified with a prefix to denote a specific (possibly custom)
	ViewSelector strategy. Specifically:
	
	Use of the "redirect:" prefix triggers a redirect to a specific "after conversation completion"
	external URL.  For example:
	    "redirect:/home.html"
	
	Redirect query parameters may also be specified using ${expressions} that evaluate against
	the request context. For example:
	    "redirect:/thankyou.htm?confirmationNumber=${flowScope.order.confirmation.id}"
	
	Use of the "flowRedirect:" prefix indicates this end state should trigger a redirect that
	starts another flow.  Flow input parameters may be specified using ${expressions} that 
	evaluate against the request context.
		"flowRedirect:search-flow?firstName=${flowScope.searchCriteria.firstName}"
		
	Use of the "bean:" prefix references a custom ViewSelector implementation you define,
	exposed by id in either a flow-local context using the "import" element or in the parent 
	context.
	    "bean:myCustomViewSelector"
	
	The exact semantics regarding the interpretation of this value are determined by the
	installed TextToViewSelector converter.

	Note when no view name is provided, this view state will make a "null" view selection. A null
	view does not request the rendering of a view, it only pauses the flow and returns control 
	the client. Use a null view when another state is expected to generate the response.
-->
<!ATTLIST end-state view CDATA #IMPLIED>

<!--
	Defines flow-level transitions eligible for execution if a state-level transition cannot be matched.
-->
<!ELEMENT global-transitions ( transition+ )>

<!--
	Defines flow ending logic to be executed. This logic will always execute when this flow is ended.
-->
<!ELEMENT end-actions ( action+ )>

<!--
	The mapper that will map flow output attributes.

	For the output mapper the following mapping characteristics apply:
	- The 'source' of each mapping is the flow RequestContext, exposing access to the central 
	  flow data structures such as flowScope.
	- The 'target' of each mapping is the flow output map that will contain output exposed to the 
	  caller that terminated this flow.
	  
	For example:
	
	<ouput-mapper>
	    <mapping source="flowScope.myFlowAttribute" target="clientOutputAttribute"/>
	</output-mapper>
	
	... maps the value of "myFlowAttribute" in flow scope to "clientOutputAttribute" in the
	flow output map.
-->
<!ELEMENT output-mapper ( mapping+ )>

<!--
	Defines a state exception handler to handle one or more exceptions that may occur during the
	execution of this flow definition. Exception handlers may be attached at the state or flow level.
-->
<!ELEMENT exception-handler EMPTY>

<!--
	The id of a custom exception handler implementation to attach.
-->
<!ATTLIST exception-handler bean CDATA #REQUIRED>

<!--
    Requests the import of all custom flow artifacts contained within a single bean
    definition resource location.
-->
<!ELEMENT import EMPTY>

<!--
	The relative resource path to a bean definition file to import.  Imported bean definitions 
	are referenceable by this flow and any of its inline flows.
	
	The resource path is relative to this document.
-->
<!ATTLIST import resource CDATA #REQUIRED>

<!--
	Defines exactly one inline flow definition and assign an id to it.
-->
<!ELEMENT inline-flow ( flow+ )>

<!--
	The assigned identifier of this in-line flow. Must be unique to all other inline flows.
-->
<!ATTLIST inline-flow id ID #REQUIRED>