package com.jxml.quick.util.qdml2qjml;
import com.jxml.quick.model.qjml.*;
import com.jxml.quick.*;
import org.xml.sax.*;
import java.util.*;
import com.jxml.quick.ocm.*;
import java.io.*;
import com.jxml.quick.recycle.*;
import com.jxml.quick.engine.*;

public class QCQJML extends OCMrootPeerSupportLite
{
	public void cvt(Object param)
		throws SAXException, IOException
	{
		QMQJML dm=(QMQJML)dataModel;
		QDML2QJML.SubQdml2Qjml c=(QDML2QJML.SubQdml2Qjml)context;
		dm.tagName="qjml";
		int i,s;

		QMQJML orig=c.orig;
		QDoc schema=context.getSchemaDoc();
		s=dm.includes.size();
		for (i=0;i<s;++i)
		{
			QMQJML q=(QMQJML)orig.includes.get(i);
			doCvt(q,null);
			String oldHRef=QRefHash.getHRef(q);
			if (!oldHRef.endsWith(".qdml"))
				throw new SAXException("Include.href does not end with .qdml: "+oldHRef);
			String newHRef=oldHRef.substring(0,oldHRef.length()-4)+"qjml";
			QMQJML cl=(QMQJML)dm.includes.get(i);
			Quick.createDoc(newHRef,cl,schema);
		}

		c.coins=dm.coins;
		for(i=0;i<dm.coins.size();++i)
		{
			c.pos=i;
			QMCoin coin=(QMCoin)dm.coins.get(i);
			doCvt(coin,null);
		}
	}

	// Override method on OCMrootPeerSupportLite
	public Object getOutputRoot()
		throws SAXException, IOException
	{
		cvt(null);

		return dataModel;
	}
}
