/**
   * Starts document parsing. This method initiates parsing of the COLLADA document and returns when
   * the full document has been parsed.
   *
   * @param args optional arguments to pass to parsers of sub-elements.
   * @return <code>this</code> if parsing is successful, otherwise null.
   * @throws XMLStreamException if an exception occurs while attempting to read the event stream.
   */
  public ColladaRoot parse(Object... args) throws XMLStreamException {
    ColladaParserContext ctx = this.parserContext;

    try {
      for (XMLEvent event = ctx.nextEvent(); ctx.hasNext(); event = ctx.nextEvent()) {
        if (event == null) continue;

        // Allow a <COLLADA> element in any namespace
        if (event.isStartElement()
            && event.asStartElement().getName().getLocalPart().equals("COLLADA")) {
          super.parse(ctx, event, args);
          return this;
        }
      }
    } finally {
      ctx.getEventReader().close();
      this.closeEventStream();
    }
    return null;
  }
  /**
   * Invoked during {@link #initialize()} to create the parser context. The parser context is
   * created by the global {@link gov.nasa.worldwind.util.xml.XMLEventParserContextFactory}.
   *
   * @param reader the reader to associate with the parser context.
   * @return a new parser context.
   */
  protected ColladaParserContext createParserContext(XMLEventReader reader) {
    ColladaParserContext ctx =
        (ColladaParserContext)
            XMLEventParserContextFactory.createParserContext(
                ColladaConstants.COLLADA_MIME_TYPE, this.getNamespaceURI());

    if (ctx == null) {
      // Register a parser context for this root's default namespace
      String[] mimeTypes = new String[] {ColladaConstants.COLLADA_MIME_TYPE};
      XMLEventParserContextFactory.addParserContext(
          mimeTypes, new ColladaParserContext(this.getNamespaceURI()));
      ctx =
          (ColladaParserContext)
              XMLEventParserContextFactory.createParserContext(
                  ColladaConstants.COLLADA_MIME_TYPE, this.getNamespaceURI());
    }

    ctx.setEventReader(reader);

    return ctx;
  }