package com.jxml.quick.util.dtd2qdml;
import com.wutka.dtd.*;
import com.jxml.quick.*;
import org.xml.sax.*;
import java.util.*;
import com.jxml.quick.ocm.*;
import java.io.*;

/**
 * Extracts QJML data.
 */
public class QCDTDAttribute extends OCMpeerSupport
{
	public ArrayList comments=new ArrayList();

	/**
	 * User-provided code to perform the conversion.
	 */
	public void cvt(Object param)
		throws SAXException, IOException
	{
		DTDAttribute dm=(DTDAttribute)dataModel;

		if (param instanceof QCDTDElement)
		{
			QCDTDElement pe=(QCDTDElement)param;
			int i,s;
			String eName=pe.dm.name;
			addStringAttribute("label",eName+"."+dm.name);
			addStringAttribute("tag",dm.name);
			if("IDREF".equals(dm.type))
				addStringAttribute("type","idref");
			startElement("text");
			s=comments.size();
			for(i=0;i<s;i++)
			{
				startElement("rem");
				String comment=(String)comments.get(i);
				addStringContent(comment);
				endElement("rem");
			}
			if (dm.type instanceof DTDEnumeration)
			{
				DTDEnumeration enum=(DTDEnumeration)dm.type;
				Vector v=enum.getItemsVec();
				s=v.size();
				for (i=0;i<s;i++)
				{
					String text=(String)v.get(i);
					addStringAttribute("value",text);
					startElement("enum");
					endElement("enum");
				}
			}
			endElement("text");
		}
		else if (param instanceof ArrayList)
		{
			comments=(ArrayList)param;
		}
	}
}
