File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,11 +229,26 @@ export class RelaxNGParser {
229229 }
230230
231231 private findDefaultValueFromChildren ( attribute : XMLElement ) : string | undefined {
232+ // Search depth-first for any compatibility "defaultValue" element among descendants
233+ const stack : XMLElement [ ] = [ ] ;
232234 for ( const child of attribute . getChildren ( ) ) {
233- if ( this . getLocalNameFromElement ( child ) === "defaultValue" ) {
234- return child . getText ( ) . trim ( ) ;
235+ if ( child . getNodeType ( ) === Constants . ELEMENT_NODE ) {
236+ stack . push ( child as XMLElement ) ;
235237 }
236238 }
239+
240+ while ( stack . length > 0 ) {
241+ const node : XMLElement = stack . pop ( ) as XMLElement ;
242+ if ( this . getLocalNameFromElement ( node ) === "defaultValue" ) {
243+ return node . getText ( ) . trim ( ) ;
244+ }
245+ for ( const child of node . getChildren ( ) ) {
246+ if ( child . getNodeType ( ) === Constants . ELEMENT_NODE ) {
247+ stack . push ( child as XMLElement ) ;
248+ }
249+ }
250+ }
251+
237252 return undefined ;
238253 }
239254
You can’t perform that action at this time.
0 commit comments