Class CustomizationContextChecker

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader

    public class CustomizationContextChecker
    extends org.xml.sax.helpers.XMLFilterImpl
    Checks if binding declarations are placed where they are allowed.

    For example, if a <jaxb:property> customization is given under the <xs:simpleContent> element, this class raises an error.

    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 <complexType> element. The spec team informed us that they would consider resolving this discrepancy in favor of RI, but meanwhile we need to detect errors correctly.

    This filter is implemented for this purpose.

    Customization 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.

    For simple types, customizations are allowed only under the <xs:simpleType> element, and for complex types they are allowed only under the <xs:cimplexType> element.

    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)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void endElement​(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)  
      void setDocumentLocator​(org.xml.sax.Locator locator)  
      void startElement​(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)  
      • Methods inherited from class org.xml.sax.helpers.XMLFilterImpl

        characters, endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CustomizationContextChecker

        public CustomizationContextChecker​(org.xml.sax.ErrorHandler _errorHandler)
        Parameters:
        _errorHandler - Detected errors will be sent to this object.
    • Method Detail

      • startElement

        public void startElement​(java.lang.String namespaceURI,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes atts)
                          throws org.xml.sax.SAXException
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
      • endElement

        public void endElement​(java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator locator)
        Specified by:
        setDocumentLocator in interface org.xml.sax.ContentHandler
        Overrides:
        setDocumentLocator in class org.xml.sax.helpers.XMLFilterImpl