throws XMLStreamException {
Index id = (Index) _objectToId.get(obj);
if (id == null) { // New identifier.
id = Index.of(_counter++);
_objectToId.put(obj, id);
_tmp.clear().append(id.intValue());
if (_idURI == null) {
xml.getStreamWriter().writeAttribute(_idName, _tmp);
} else {
xml.getStreamWriter().writeAttribute(_idURI, _idName, _tmp);
}