1212
1313import { existsSync , readFileSync } from 'fs' ;
1414import { resolve } from 'path' ;
15+ import { XMLUtils } from '../XMLUtils' ;
1516import { AttributeGroup } from '../schema/AttributeGroup' ;
1617import { BuiltinTypes } from '../schema/BuiltinTypes' ;
1718import { ContentModel } from '../schema/ContentModel' ;
@@ -340,6 +341,7 @@ export class CompositeGrammar implements Grammar {
340341 resolveCrossSchemaGroup ( qualifiedName : string ) : ContentModel | undefined {
341342 // Try to find the group in all loaded XMLSchemaGrammar instances
342343 for ( const [ namespace , grammar ] of this . grammars . entries ( ) ) {
344+ XMLUtils . ignoreUnused ( namespace ) ;
343345 if ( grammar instanceof XMLSchemaGrammar ) {
344346 const group = grammar . getGroupDefinition ( qualifiedName ) ;
345347 if ( group ) {
@@ -354,6 +356,7 @@ export class CompositeGrammar implements Grammar {
354356 resolveAllGroupReferences ( ) : void {
355357 // Go through all XMLSchemaGrammar instances and try to resolve any unresolved group references
356358 for ( const [ namespace , grammar ] of this . grammars . entries ( ) ) {
359+ XMLUtils . ignoreUnused ( namespace ) ;
357360 if ( grammar instanceof XMLSchemaGrammar ) {
358361 // For now, this would need access to unresolved group references
359362 // This is a placeholder for post-loading resolution
@@ -564,6 +567,7 @@ export class CompositeGrammar implements Grammar {
564567 context : ValidationContext ,
565568 grammar : any
566569 ) : ValidationResult {
570+ XMLUtils . ignoreUnused ( context ) ;
567571 // Get element declaration and its complex type
568572 const elementAttrs = grammar . getElementAttributes ( elementName ) ;
569573 if ( ! elementAttrs || elementAttrs . size === 0 ) {
@@ -620,16 +624,6 @@ export class CompositeGrammar implements Grammar {
620624 return errors . length > 0 ? new ValidationResult ( false , errors ) : ValidationResult . success ( ) ;
621625 }
622626
623- private performAttributeValidation ( grammar : Grammar , elementName : string , attributes : Map < string , string > , context : ValidationContext ) : ValidationResult {
624- // For XMLSchemaGrammar, we handle the validation here in CompositeGrammar
625- if ( grammar . getGrammarType ( ) . toString ( ) === 'xmlschema' ) {
626- return ( grammar as any ) . validateAttributes ( elementName , attributes , context ) ;
627- }
628-
629- // For other grammar types, delegate to the grammar
630- return grammar . validateAttributes ( elementName , attributes , context ) ;
631- }
632-
633627 private performValidation ( grammar : Grammar , elementName : string , context : ValidationContext ) : ValidationResult {
634628 // For XMLSchemaGrammar, we handle the validation here in CompositeGrammar
635629 if ( grammar . getGrammarType ( ) . toString ( ) === 'xmlschema' ) {
@@ -837,6 +831,7 @@ export class CompositeGrammar implements Grammar {
837831 resolveAttributeGroup ( attributeGroupName : string ) : AttributeGroup | undefined {
838832 // First try to resolve in all XMLSchema grammars
839833 for ( const [ namespace , grammar ] of this . grammars ) {
834+ XMLUtils . ignoreUnused ( namespace ) ;
840835 if ( grammar instanceof XMLSchemaGrammar ) {
841836 const attributeGroup = grammar . getAttributeGroupDefinition ( attributeGroupName ) ;
842837 if ( attributeGroup ) {
@@ -871,6 +866,7 @@ export class CompositeGrammar implements Grammar {
871866
872867 // Finally, try unqualified name in all grammars
873868 for ( const [ namespace , grammar ] of this . grammars ) {
869+ XMLUtils . ignoreUnused ( namespace ) ;
874870 if ( grammar instanceof XMLSchemaGrammar ) {
875871 const attributeGroup = grammar . getAttributeGroupDefinition ( attributeGroupName ) ;
876872 if ( attributeGroup ) {
@@ -1062,6 +1058,7 @@ export class CompositeGrammar implements Grammar {
10621058 }
10631059
10641060 private validateComplexType ( elementName : string , context : ValidationContext , complexType : any , grammar : any ) : ValidationResult {
1061+ XMLUtils . ignoreUnused ( elementName ) ;
10651062 // Attributes are already validated during startElement by SAXParser.validateAttributes()
10661063 // No need to validate them again during content validation (endElement)
10671064
0 commit comments