isValidNcName function
Validates that a string is a valid XML NCName (non-colonized name).
NCNames are used for element/attribute names without namespace prefixes. They must:
- Start with a letter or underscore
- Contain only letters, digits, hyphens, underscores, and periods
- Not contain colons
Implementation
bool isValidNcName(String name) {
if (name.isEmpty) return false;
// First character must be letter or underscore
final first = name.codeUnitAt(0);
if (!_isNameStartChar(first)) return false;
// Remaining characters
for (var i = 1; i < name.length; i++) {
if (!_isNameChar(name.codeUnitAt(i))) return false;
}
return true;
}