/**
   * Receive notification of the end of an element.
   *
   * @param handler non-null reference to current StylesheetHandler that is constructing the
   *     Templates.
   * @param uri The Namespace URI, or an empty string.
   * @param localName The local name (without prefix), or empty string if not namespace processing.
   * @param rawName The qualified name (with prefix).
   */
  public void endElement(StylesheetHandler handler, String uri, String localName, String rawName)
      throws org.xml.sax.SAXException {

    ElemTemplateElement elem = handler.getElemTemplateElement();

    if (elem instanceof ElemLiteralResult) {
      if (((ElemLiteralResult) elem).getIsLiteralResultAsStylesheet()) {
        handler.popStylesheet();
      }
    }

    super.endElement(handler, uri, localName, rawName);
  }