protected Object cloneTemplate(Node node)
	{
		Object obj = null;

		try
		{
			if (template.getClass().isEnum())
			{
				obj = template.getClass().getEnumConstants()[0];
			}
			else
			{
				obj = template.getClass().newInstance();
			}

			// Special case: Check if the collection
			// should be a map. This is if the first
			// child has an "as"-attribute. This
			// assumes that all childs will have
			// as attributes in this case. This is
			// required because in JavaScript, the
			// map and array object are the same.
			if (obj instanceof Collection)
			{
				node = node.getFirstChild();

				// Skips text nodes
				while (node != null && !(node instanceof Element))
				{
					node = node.getNextSibling();
				}

				if (node != null && node instanceof Element
						&& ((Element) node).hasAttribute("as"))
				{
					obj = new Hashtable<Object, Object>();
				}
			}
		}
		catch (InstantiationException e)
		{
			// ignore
			e.printStackTrace();
		}
		catch (IllegalAccessException e)
		{
			// ignore
			e.printStackTrace();
		}

		return obj;
	}