Project

Profile

Help

Revision 2356dfce

Added by Michael Kay almost 3 years ago

Fix bug #4140 (namespace-alias creates duplicate attributes)

View differences:

latest9.9/hej/net/sf/saxon/style/LiteralResultElement.java
24 24
import net.sf.saxon.type.BuiltInAtomicType;
25 25
import net.sf.saxon.type.SchemaType;
26 26
import net.sf.saxon.type.Untyped;
27
import net.sf.saxon.z.IntHashSet;
28
import net.sf.saxon.z.IntSet;
27 29

  
28
import java.util.*;
30
import java.util.ArrayList;
31
import java.util.Arrays;
32
import java.util.Iterator;
33
import java.util.List;
29 34

  
30 35

  
31 36
/**
......
238 243
            // also type-check the AVT expressions
239 244

  
240 245
            if (numberOfAttributes > 0) {
241

  
246
                boolean changed = false;
242 247
                for (int i = 0; i < numberOfAttributes; i++) {
243 248

  
244 249
                    NodeName anameCode = attributeNames[i];
......
252 257
                                    newBinding.getPrefix(),
253 258
                                    newBinding.getURI(),
254 259
                                    getAttributeList().getLocalName(i));
260
                            changed = true;
255 261
                        }
256 262
                    }
257 263

  
258 264
                    attributeNames[i] = alias;
259 265
                    attributeValues[i] = typeCheck(alias.getDisplayName(), attributeValues[i]);
260 266
                }
267

  
268
                if (changed && numberOfAttributes > 1) {
269
                    // spec bug 30400. Check that the attribute names are still distinct
270
                    IntSet names = new IntHashSet(numberOfAttributes);
271
                    for (int i=0; i<numberOfAttributes; i++) {
272
                        int fp = attributeNames[i].obtainFingerprint(getNamePool());
273
                        boolean absent = names.add(fp);
274
                        if (!absent) {
275
                            compileError("As a result of namespace aliasing, two attributes have the same expanded name", "XTSE0813");
276
                        }
277
                    }
278
                }
261 279
            }
262 280

  
263 281
            // remove any namespaces that are on the exclude-result-prefixes list.

Also available in: Unified diff