docs: VoltXMLElement voltGetRangeVariableXML(Session session)
      throws org.hsqldb_voltpatches.HSQLInterface.HSQLParseException
      {
          Index        index;
          Index        primaryIndex;
  
          index        = rangeIndex;
          primaryIndex = rangeTable.getPrimaryIndex();
  
          // get the index for this scan (/filter)
          // note: ignored if scan if full table scan
          if (index == null)
              index = primaryIndex;
  
          // output open tag
          VoltXMLElement scan = new VoltXMLElement("tablescan");
  
          if (rangeTable.tableType == TableBase.SYSTEM_SUBQUERY) {
              if (rangeTable instanceof TableDerived) {
                  if (tableAlias == null || tableAlias.name == null) {
                      // VoltDB require derived sub select table with user specified alias
                      throw new org.hsqldb_voltpatches.HSQLInterface.HSQLParseException(
                              "SQL Syntax error: Every derived table must have its own alias.");
                  }
                  scan.attributes.put("table", tableAlias.name.toUpperCase());
  
                  VoltXMLElement subQuery = ((TableDerived) rangeTable).dataExpression.voltGetXML(session);
                  scan.children.add(subQuery);
              }
          } else {
              scan.attributes.put("table", rangeTable.getName().name.toUpperCase());
          }
  
          if (tableAlias != null && !rangeTable.getName().name.equals(tableAlias)) {
              scan.attributes.put("tablealias", tableAlias.name.toUpperCase());
          }
  
          // note if this is an outer join
          if (isLeftJoin && isRightJoin) {
              scan.attributes.put("jointype", "full");
          } else if (isLeftJoin) {
              scan.attributes.put("jointype", "left");
          } else if (isRightJoin) {
              scan.attributes.put("jointype", "right");
          } else {
              scan.attributes.put("jointype", "inner");
          }
  
          Expression joinCond = null;
          Expression whereCond = null;
          // if isJoinIndex and indexCondition are set then indexCondition is join condition
          // else if indexCondition is set then it is where condition
          if (isJoinIndex == true) {
              joinCond = indexCondition;
              if (indexEndCondition != null) {
              	joinCond = makeConjunction(joinCond, indexEndCondition);
              }
              // then go to the nonIndexJoinCondition
              if (nonIndexJoinCondition != null) {
              	joinCond = makeConjunction(joinCond, nonIndexJoinCondition);
              }
              // then go to the nonIndexWhereCondition
              whereCond = nonIndexWhereCondition;
          } else {
              joinCond = nonIndexJoinCondition;
  
              whereCond = indexCondition;
              if (indexEndCondition != null) {
              	whereCond = makeConjunction(whereCond, indexEndCondition);
              }
              // then go to the nonIndexWhereCondition
              if (nonIndexWhereCondition != null) {
              	whereCond = makeConjunction(whereCond, nonIndexWhereCondition);
              }
  
          }
          if (joinCond != null) {
              joinCond = joinCond.eliminateDuplicates(session);
              VoltXMLElement joinCondEl = new VoltXMLElement("joincond");
              joinCondEl.children.add(joinCond.voltGetXML(session));
              scan.children.add(joinCondEl);
          }
  
          if (whereCond != null) {
              whereCond = whereCond.eliminateDuplicates(session);
              VoltXMLElement whereCondEl = new VoltXMLElement("wherecond");
              whereCondEl.children.add(whereCond.voltGetXML(session));
              scan.children.add(whereCondEl);
          }
  
          return scan;
      }