private static void readGroups( Element groupsElement, MVD mvd )
		throws Exception
	{
		TreeMap<Short,Group> groups = new TreeMap<Short,Group>();
		NodeList nl = groupsElement.getChildNodes();
		for ( int i=0;i<nl.getLength();i++ )
		{
			Node groupNode = nl.item( i );
			if ( groupNode.getNodeType() == Node.ELEMENT_NODE )
			{
				NamedNodeMap nodeMap = groupNode.getAttributes();
				Node idAttr = nodeMap.getNamedItem( "id" );
				Node parentAttr = nodeMap.getNamedItem( "parent" );
				Node nameAttr = nodeMap.getNamedItem( "name" );
				if ( idAttr == null || parentAttr == null 
					|| nameAttr == null )
					throw new MVDException( 
						"missing id, parent or name for group" );
				String id = idAttr.getTextContent();
				String parent = parentAttr.getTextContent();
				String name = nameAttr.getTextContent();
				Group g = new Group( Short.parseShort(parent), name );
				short idVal = Short.parseShort( id );
				groups.put( new Short(idVal), g );
			}
		}
		Set<Short> keys = groups.keySet();
		Iterator<Short> iter = keys.iterator();
		short old = 0;
		// TreeMap sorts on id
		while ( iter.hasNext() )
		{
			Short curr = iter.next();
			short currVal = curr.shortValue();
			if ( currVal != old+1 )
				throw new MVDException( "Missing group id "+(old+1) );
			mvd.addGroup( groups.get(curr) );
			old = currVal;
		}
	}