if (!(candidateSelectorList.item(0) instanceof SimpleSelector)) {
throw new Exception(
"Candidate selector should only be a SimpleSelector");
}
SelectorListImpl newSelectorList = new SelectorListImpl();
SimpleSelector candidateSelector = (SimpleSelector) candidateSelectorList
.item(0);
for (int i = 0; i < oldList.getLength(); i++) {
Selector selector = oldList.item(i);
newSelectorList.addSelector(createSelectorWithSomePartReplaced(
selector, toBeReplacedSelectorName, candidateSelector));