private void describeWebServiceFunction(FunctionSignature signature, MemTreeBuilder builderFunction, Sequence functionResult) throws XPathException
private void describeWebServiceFunction(FunctionSignature signature, MemTreeBuilder builderFunction, Sequence functionResult) throws XPathException,SAXException
    	private void describeWebServiceFunction(FunctionSignature signature, MemTreeBuilder builderFunction, Sequence functionResult) throws XPathException    	{    		//Generate an XML snippet for each function        	builderFunction.startElement(new QName("function", null, null), null);        	builderFunction.startElement(new QName("name", null, null), null);        	builderFunction.characters(signature.getName().getLocalName());        	builderFunction.endElement();        	if(signature.getDescription() != null)        	{        		builderFunction.startElement(new QName("description", null, null), null);        		builderFunction.characters(signature.getDescription());        		builderFunction.endElement();        	}        	SequenceType[] xqwsArguments = signature.getArgumentTypes();        	builderFunction.startElement(new QName("parameters", null, null), null);        	for(int a = 0; a < xqwsArguments.length; a++)        	{        		builderFunction.startElement(new QName("parameter",null, null), null);        		builderFunction.startElement(new QName("name",null, null), null);        		//builderFunction.characters(xqwsArguments[a].getNodeName().getLocalName()); //TODO: how to get parameter name?        		builderFunction.endElement();        		builderFunction.startElement(new QName("type",null, null), null);        		builderFunction.characters(Type.getTypeName(xqwsArguments[a].getPrimaryType()));        		builderFunction.endElement();        		builderFunction.startElement(new QName("cardinality",null, null), null);        		builderFunction.characters(Integer.toString(xqwsArguments[a].getCardinality()));        		builderFunction.endElement();        		builderFunction.endElement();        	}        	builderFunction.endElement();        	builderFunction.startElement(new QName("return",null, null), null);        	builderFunction.startElement(new QName("type",null, null), null);        	builderFunction.characters(Type.getTypeName(signature.getReturnType().getPrimaryType()));        	builderFunction.endElement();        	int iReturnCardinality = signature.getReturnType().getCardinality();        	builderFunction.startElement(new QName("cardinality",null, null), null);        	builderFunction.characters(Integer.toString(iReturnCardinality));        	builderFunction.endElement();        	if(functionResult != null)        	{        		builderFunction.startElement(new QName("result", null, null), null);        		        		//determine result cardinality        		if(iReturnCardinality >= Cardinality.MANY)        		{        			//sequence of values        			builderFunction.startElement(new QName("sequence", null, null), null);        			        			for(int i=0; i < functionResult.getLength(); i++)        			{            			builderFunction.startElement(new QName("value", null, null), null);            			builderFunction.characters(functionResult.itemAt(i).getStringValue());            			builderFunction.endElement();        			}        			        			builderFunction.endElement();        		}        		else        		{        			//atomic value        			builderFunction.startElement(new QName("value", null, null), null);        			builderFunction.characters(functionResult.itemAt(0).getStringValue());        			builderFunction.endElement();        		}        		        		builderFunction.endElement();        	}        	builderFunction.endElement();        	builderFunction.endElement();    	}