code: @Override
      public void onID(Datatype datatype, StringToken idToken)
          throws IllegalArgumentException
      {
          if (mIdDefs == null) {
              mIdDefs = new ElementIdMap();
          }
  
          int idType = datatype.getIdType();
          Location loc = mContext.getValidationLocation();
          PrefixedName elemPName = getElementPName();
          PrefixedName attrPName = getAttrPName();
  
          if (idType == Datatype.ID_TYPE_ID) {
              String idStr = idToken.literal.trim();
              ElementId eid = mIdDefs.addDefined(idStr, loc, elemPName, attrPName);
              // We can detect dups by checking if Location is the one we passed:
              if (eid.getLocation() != loc) {
                  mProblem = new XMLValidationProblem(loc, "Duplicate id '"+idStr+"', first declared at "+eid.getLocation());
                  mProblem.setReporter(this);
              }
          } else if (idType == Datatype.ID_TYPE_IDREF) {
              String idStr = idToken.literal.trim();
              mIdDefs.addReferenced(idStr, loc, elemPName, attrPName);
          } else if (idType == Datatype.ID_TYPE_IDREFS) {
              StringTokenizer tokens = new StringTokenizer(idToken.literal);
              while (tokens.hasMoreTokens()) {
                  mIdDefs.addReferenced(tokens.nextToken(), loc, elemPName, attrPName);
              }
          } else { // sanity check
              throw new IllegalStateException("Internal error: unexpected ID datatype: "+datatype);
          }
      }
docs: <p>
  Note: we have to throw a dummy marker exception, which merely
  signals that a validation problem is to be reported.
  This is obviously messy, but has to do for now.