Java tutorial
/** * This class represents an XSD 'all' element. * * Copyright (C) 2007 Stephen Harding * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Please send inquiries to; steve@inverse2.com * * $Revision: 1.3 $ * * $Log: XSDAll.java,v $ * Revision 1.3 2008/07/01 17:26:46 stevewdh * Changed logging so that user can specify the type they want (Java, Log4J or HTML). * * Revision 1.2 2008/03/05 10:47:27 stevewdh * *** empty log message *** * * Revision 1.1 2007/10/04 11:06:38 stevewdh * *** empty log message *** * * Revision 1.2 2007/09/30 13:09:05 stephen harding * Added contact details to license header. * * Revision 1.1 2007/09/15 16:09:05 stephen harding * Added header. * * */ package com.init.octo.schema; import java.util.Iterator; import java.util.LinkedList; import org.jdom2.Element; import com.init.octo.util.Logger; public class XsdAll extends XSDElementGroup { private static Logger log = Logger.getLogger(XsdAll.class.getName()); // logging object /** * Constructor */ public XsdAll(int indent) { super(indent); this.indent = indent; groupType = "XSDAll"; } /** * This method builds a ALL element * * @param root - the ALL element that defines this element * @param cache - a list of pre-defined XML types */ public boolean build(Element root, XSDCache cache, String parentName) { log.debug("" + indent + ": " + "Build representation of a ALL"); id = root.getAttributeValue(XSDSchema.ID_ATT); maxOccurs = root.getAttributeValue(XSDSchema.MAXOCCURS_ATT); minOccurs = root.getAttributeValue(XSDSchema.MINOCCURS_ATT); group = new LinkedList<XMLType>(); Element element; String elementName; for (Iterator<?> i = (root.getChildren()).iterator(); i.hasNext();) { element = (Element) i.next(); elementName = element.getName(); log.debug("" + indent + ": " + "Child element <" + elementName + "> found"); /** process the child elements that define this element... **/ if (elementName.equals(XSDSchema.ANNOTATION)) { annotation = element.getTextTrim(); } else if (elementName.equals(XSDSchema.ELEMENT)) { log.debug("" + indent + ": " + "Adding element to the list of child elements"); XSDElement e = new XSDElement(indent + 1); if (e.build(element, cache, parentName) != true) { log.error("Error building an element - " + element); return (false); } group.add(e); } else { log.warn("" + indent + ": " + "Unexpected element <" + elementName + "> found and ignored"); } } // end for all child elements of this <ALL> tag log.debug("" + indent + ": " + "ALL built"); return (true); } // end build() } // end class XSDAll