package com.jxml.quick.util.qjml2qiml;
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.*;

/**
 * Extracts QJML data.
 */
public class QCText extends OCMpeerSupport 
{
	public boolean beenHere=false;

	/**
	 * Convert attribute.
	 */
	public void cvt(Object param)
		throws SAXException, IOException
	// param=null: cvt element
	// param="": cvt attribute
	{
		QMText dm=(QMText)dataModel;

		if (beenHere)
		{
			addStringAttribute("href","#"+dm.getLabel());
			//addStringAttribute("schema","http://www.jxml.com/qiml.qiml");
			emptyElement("link");
			return;
		}
		beenHere=true;

		addStringAttribute("tagName",dm.getTag());
		addStringAttribute("ID",dm.getLabel());
		if (dm.wild)
			addStringAttribute("wild","True");
		if ("CDATA".equals(dm.type))
			addStringAttribute("cdata","True");
		if ("idref".equals(dm.type))
			addStringAttribute("isIdRef","True");

		startElement("elementDefinition");

		doCvt(dm.remList,null);

		if (dm.target!=null)
			doCvt(dm.target,dm.getValidList());
		else
			doCvt(QCTargetEditor.newEditor(dm.type),
			       dm.getValidList()); // cvt data

		doCvt(dm.extensions,null);
		doCvt(dm.implementations,null);

		if (param==null)
			doCvt(new QMAttributes(),null);

		endElement("elementDefinition");
	}
}
