package com.jxml.quick.config;
import com.jxml.quick.*;
import com.jxml.protocol.*;
import org.xml.sax.*;
import java.io.*;
import java.util.*;

public class Parm
{
	public static void main(String[] arg)
	{
		try
		{
			Protocol.addJXMLProtocolPackage();

			int sargs=arg.length;
			if (sargs!=1)
			{
				System.out.println("One arguments is required:");
				System.out.println("- The name of the param file!");
				return;
			}
			QDoc pschema=CreateParm.createSchema();
			QDoc pdoc=Quick.parse(pschema,arg[0]);
			Parm parm=(Parm)pdoc.getRoot();

			ArrayList pargs=new ArrayList();
			int nvs=parm.nvList.size();
			int i;
			for (i=0;i<nvs;++i)
			{
				NV nv=(NV)parm.nvList.get(i);
				pargs.add("-"+nv.name);
				pargs.add(nv.value);
			}

			QDoc cschema=CreateConfig.createSchema();
			QDoc cdoc=Quick.parse(cschema,parm.cfg);
			Item item=(Item)cdoc.getRoot();

			TreeMap properties=new TreeMap();
			StringBuffer sb=new StringBuffer();
			properties.put("out",sb);
			item.eval(properties,pargs,null);
			System.out.print(sb.toString());
		}
		catch (Exception pe)
		{
			QPE.display(pe);
		}
	}

	public String cfg;
	public ArrayList nvList=new ArrayList();
}
