/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001-2003 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.tib.bibl;
import java.util.Iterator;
import java.util.Vector;
import org.jdom.Element;
/**
* This class extends org.jdom.Document to provide added XML functionality, such as locating specific elements.
* Some of its methods are specific to the TIBBIBL DTD, others are more general in function. XMLDoc is in turn
* extended by {@link TibDoc}, which adds more specific functionality and is the class used in the TiblEdit program.
* This class needs to be cleaned up so that only the most general XML functions remain and the functions that are
* specific to our DTD are relegated to TibDoc.
*
* @author Than Garson, Tibetan and Himalayan Digital Library
*/
public class XMLDoc extends org.jdom.Document implements TibConstants
{
// Attributes
private org.jdom.Element root, sysid, temp;
private org.jdom.Attribute id;
private Vector tagList = new Vector(100);
private String editorId, editorsName;
private org.jdom.output.XMLOutputter xop = new org.jdom.output.XMLOutputter();
// Accessors
public void setRoot()
{
root = getRootElement();
id = root.getAttribute(ID);
if(id == null) {
id = new org.jdom.Attribute(ID,"");
root.setAttribute(id);
}
}
public org.jdom.Element getRoot()
{
return root;
}
public void setID(String id)
{
this.id.setValue(id);
}
public String getID()
{
return (String)id.getValue();
}
public void setSysid(String sysidString)
{
sysid = getSysid();
if(sysid == null) {
temp = findElement(CONTROL);
sysid = new org.jdom.Element(SID);
temp.getChildren().add(0,sysid);
}
sysid.setText(sysidString);
}
public org.jdom.Element getSysid()
{
return findElement(SID);
}
public org.jdom.Element[] getTagList()
{
refreshTagList();
Object[] tempList = tagList.toArray();
org.jdom.Element[] elList = new org.jdom.Element[tempList.length];
for(int c=0; c