@@ -202,32 +202,33 @@ ExclusiveCanonicalization.prototype.process = function(node, options) {
202
202
var ancestorNamespaces = options . ancestorNamespaces || [ ] ;
203
203
204
204
/**
205
- * Get the InclusiveNamespaces PrefixList
206
- */
207
- var inclusiveNamespacesPrefixList = options . inclusiveNamespacesPrefixList || [ ] ;
208
- var CanonicalizationMethod = utils . findChilds ( node , "CanonicalizationMethod" )
209
- if ( CanonicalizationMethod . length != 0 ) {
210
- var inclusiveNamespaces = utils . findChilds ( CanonicalizationMethod [ 0 ] , "InclusiveNamespaces" )
211
- if ( inclusiveNamespaces . length != 0 ) {
212
- inclusiveNamespacesPrefixList = inclusiveNamespaces [ 0 ] . getAttribute ( 'PrefixList' ) . split ( " " ) ;
213
- }
205
+ * If the inclusiveNamespacesPrefixList has not been explicitly provided then look it up in CanonicalizationMethod/InclusiveNamespaces
206
+ */
207
+ if ( inclusiveNamespacesPrefixList . length == 0 ) {
208
+ var CanonicalizationMethod = utils . findChilds ( node , "CanonicalizationMethod" )
209
+ if ( CanonicalizationMethod . length != 0 ) {
210
+ var inclusiveNamespaces = utils . findChilds ( CanonicalizationMethod [ 0 ] , "InclusiveNamespaces" )
211
+ if ( inclusiveNamespaces . length != 0 ) {
212
+ inclusiveNamespacesPrefixList = inclusiveNamespaces [ 0 ] . getAttribute ( 'PrefixList' ) . split ( " " ) ;
213
+ }
214
+ }
214
215
}
215
216
216
217
/**
217
218
* If you have a PrefixList then use it and the ancestors to add the necessary namespaces
218
219
*/
219
- if ( inclusiveNamespacesPrefixList ) {
220
- var prefixList = inclusiveNamespacesPrefixList instanceof Array ? inclusiveNamespacesPrefixList : inclusiveNamespacesPrefixList . split ( ' ' ) ;
221
- prefixList . forEach ( function ( prefix ) {
222
- if ( ancestorNamespaces ) {
223
- ancestorNamespaces . forEach ( function ( ancestorNamespace ) {
224
- if ( prefix == ancestorNamespace . prefix ) {
225
- node . setAttributeNS ( 'http://www.w3.org/2000/xmlns/' , 'xmlns:' + prefix , ancestorNamespace . namespaceURI ) ;
226
- }
227
- } )
228
- }
229
- } )
230
- }
220
+ if ( inclusiveNamespacesPrefixList ) {
221
+ var prefixList = inclusiveNamespacesPrefixList instanceof Array ? inclusiveNamespacesPrefixList : inclusiveNamespacesPrefixList . split ( ' ' ) ;
222
+ prefixList . forEach ( function ( prefix ) {
223
+ if ( ancestorNamespaces ) {
224
+ ancestorNamespaces . forEach ( function ( ancestorNamespace ) {
225
+ if ( prefix == ancestorNamespace . prefix ) {
226
+ node . setAttributeNS ( 'http://www.w3.org/2000/xmlns/' , 'xmlns:' + prefix , ancestorNamespace . namespaceURI ) ;
227
+ }
228
+ } )
229
+ }
230
+ } )
231
+ }
231
232
232
233
var res = this . processInner ( node , [ ] , defaultNs , defaultNsForPrefix , inclusiveNamespacesPrefixList ) ;
233
234
return res ;
0 commit comments