/* Copyright 1996-2003 Simon Whiteside */ package simkin.examples.inherits; import simkin.*; import org.w3c.dom.*; import org.apache.crimson.tree.*; import org.xml.sax.*; import java.io.*; /** * this class extends the XMLElementObject class with understanding of the <inherits> tag. It overrides the createXMLElementObject method to make sure that any sub-elements are also checked. */ public class InheritsElement extends XMLElementObject { /** Constructor - passes element up to its parent */ public InheritsElement(Element elem){ super(elem); } /** overrides this method so that sub-elements also understand the inherits tag */ protected XMLElementObject createXMLElementObject(Element element){ return new InheritsElement(element); } /** extends this method to check for inherits tags after the element has been set */ protected void setElement(Element elem){ super.setElement(elem); if (elem!=null) replaceInherits(elem); } /** this method replaces any <inherits> tags with the equivalent XML file */ public static void replaceInherits(Element elem){ NodeList nodes=elem.getChildNodes(); int count=0; Document owner=elem.getOwnerDocument(); for (int i=0;i