Class NGCCRuntimeEx

java.lang.Object
com.sun.xml.xsom.impl.parser.state.NGCCRuntime
com.sun.xml.xsom.impl.parser.NGCCRuntimeEx
All Implemented Interfaces:
PatcherManager, NGCCEventSource, ContentHandler

public class NGCCRuntimeEx extends NGCCRuntime implements PatcherManager
NGCCRuntime extended with various utility methods for parsing XML Schema.
Author:
Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  • Field Details

    • parser

      public final ParserContext parser
      coordinator.
    • currentSchema

      public SchemaImpl currentSchema
      The schema currently being parsed.
    • finalDefault

      public int finalDefault
      The @finalDefault value of the current schema.
    • blockDefault

      public int blockDefault
      The @blockDefault value of the current schema.
    • elementFormDefault

      public boolean elementFormDefault
      The @elementFormDefault value of the current schema. True if local elements are qualified by default.
    • attributeFormDefault

      public boolean attributeFormDefault
      The @attributeFormDefault value of the current schema. True if local attributes are qualified by default.
    • chameleonMode

      public boolean chameleonMode
      True if the current schema is in a chameleon mode. This changes the way QNames are interpreted. Life is very miserable with XML Schema, as you see.
    • document

      public SchemaDocumentImpl document
      Points to the SchemaDocumentImpl that represents the schema document being parsed.
    • XMLSchemaNSURI

      public static final String XMLSchemaNSURI
      See Also:
  • Method Details

    • checkDoubleDefError

      public void checkDoubleDefError(XSDeclaration c) throws SAXException
      Throws:
      SAXException
    • ignorableDuplicateComponent

      public static boolean ignorableDuplicateComponent(XSDeclaration c)
    • addPatcher

      public void addPatcher(Patch patcher)
      Specified by:
      addPatcher in interface PatcherManager
    • addErrorChecker

      public void addErrorChecker(Patch patcher)
      Specified by:
      addErrorChecker in interface PatcherManager
    • reportError

      public void reportError(String msg, Locator loc) throws SAXException
      Description copied from interface: PatcherManager
      Reports an error during the parsing.
      Specified by:
      reportError in interface PatcherManager
      loc - location of the error in the source file, or null if it's unavailable.
      Throws:
      SAXException
    • reportError

      public void reportError(String msg) throws SAXException
      Throws:
      SAXException
    • includeSchema

      public void includeSchema(String schemaLocation) throws SAXException
      Includes the specified schema.
      Throws:
      SAXException
    • importSchema

      public void importSchema(String ns, String schemaLocation) throws SAXException
      Imports the specified schema.
      Throws:
      SAXException
    • hasAlreadyBeenRead

      public boolean hasAlreadyBeenRead()
      Called when a new document is being parsed and checks if the document has already been parsed before.

      Used to avoid recursive inclusion. Note that the same document will be parsed multiple times if they are for different target namespaces. Document Graph Model

      The challenge we are facing here is that you have a graph of documents that reference each other. Each document has an unique URI to identify themselves, and references are done by using those. The graph may contain cycles.

      Our goal here is to parse all the documents in the graph, without parsing the same document twice. This method implements this check.

      One complication is the chameleon schema; a document can be parsed multiple times if they are under different target namespaces.

      Also, note that when you resolve relative URIs in the @schemaLocation, their base URI is *NOT* the URI of the document.

      Returns:
      true if the document has already been processed and thus needs to be skipped.
    • parseEntity

      public void parseEntity(InputSource source, boolean includeMode, String expectedNamespace, Locator importLocation) throws SAXException
      Parses the specified entity.
      Parameters:
      importLocation - The source location of the import/include statement. Used for reporting errors.
      Throws:
      SAXException
    • createAnnotationParser

      public AnnotationParser createAnnotationParser()
      Creates a new instance of annotation parser.
    • getAnnotationContextElementName

      public String getAnnotationContextElementName()
      Gets the element name that contains the annotation element. This method works correctly only when called by the annotation handler.
    • copyLocator

      public Locator copyLocator()
      Creates a copy of the current locator object.
    • getErrorHandler

      public ErrorHandler getErrorHandler()
    • onEnterElementConsumed

      public void onEnterElementConsumed(String uri, String localName, String qname, Attributes atts) throws SAXException
      Description copied from class: NGCCRuntime
      Called by the generated handler code when an enter element event is consumed.

      Pushes a new attribute set.

      Note that attributes are NOT pushed at the startElement method, because the processing of the enterElement event can trigger other attribute events and etc.

      This method will be called from one of handlers when it truely consumes the enterElement event.

      Overrides:
      onEnterElementConsumed in class NGCCRuntime
      Throws:
      SAXException
    • onLeaveElementConsumed

      public void onLeaveElementConsumed(String uri, String localName, String qname) throws SAXException
      Overrides:
      onLeaveElementConsumed in class NGCCRuntime
      Throws:
      SAXException
    • createValidationContext

      public org.relaxng.datatype.ValidationContext createValidationContext()
      Returns an immutable snapshot of the current context.
    • createXmlString

      public XmlString createXmlString(String value)
    • startPrefixMapping

      public void startPrefixMapping(String prefix, String uri) throws SAXException
      Specified by:
      startPrefixMapping in interface ContentHandler
      Overrides:
      startPrefixMapping in class NGCCRuntime
      Throws:
      SAXException
    • endPrefixMapping

      public void endPrefixMapping(String prefix) throws SAXException
      Specified by:
      endPrefixMapping in interface ContentHandler
      Overrides:
      endPrefixMapping in class NGCCRuntime
      Throws:
      SAXException
    • parseUName

      public UName parseUName(String qname) throws SAXException
      Parses UName under the given context.
      Throws:
      SAXException
    • parseBoolean

      public boolean parseBoolean(String v)
    • unexpectedX

      protected void unexpectedX(String token) throws SAXException
      Overrides:
      unexpectedX in class NGCCRuntime
      Throws:
      SAXException
    • parseForeignAttributes

      public ForeignAttributesImpl parseForeignAttributes(ForeignAttributesImpl next)