package com.jxml.quick.examples.map;

import java.io.*;
import java.util.*;
import com.jxml.protocol.*;
import com.jxml.quick.*;

// Import classes for the SAX Parser
import org.xml.sax.*;

public class Main
{
    public static void main(String[] args)
    {
	try
	    {
		Protocol.addJXMLProtocolPackage();
		// Generate a Quick schema
		QDoc schema=CreateTest.createSchema();

		Goals goals=new Goals();
		Map map=goals.map;
		ArrayList al1=new ArrayList();
		map.put("his",al1);
		al1.add("car");
		al1.add("computer");
		ArrayList al2=new ArrayList();
		map.put("hers",al2);
		al2.add("house");
		al2.add("boat");

		QDoc mapDoc=Quick.createDoc(goals,schema);
		Quick.express(mapDoc,"map.xml");
System.out.println(Quick.express(mapDoc));

		QDoc mapDoc1=Quick.parse(schema,"file:map.xml");
		Goals g=(Goals)Quick.getRoot(mapDoc1);
		Map m=g.map;

		int i;
		int s;
		List l;
		System.out.println();
		System.out.println("his=");
		l=(List)m.get("his");
		s=l.size();
		for (i=0;i<s;++i)
			System.out.println("   "+l.get(i));
		System.out.println();
		System.out.println("hers=");
		l=(List)m.get("hers");
		s=l.size();
		for (i=0;i<s;++i)
			System.out.println("   "+l.get(i));
	    } 
	catch (Exception e)
	    {
		QPE.display(e);
	    }
    }
}
