(name: string, colonIndex: number)
| 418 | * @returns Error message if invalid, null if valid. |
| 419 | */ |
| 420 | export function validateQName(name: string, colonIndex: number): string | null { |
| 421 | if (colonIndex === -1) { |
| 422 | return null; // No colon means valid NCName (already validated by name char rules) |
| 423 | } |
| 424 | |
| 425 | // Colon at start (:foo) - invalid |
| 426 | if (colonIndex === 0) { |
| 427 | return "QName cannot start with ':'"; |
| 428 | } |
| 429 | |
| 430 | // Colon at end (foo:) - invalid |
| 431 | if (colonIndex === name.length - 1) { |
| 432 | return "QName cannot end with ':'"; |
| 433 | } |
| 434 | |
| 435 | // Multiple colons (a:b:c) - invalid |
| 436 | if (name.indexOf(":", colonIndex + 1) !== -1) { |
| 437 | return "QName cannot contain multiple ':'"; |
| 438 | } |
| 439 | |
| 440 | return null; // Valid QName |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Validates a namespace binding (xmlns or xmlns:prefix attribute). |
no outgoing calls
no test coverage detected