/* * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.internal.xjc.reader.xmlschema.parser; import java.util.HashSet; import java.util.Set; import java.util.Stack; import javax.xml.namespace.QName; import com.sun.tools.internal.xjc.reader.Const; import com.sun.xml.internal.bind.v2.WellKnownNamespace; import org.xml.sax.Attributes; import org.xml.sax.ErrorHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.XMLFilterImpl; /** * Checks if binding declarations are placed where they are allowed. * *
* For example, if a {@code
* our main checkpoint of misplaced customizations are in BGMBuilder.
* There, we mark a customization whenever we use it. At the end of the
* day, we look for unmarked customizations and raise errors for them.
*
*
* Between this approach and the JAXB spec 1.0 is a problem that
* the spec allows/prohibits customizations at schema element level,
* while BGMBuilder and XSOM works on schema component levels.
*
*
* For example, a property customization is allowed on a complex type
* schema component, but it's only allowed on the {@code
* This filter is implemented for this purpose.
*
*
*
* For simple types, customizations are allowed only under the {@code
* So the bottom line is that it would be suffice if we just make sure
* that no customization will be attached under other elements of
* simple types and complex types. Those are:
*
* - simpleType/restriction
* - list
* - union
* - complexType/(simple or complex)Content
* - complexType/(simple or complex)Content/(restriction of extension)
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public class CustomizationContextChecker extends XMLFilterImpl {
/** Keep names of all the ancestor elements. */
private final StackCustomization and allowed locations
*
* - globalBinding/schemaBinding
* schema
*
* - class
* complexType(*), modelGroupDecl, modelGroup, element
*
* - property
* attribute, element, any, modelGroup, modelGroupRef, complexType(*)
*
* - javaType
* simpleType(*)
*
* - typesafeEnumClass
* simpleType(*)
*
* - typesafeEnumMember
* simpleType(*), enumeration
*
* Components marked with '*' needs a check by this component
* since more than one schema element corresponds to one schema component
* of that type.
*
*