Search

Scope

This section describes how to create and edit XSD files that can be used in Futurama applications, especially Webservice applications.

Introduction

From version 17.11 onwards, Futurama supports the use of custom WSDL files in Webservice applications. See Webservice description for more information. In the WSDL definition XSD schemas (XML Schema Definition language) are used to describe and validate the structure of XML. With the introduction of custom WSDL, Futurama Editor also offers the feature to automatically create XSD files. These auto-created files are based on the XML output XmlBuilders or XmlNodes within a Futurama model. Because the XSD schema is based on the (limited) information of one sole XML file, its contents are generally also limited and need to be modified manually. This sections offers a small tutorial, as well as some tips & tricks to get you started.

Tips & Tricks to get you started

1. Using editor tools  to validate XML against your XSD

Use a tool like Notepad++ to validate your XML files against your XSD Schema. Steps:

  • Create or open an XML file.
  • Open Plugins - XML Tools - Validate now and select the XSD schema file to validate the XML

2. Use namespaces

Always use namespaces in your XSD schemas and XML files to limit the scope of your definitions. Especially when elements with the same name, but different contents are used in a web service request and response you will be confronted with strange behavior and/or errors otherwise. Take a look at the two XSD Schemas below:



	
		
			
				
			
		
	
	
		
			
				
			
		
	
	

and



	
		
			
				
			
		
	
	
		
			
				
			
		
	
	

Individually, these definitions make perfectly sense and will work without a problem. But in conjunction (which is the case when these are both used within the scope of a WSDL definition) the definition of ‘Client is ambiguous. Use namespaces to avoid this problem.

3. Elements vs Types

Take a look at the XSD listed below, which is typically auto-generated:



	
		
			
				
					
						
							
							
						
					
				
				
					
						
							
							
						
					
				
			
		
	
Note that 'AgeMin' and 'AgeMax' have the same definition. Create a custom type to avoid superfluous definitions:


	
		
			
				
								
			
		
	
	
	    
	        
	        
	    
	

4. Optional elements and sequences

Elements within the XML structure can either be optional or ranges. These properties are not recognized by the auto-generation command in Futurama if they appear only once in the sample XML. Use the ‘minOccurs’ and ‘maxOccurs’ attributes to define lower- and upperbounds to the number of elements. The example below contains an optional element ‘Partner’ and a range of children with a maximum of 10:



	
		
			
				
								
			
		
	
	
	    
	        
	        
	    
	

maxOccurs and minOccurs are optional; Use maxOccurs=”unbounded” for an unlimited range.

5. Order of elements

Note that the elements that are normally specified in an XSD schema should appear in exactly the same order in the XML contents. Within Futurama, this order is not important when XML is read in XmlNodes and/or XmlFields! This means that this XML file will be processed without problems when read in an XmlNode in Futurama:



	
		A049108
		21/12/1961
	
	
		07/04/1972
		A049109
	

But it will not be validated in the average XSD schema! To allow for the change of order within the structure, use a 'choice' construction:



	
		
			
				
					
						
							
								
								
							
						
					
				
			
		
	

6. Enumerations

In Futurama, enumerations are not supported. This means a variable with a restricted number of values can not be specified at design time. When reading or producing XML, these restrictions can occur at realtime. For example, the sex of a member is always M or F. XSD schemas support these restrictions:



	
		
			
				
				
			
		
	
	
	  
		
		
	  
	

It is good practice to use restrictions in the definition of web service requests and responses, as they reduce the risk of invalid in- or output.

7. Using comma’s as decimal separator

All decimal types are derived from the xs:decimal primary type and constitute a set of predefined types that address the most common usages. The decimal separator is always a dot (“.”) as this is the universal standard. It is possible to use a comma as the decimal separator, but then a specific simpleType has to be defined first:



	
	  
		
		
	

The type MyDecimal can now be used in the rest of the XSD file.

More information

More information about XSD:

w3schools tutorial