/**
	     * Gets the request.
	     * 
	     * @param input
	     *            the input
	     * @return the request
	     * @throws XMLRealiserException
	     *             the xML realiser exception
	     */
		public static wrapper.RequestType getRequest(StringReader input)
		{
			wrapper.NLGSpec spec = UnWrapper.getNLGSpec(input);
			wrapper.RequestType request = spec.Request;
			if (request == null)
			{
				throw new XMLRealiserException("Must have Request element");
			}

			return request;
		}
	    /**
	     * The main method to perform realisation.
	     * 
	     * @param args
	     *            the args
	     * @return the string
	     * @throws XMLRealiserException
	     *             the xML realiser exception
	     */
		public static string main(object[] args)
		{

			if (args == null || args.Length == 0)
			{
				throw new XMLRealiserException("invalid args");
			}
			int argx = 0;
			string input = "";
			string output = "OK";
			string opCodeStr = (string) args[argx++];
			OpCode opCode;
			try
			{
				Enum.TryParse(opCodeStr, out opCode);
			}
			catch (ArgumentException)
			{
				throw new XMLRealiserException("invalid args");
			}
			switch (opCode)
			{
			case OpCode.realise:
				if (args.Length <= argx)
				{
					throw new XMLRealiserException("invalid args");
				}
				input = (string) args[argx++];
				StringReader reader = new StringReader(input);
				wrapper.RequestType request = getRequest(reader);
				output = realise(request.Document);

				break;
			case OpCode.setLexicon:
			{
				if (args.Length <= argx + 1)
				{
					throw new XMLRealiserException("invalid setLexicon args");
				}
				string lexTypeStr = (string) args[argx++];
				string lexFile = (string) args[argx++];
				LexiconType lexType;

				if (!Enum.TryParse(lexTypeStr, out lexType))
				{
					throw new XMLRealiserException("invalid args");
				}

				setLexicon(lexType, lexFile);
				break;
			}
			case OpCode.startRecording:
			{
				if (args.Length <= argx)
				{
					throw new XMLRealiserException("invalid args");
				}
				string path = (string) args[argx++];
				startRecording(path);
				break;
			}
			case OpCode.stopRecording:
				if (record != null)
				{
					output = record.GetRecordingFile();
					try
					{
						record.finish();
					}
					catch (Exception e)
					{
						throw new XMLRealiserException("xml writing error " + e.Message);
					}
				}
				break;
			case OpCode.noop:
				break;
			default:
				throw new XMLRealiserException("invalid op code " + opCodeStr);
			}

			if (opCode == OpCode.realise)
			{
			}

			return output;
		}