<!--
DTD for small to medium business XML requests and responses.
Authors: Brian Chess, Craig Sullivan, and Heidi Hammack.
-->

<!--
NetLedger IPR Software Notice
Copyright (c) 2000 NetLedger, Inc. All Rights Reserved.
http://www.smbxml.org/legal/IPRSoftware(2000-05-11)
-->

<!--
Revision History:
	5/15/2000:	1.00 Release
-->


<!ENTITY % ObjectTypeDTD SYSTEM "http://www.smbxml.org/smbObjects_1_00.dtd">
%ObjectTypeDTD;


<!ELEMENT	SMBXML	(Head,(Request|Response)) >

<!-- The head element identifies where the document comes from and where it is going to.
	Information may be omitted from the head if it is implicit in the use context of
	the document.

	Attribute definitions for the Head Element:
		description:	Text describing the purpose of the document.  For documents that
				are queued for approval, this text will be used as a document 
				summary.
		timestamp:	The request transmission time given as the number of milliseconds
				since January 1, 1970, 00:00:00 GMT.  (Available in Java as the
				getTime() method of the Date class or in any POSIX OS as as the
				time() system call.)
		currency:	The base currency used in the request given as an
				ISO 4217 Currency code.
		doc_id:		An document identifier for the purpose of matching
				responses to requests.
-->		
	<!ELEMENT	Head	(From?,To?) >
	<!ATTLIST	Head
		description		%String41;	#IMPLIED 
		timestamp		%Unsigned;	#IMPLIED
		currency		(USD)		"USD"	
		doc_id			%String;	#IMPLIED >

	<!-- Attribute definitions for the From and To elements:
		system:			The sending or receiving entity (ASP, software package, etc).
		organization:	The organization that owns the document (in NetLedger, this is
							the company login.)
		user:			The individual user sending or receiving the document.
	-->
	<!ELEMENT	From	EMPTY >
	<!ATTLIST	From
		system			%String;	#REQUIRED
		organization		%String;	#IMPLIED
		user			%String;	#IMPLIED >
	
	<!ELEMENT	To		EMPTY >
	<!ATTLIST	To
		system			%String;	#REQUIRED
		organization		%String;	#IMPLIED
		user			%String;	#IMPLIED >


<!-- Request -->
	<!-- The req_id in each request type names the request so that a response can refer
	to it directly. -->

<!ENTITY	% ModificationType	"Add|Delete|Modify|Reconcile|Replace" >
<!ENTITY	% QueryType		"LastModifiedQuery|ListQuery|TransactionQuery" >

<!ELEMENT	Request	((%ModificationType;)+|(%QueryType;)+|SignUp+) >

	<!-- Modification Types -->
	<!-- Attribute definitions for the Modification Elements:
		req_id:		The request's identifier.  req_id allows a response to refer directly
				to a specific request.
		external_id:	A unique identifier in the originator's system.  The external_id 
				names a transaction so that it can be referenced in future documents.
				The size (99 characters) is large enough that it can contain a URI
				for the object of the request.  The external_id's namespace is that
				of the originating system.
	-->

	<!ELEMENT	Add	(%ObjectType;) >
	<!ATTLIST	Add
		req_id			%String;		#IMPLIED 
		external_id		%NameDef99;		#IMPLIED >
				
	<!ELEMENT	Delete	EMPTY >
	<!ATTLIST	Delete
		req_id			%String;		#IMPLIED 
		external_id		%NameRef99;		#REQUIRED >
			
	<!ELEMENT	Modify	(Mod)* >
	<!ATTLIST	Modify
		req_id			%String;		#IMPLIED
		external_id		%NameRef99;		#REQUIRED >
		
		<!-- Attribute definitions for the Mod Element:
			attrib:		The name of the attribute to be modified
			value:		The new value for the attribute.
			line_num:	The line_num of the item that the Mod is to be applied to.  If
					line_num is ommitted, the Mod is applied to the body of the object.
		-->
		<!ELEMENT	Mod	EMPTY >
		<!ATTLIST	Mod
			line_num	%Integer;	#IMPLIED
			attrib		CDATA		#REQUIRED
			value		CDATA		#REQUIRED >
			

	<!-- Are you trying to synchronize a transaction across two independent systems?
		That's what the Reconcile command is for.  If the transaction is found in
		the receiving system, the only effect of the command is to mark it as reconciled.
		If the transaction is not found in the receiving system, user intervention is
		required to resolve the transaction. -->
	<!ELEMENT	Reconcile	(%ReconcilableTransactionType;) >
	<!ATTLIST	Reconcile 
		req_id			%String;		#IMPLIED
		external_id		%NameDef99;		#IMPLIED >
		
	<!ELEMENT	Replace	(%ObjectType;) >
	<!ATTLIST	Replace
		req_id			%String;		#IMPLIED
		external_id		%NameRef99;		#REQUIRED  >
	

	<!-- Query Types -->
	
	<!-- The LastModifiedQuery allows you to check when a list was last updated. -->
	<!ELEMENT	LastModifiedQuery	EMPTY >
	<!ATTLIST	LastModifiedQuery
		req_id			%String;		#IMPLIED
		type			(%ListType;)		#REQUIRED >
				
	<!ELEMENT	ListQuery	EMPTY >
	<!ATTLIST	ListQuery
		req_id			%String;		#IMPLIED
		type			(%ListType;)		#REQUIRED
		name			%NameRef;		#IMPLIED
		include_inactive	%Boolean;		"false"  >

	<!ELEMENT	TransactionQuery	EMPTY >
	<!ATTLIST	TransactionQuery
		req_id			%String;		#IMPLIED
		ttype			(%TransactionType;)	#IMPLIED
		account			%AccountRef31;		#IMPLIED
		from_date		%DateType;		#IMPLIED
		to_date			%DateType;		#IMPLIED
		low_amount		%Money12_2;		#IMPLIED
		high_amount		%Money12_2;		#IMPLIED
		external_id		%NameRef99;		#IMPLIED
		status			(open|closed)		#IMPLIED >		

	<!-- In NetLedger, SignUp creates a new account. -->
	<!ELEMENT	SignUp	EMPTY >
	<!ATTLIST	SignUp
		req_id			%String;		#IMPLIED
		first_name		%String31;		#REQUIRED
		last_name		%String31;		#REQUIRED
		email			%String64;		#REQUIRED
		company_name		%String64;		#REQUIRED
		password		%String16;		#REQUIRED >


<!-- Response -->

<!-- We expect the number of error types to increase rapidly. Suggestions? -->
<!ENTITY	% ErrorType	"BadRefId|DBerror|BadDate|BadXML" >
<!ENTITY	% QueryResponseType	"LastModifiedResponse|ListResponse|TransactionResponse" >

<!ELEMENT	Response (Ack | Error | Retry | (%QueryResponseType;)+ ) >
	
	<!ELEMENT	Ack	(#PCDATA) >

	<!ELEMENT	Error	(#PCDATA) >
	<!ATTLIST	Error
		req_id			%String;		#IMPLIED
		error_type		(%ErrorType;)		#REQUIRED>
		
	<!ELEMENT	Retry	(#PCDATA) >

	<!-- The Last Modified response gives the number of milliseconds since
		January 1, 1970, 00:00:00 GMT.  -->
	<!ELEMENT	LastModifiedResponse	EMPTY >
	<!ATTLIST	LastModifiedResponse
		req_id			%String;		#IMPLIED
		time			%Unsigned;		#REQUIRED >

	<!ELEMENT	ListResponse	(%ListType;)* >
	<!ATTLIST	ListResponse
		req_id			%String;		#IMPLIED >
	
	<!ELEMENT	TransactionResponse	(%TransactionType;)* >
	<!ATTLIST	TransactionResponse
		req_id			%String;		#IMPLIED >