View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from reader-stax.vm
3   //  template, any modifications will be overwritten.
4   // ==============================================================
5   package org.apache.maven.model.v4;
6   
7   import java.io.IOException;
8   import java.io.InputStream;
9   import java.io.Reader;
10  import java.text.DateFormat;
11  import java.util.ArrayList;
12  import java.util.Collections;
13  import java.util.Date;
14  import java.util.HashMap;
15  import java.util.HashSet;
16  import java.util.LinkedHashMap;
17  import java.util.List;
18  import java.util.Map;
19  import java.util.Set;
20  import org.apache.maven.api.annotations.Generated;
21  import org.apache.maven.api.model.InputSource;
22  import org.apache.maven.api.model.InputLocation;
23  import org.apache.maven.api.model.Model;
24  import org.apache.maven.api.model.ModelBase;
25  import org.apache.maven.api.model.PluginContainer;
26  import org.apache.maven.api.model.PluginConfiguration;
27  import org.apache.maven.api.model.BuildBase;
28  import org.apache.maven.api.model.Build;
29  import org.apache.maven.api.model.CiManagement;
30  import org.apache.maven.api.model.Notifier;
31  import org.apache.maven.api.model.Contributor;
32  import org.apache.maven.api.model.Dependency;
33  import org.apache.maven.api.model.Developer;
34  import org.apache.maven.api.model.Exclusion;
35  import org.apache.maven.api.model.IssueManagement;
36  import org.apache.maven.api.model.DistributionManagement;
37  import org.apache.maven.api.model.License;
38  import org.apache.maven.api.model.MailingList;
39  import org.apache.maven.api.model.Organization;
40  import org.apache.maven.api.model.PatternSet;
41  import org.apache.maven.api.model.Parent;
42  import org.apache.maven.api.model.Scm;
43  import org.apache.maven.api.model.FileSet;
44  import org.apache.maven.api.model.Resource;
45  import org.apache.maven.api.model.RepositoryBase;
46  import org.apache.maven.api.model.Repository;
47  import org.apache.maven.api.model.DeploymentRepository;
48  import org.apache.maven.api.model.RepositoryPolicy;
49  import org.apache.maven.api.model.Site;
50  import org.apache.maven.api.model.ConfigurationContainer;
51  import org.apache.maven.api.model.Plugin;
52  import org.apache.maven.api.model.PluginExecution;
53  import org.apache.maven.api.model.DependencyManagement;
54  import org.apache.maven.api.model.PluginManagement;
55  import org.apache.maven.api.model.Reporting;
56  import org.apache.maven.api.model.Profile;
57  import org.apache.maven.api.model.Activation;
58  import org.apache.maven.api.model.ActivationProperty;
59  import org.apache.maven.api.model.ActivationOS;
60  import org.apache.maven.api.model.ActivationFile;
61  import org.apache.maven.api.model.ReportPlugin;
62  import org.apache.maven.api.model.ReportSet;
63  import org.apache.maven.api.model.Prerequisites;
64  import org.apache.maven.api.model.Relocation;
65  import org.apache.maven.api.model.Extension;
66  import org.apache.maven.api.model.InputLocation;
67  import org.apache.maven.api.model.InputSource;
68  import org.apache.maven.internal.xml.XmlNodeStaxBuilder;
69  import org.apache.maven.api.xml.XmlNode;
70  import javax.xml.stream.XMLInputFactory;
71  import javax.xml.stream.XMLStreamException;
72  import javax.xml.stream.XMLStreamReader;
73  import javax.xml.transform.stream.StreamSource;
74  
75  import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
76  import static javax.xml.XMLConstants.XML_NS_URI;
77  
78  @Generated
79  public class MavenStaxReader {
80  
81      private static final Map<String, String> DEFAULT_ENTITIES;
82      static {
83          Map<String, String> entities = new HashMap<>();
84          entities.put("nbsp", "\u00a0");
85          entities.put("iexcl", "\u00a1");
86          entities.put("cent", "\u00a2");
87          entities.put("pound", "\u00a3");
88          entities.put("curren", "\u00a4");
89          entities.put("yen", "\u00a5");
90          entities.put("brvbar", "\u00a6");
91          entities.put("sect", "\u00a7");
92          entities.put("uml", "\u00a8");
93          entities.put("copy", "\u00a9");
94          entities.put("ordf", "\u00aa");
95          entities.put("laquo", "\u00ab");
96          entities.put("not", "\u00ac");
97          entities.put("shy", "\u00ad");
98          entities.put("reg", "\u00ae");
99          entities.put("macr", "\u00af");
100         entities.put("deg", "\u00b0");
101         entities.put("plusmn", "\u00b1");
102         entities.put("sup2", "\u00b2");
103         entities.put("sup3", "\u00b3");
104         entities.put("acute", "\u00b4");
105         entities.put("micro", "\u00b5");
106         entities.put("para", "\u00b6");
107         entities.put("middot", "\u00b7");
108         entities.put("cedil", "\u00b8");
109         entities.put("sup1", "\u00b9");
110         entities.put("ordm", "\u00ba");
111         entities.put("raquo", "\u00bb");
112         entities.put("frac14", "\u00bc");
113         entities.put("frac12", "\u00bd");
114         entities.put("frac34", "\u00be");
115         entities.put("iquest", "\u00bf");
116         entities.put("Agrave", "\u00c0");
117         entities.put("Aacute", "\u00c1");
118         entities.put("Acirc", "\u00c2");
119         entities.put("Atilde", "\u00c3");
120         entities.put("Auml", "\u00c4");
121         entities.put("Aring", "\u00c5");
122         entities.put("AElig", "\u00c6");
123         entities.put("Ccedil", "\u00c7");
124         entities.put("Egrave", "\u00c8");
125         entities.put("Eacute", "\u00c9");
126         entities.put("Ecirc", "\u00ca");
127         entities.put("Euml", "\u00cb");
128         entities.put("Igrave", "\u00cc");
129         entities.put("Iacute", "\u00cd");
130         entities.put("Icirc", "\u00ce");
131         entities.put("Iuml", "\u00cf");
132         entities.put("ETH", "\u00d0");
133         entities.put("Ntilde", "\u00d1");
134         entities.put("Ograve", "\u00d2");
135         entities.put("Oacute", "\u00d3");
136         entities.put("Ocirc", "\u00d4");
137         entities.put("Otilde", "\u00d5");
138         entities.put("Ouml", "\u00d6");
139         entities.put("times", "\u00d7");
140         entities.put("Oslash", "\u00d8");
141         entities.put("Ugrave", "\u00d9");
142         entities.put("Uacute", "\u00da");
143         entities.put("Ucirc", "\u00db");
144         entities.put("Uuml", "\u00dc");
145         entities.put("Yacute", "\u00dd");
146         entities.put("THORN", "\u00de");
147         entities.put("szlig", "\u00df");
148         entities.put("agrave", "\u00e0");
149         entities.put("aacute", "\u00e1");
150         entities.put("acirc", "\u00e2");
151         entities.put("atilde", "\u00e3");
152         entities.put("auml", "\u00e4");
153         entities.put("aring", "\u00e5");
154         entities.put("aelig", "\u00e6");
155         entities.put("ccedil", "\u00e7");
156         entities.put("egrave", "\u00e8");
157         entities.put("eacute", "\u00e9");
158         entities.put("ecirc", "\u00ea");
159         entities.put("euml", "\u00eb");
160         entities.put("igrave", "\u00ec");
161         entities.put("iacute", "\u00ed");
162         entities.put("icirc", "\u00ee");
163         entities.put("iuml", "\u00ef");
164         entities.put("eth", "\u00f0");
165         entities.put("ntilde", "\u00f1");
166         entities.put("ograve", "\u00f2");
167         entities.put("oacute", "\u00f3");
168         entities.put("ocirc", "\u00f4");
169         entities.put("otilde", "\u00f5");
170         entities.put("ouml", "\u00f6");
171         entities.put("divide", "\u00f7");
172         entities.put("oslash", "\u00f8");
173         entities.put("ugrave", "\u00f9");
174         entities.put("uacute", "\u00fa");
175         entities.put("ucirc", "\u00fb");
176         entities.put("uuml", "\u00fc");
177         entities.put("yacute", "\u00fd");
178         entities.put("thorn", "\u00fe");
179         entities.put("yuml", "\u00ff");
180 
181         // ----------------------------------------------------------------------
182         // Special entities
183         // ----------------------------------------------------------------------
184 
185         entities.put("OElig", "\u0152");
186         entities.put("oelig", "\u0153");
187         entities.put("Scaron", "\u0160");
188         entities.put("scaron", "\u0161");
189         entities.put("Yuml", "\u0178");
190         entities.put("circ", "\u02c6");
191         entities.put("tilde", "\u02dc");
192         entities.put("ensp", "\u2002");
193         entities.put("emsp", "\u2003");
194         entities.put("thinsp", "\u2009");
195         entities.put("zwnj", "\u200c");
196         entities.put("zwj", "\u200d");
197         entities.put("lrm", "\u200e");
198         entities.put("rlm", "\u200f");
199         entities.put("ndash", "\u2013");
200         entities.put("mdash", "\u2014");
201         entities.put("lsquo", "\u2018");
202         entities.put("rsquo", "\u2019");
203         entities.put("sbquo", "\u201a");
204         entities.put("ldquo", "\u201c");
205         entities.put("rdquo", "\u201d");
206         entities.put("bdquo", "\u201e");
207         entities.put("dagger", "\u2020");
208         entities.put("Dagger", "\u2021");
209         entities.put("permil", "\u2030");
210         entities.put("lsaquo", "\u2039");
211         entities.put("rsaquo", "\u203a");
212         entities.put("euro", "\u20ac");
213 
214         // ----------------------------------------------------------------------
215         // Symbol entities
216         // ----------------------------------------------------------------------
217 
218         entities.put("fnof", "\u0192");
219         entities.put("Alpha", "\u0391");
220         entities.put("Beta", "\u0392");
221         entities.put("Gamma", "\u0393");
222         entities.put("Delta", "\u0394");
223         entities.put("Epsilon", "\u0395");
224         entities.put("Zeta", "\u0396");
225         entities.put("Eta", "\u0397");
226         entities.put("Theta", "\u0398");
227         entities.put("Iota", "\u0399");
228         entities.put("Kappa", "\u039a");
229         entities.put("Lambda", "\u039b");
230         entities.put("Mu", "\u039c");
231         entities.put("Nu", "\u039d");
232         entities.put("Xi", "\u039e");
233         entities.put("Omicron", "\u039f");
234         entities.put("Pi", "\u03a0");
235         entities.put("Rho", "\u03a1");
236         entities.put("Sigma", "\u03a3");
237         entities.put("Tau", "\u03a4");
238         entities.put("Upsilon", "\u03a5");
239         entities.put("Phi", "\u03a6");
240         entities.put("Chi", "\u03a7");
241         entities.put("Psi", "\u03a8");
242         entities.put("Omega", "\u03a9");
243         entities.put("alpha", "\u03b1");
244         entities.put("beta", "\u03b2");
245         entities.put("gamma", "\u03b3");
246         entities.put("delta", "\u03b4");
247         entities.put("epsilon", "\u03b5");
248         entities.put("zeta", "\u03b6");
249         entities.put("eta", "\u03b7");
250         entities.put("theta", "\u03b8");
251         entities.put("iota", "\u03b9");
252         entities.put("kappa", "\u03ba");
253         entities.put("lambda", "\u03bb");
254         entities.put("mu", "\u03bc");
255         entities.put("nu", "\u03bd");
256         entities.put("xi", "\u03be");
257         entities.put("omicron", "\u03bf");
258         entities.put("pi", "\u03c0");
259         entities.put("rho", "\u03c1");
260         entities.put("sigmaf", "\u03c2");
261         entities.put("sigma", "\u03c3");
262         entities.put("tau", "\u03c4");
263         entities.put("upsilon", "\u03c5");
264         entities.put("phi", "\u03c6");
265         entities.put("chi", "\u03c7");
266         entities.put("psi", "\u03c8");
267         entities.put("omega", "\u03c9");
268         entities.put("thetasym", "\u03d1");
269         entities.put("upsih", "\u03d2");
270         entities.put("piv", "\u03d6");
271         entities.put("bull", "\u2022");
272         entities.put("hellip", "\u2026");
273         entities.put("prime", "\u2032");
274         entities.put("Prime", "\u2033");
275         entities.put("oline", "\u203e");
276         entities.put("frasl", "\u2044");
277         entities.put("weierp", "\u2118");
278         entities.put("image", "\u2111");
279         entities.put("real", "\u211c");
280         entities.put("trade", "\u2122");
281         entities.put("alefsym", "\u2135");
282         entities.put("larr", "\u2190");
283         entities.put("uarr", "\u2191");
284         entities.put("rarr", "\u2192");
285         entities.put("darr", "\u2193");
286         entities.put("harr", "\u2194");
287         entities.put("crarr", "\u21b5");
288         entities.put("lArr", "\u21d0");
289         entities.put("uArr", "\u21d1");
290         entities.put("rArr", "\u21d2");
291         entities.put("dArr", "\u21d3");
292         entities.put("hArr", "\u21d4");
293         entities.put("forall", "\u2200");
294         entities.put("part", "\u2202");
295         entities.put("exist", "\u2203");
296         entities.put("empty", "\u2205");
297         entities.put("nabla", "\u2207");
298         entities.put("isin", "\u2208");
299         entities.put("notin", "\u2209");
300         entities.put("ni", "\u220b");
301         entities.put("prod", "\u220f");
302         entities.put("sum", "\u2211");
303         entities.put("minus", "\u2212");
304         entities.put("lowast", "\u2217");
305         entities.put("radic", "\u221a");
306         entities.put("prop", "\u221d");
307         entities.put("infin", "\u221e");
308         entities.put("ang", "\u2220");
309         entities.put("and", "\u2227");
310         entities.put("or", "\u2228");
311         entities.put("cap", "\u2229");
312         entities.put("cup", "\u222a");
313         entities.put("int", "\u222b");
314         entities.put("there4", "\u2234");
315         entities.put("sim", "\u223c");
316         entities.put("cong", "\u2245");
317         entities.put("asymp", "\u2248");
318         entities.put("ne", "\u2260");
319         entities.put("equiv", "\u2261");
320         entities.put("le", "\u2264");
321         entities.put("ge", "\u2265");
322         entities.put("sub", "\u2282");
323         entities.put("sup", "\u2283");
324         entities.put("nsub", "\u2284");
325         entities.put("sube", "\u2286");
326         entities.put("supe", "\u2287");
327         entities.put("oplus", "\u2295");
328         entities.put("otimes", "\u2297");
329         entities.put("perp", "\u22a5");
330         entities.put("sdot", "\u22c5");
331         entities.put("lceil", "\u2308");
332         entities.put("rceil", "\u2309");
333         entities.put("lfloor", "\u230a");
334         entities.put("rfloor", "\u230b");
335         entities.put("lang", "\u2329");
336         entities.put("rang", "\u232a");
337         entities.put("loz", "\u25ca");
338         entities.put("spades", "\u2660");
339         entities.put("clubs", "\u2663");
340         entities.put("hearts", "\u2665");
341         entities.put("diams", "\u2666");
342         DEFAULT_ENTITIES = Collections.unmodifiableMap(entities);
343     }
344 
345     private boolean addDefaultEntities = true;
346     private boolean addLocationInformation = true;
347 
348     private final ContentTransformer contentTransformer;
349 
350     public MavenStaxReader() {
351         this((s, f) -> s);
352     }
353 
354     public MavenStaxReader(ContentTransformer contentTransformer) {
355         this.contentTransformer = contentTransformer;
356     }
357 
358     /**
359      * Returns the state of the "add default entities" flag.
360      *
361      * @return boolean
362      */
363     public boolean getAddDefaultEntities() {
364         return addDefaultEntities;
365     } //-- boolean getAddDefaultEntities()
366 
367     /**
368      * Sets the state of the "add default entities" flag.
369      *
370      * @param addDefaultEntities a addDefaultEntities object.
371      */
372     public void setAddDefaultEntities(boolean addDefaultEntities) {
373         this.addDefaultEntities = addDefaultEntities;
374     } //-- void setAddDefaultEntities(boolean)
375 
376     /**
377      * Returns the state of the "add location information" flag.
378      *
379      * @return boolean
380      */
381     public boolean getAddLocationInformation() {
382         return addLocationInformation;
383     } //-- boolean getAddLocationInformation()
384 
385     /**
386      * Sets the state of the "add location information" flag.
387      *
388      * @param addLocationInformation a addLocationInformation object.
389      */
390     public void setAddLocationInformation(boolean addLocationInformation) {
391         this.addLocationInformation = addLocationInformation;
392     } //-- void setAddLocationInformation(boolean)
393 
394     public Model read(Reader reader) throws XMLStreamException {
395         return read(reader, true, null);
396     }
397 
398     /**
399      * @param reader a reader object.
400      * @param strict a strict object.
401      * @throws XMLStreamException XMLStreamException if
402      * any.
403      * @return Model
404      */
405     public Model read(Reader reader, boolean strict, InputSource source) throws XMLStreamException {
406         XMLInputFactory factory = XMLInputFactory.newFactory();
407         factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
408         StreamSource streamSource = new StreamSource(reader, source != null ? source.getLocation() : null);
409         XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
410         return read(parser, strict, source);
411     } //-- Model read(Reader, boolean)
412 
413     public Model read(InputStream in) throws XMLStreamException {
414         return read(in, true, null);
415     }
416 
417     /**
418      * Method read.
419      *
420      * @param in a in object.
421      * @param strict a strict object.
422      * @throws XMLStreamException XMLStreamException if
423      * any.
424      * @return Model
425      */
426     public Model read(InputStream in, boolean strict, InputSource source) throws XMLStreamException {
427         XMLInputFactory factory = XMLInputFactory.newFactory();
428         factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
429         StreamSource streamSource = new StreamSource(in, source != null ? source.getLocation() : null);
430         XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
431         return read(parser, strict, source);
432     } //-- Model read(InputStream, boolean)
433 
434     /**
435      * Method read.
436      *
437      * @param parser a parser object.
438      * @param strict a strict object.
439      * @throws XMLStreamException XMLStreamException if
440      * any.
441      * @return Model
442      */
443     public Model read(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
444         Model model = null;
445         int eventType = parser.getEventType();
446         boolean parsed = false;
447         while (eventType != XMLStreamReader.END_DOCUMENT) {
448             if (eventType == XMLStreamReader.START_ELEMENT) {
449                 if (strict && ! "project".equals(parser.getLocalName())) {
450                     throw new XMLStreamException("Expected root element 'project' but found '" + parser.getName() + "'", parser.getLocation(), null);
451                 } else if (parsed) {
452                     // fallback, already expected a XMLStreamException due to invalid XML
453                     throw new XMLStreamException("Duplicated tag: 'project'", parser.getLocation(), null);
454                 }
455                 model = parseModel(parser, strict, source);
456                 parsed = true;
457             }
458             eventType = parser.next();
459         }
460         if (parsed) {
461             return model;
462         }
463         throw new XMLStreamException("Expected root element 'project' but found no element at all: invalid XML document", parser.getLocation(), null);
464     } //-- Model read(XMLStreamReader, boolean)
465 
466     private Model parseModel(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
467         String tagName = parser.getLocalName();
468         Model.Builder model = Model.newBuilder(true);
469         if (addLocationInformation) {
470             model.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
471         }
472         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
473             String name = parser.getAttributeLocalName(i);
474             String ns = parser.getAttributeNamespace(i);
475             String value = parser.getAttributeValue(i);
476             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
477                 // just ignore attributes with non-default namespace (for example: xsi and xml)
478             } else if ("xmlns".equals(name)) {
479                 // ignore xmlns attribute in root class, which is a reserved attribute name
480             } else if ("child.project.url.inherit.append.path".equals(name)) {
481                 if (addLocationInformation) {
482                     model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
483                 }
484                 model.childProjectUrlInheritAppendPath(interpolatedTrimmed(value, "child.project.url.inherit.append.path"));
485             } else if ("root".equals(name)) {
486                 if (addLocationInformation) {
487                     model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
488                 }
489                 model.root(getBooleanValue(interpolatedTrimmed(value, "root"), "root", parser, false));
490             } else if ("preserve.model.version".equals(name)) {
491                 if (addLocationInformation) {
492                     model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
493                 }
494                 model.preserveModelVersion(getBooleanValue(interpolatedTrimmed(value, "preserve.model.version"), "preserve.model.version", parser, false));
495             } else {
496                 checkUnknownAttribute(parser, name, tagName, strict);
497             }
498         }
499         Set<String> parsed = new HashSet<>();
500         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
501             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
502             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
503             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
504             Map<Object, InputLocation> locations = null;
505             switch (childName) {
506                 case "modelVersion": {
507                     model.modelVersion(interpolatedTrimmed(nextText(parser, strict), "modelVersion"));
508                     break;
509                 }
510                 case "parent": {
511                     model.parent(parseParent(parser, strict, source));
512                     break;
513                 }
514                 case "groupId": {
515                     model.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
516                     break;
517                 }
518                 case "artifactId": {
519                     model.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
520                     break;
521                 }
522                 case "version": {
523                     model.version(interpolatedTrimmed(nextText(parser, strict), "version"));
524                     break;
525                 }
526                 case "packaging": {
527                     model.packaging(interpolatedTrimmed(nextText(parser, strict), "packaging"));
528                     break;
529                 }
530                 case "name": {
531                     model.name(interpolatedTrimmed(nextText(parser, strict), "name"));
532                     break;
533                 }
534                 case "description": {
535                     model.description(interpolatedTrimmed(nextText(parser, strict), "description"));
536                     break;
537                 }
538                 case "url": {
539                     model.url(interpolatedTrimmed(nextText(parser, strict), "url"));
540                     break;
541                 }
542                 case "inceptionYear": {
543                     model.inceptionYear(interpolatedTrimmed(nextText(parser, strict), "inceptionYear"));
544                     break;
545                 }
546                 case "organization": {
547                     model.organization(parseOrganization(parser, strict, source));
548                     break;
549                 }
550                 case "licenses": {
551                     List<License> licenses = new ArrayList<>();
552                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
553                         if ("license".equals(parser.getLocalName())) {
554                             licenses.add(parseLicense(parser, strict, source));
555                         } else {
556                             checkUnknownElement(parser, strict);
557                         }
558                     }
559                     model.licenses(licenses);
560                     break;
561                 }
562                 case "developers": {
563                     List<Developer> developers = new ArrayList<>();
564                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
565                         if ("developer".equals(parser.getLocalName())) {
566                             developers.add(parseDeveloper(parser, strict, source));
567                         } else {
568                             checkUnknownElement(parser, strict);
569                         }
570                     }
571                     model.developers(developers);
572                     break;
573                 }
574                 case "contributors": {
575                     List<Contributor> contributors = new ArrayList<>();
576                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
577                         if ("contributor".equals(parser.getLocalName())) {
578                             contributors.add(parseContributor(parser, strict, source));
579                         } else {
580                             checkUnknownElement(parser, strict);
581                         }
582                     }
583                     model.contributors(contributors);
584                     break;
585                 }
586                 case "mailingLists": {
587                     List<MailingList> mailingLists = new ArrayList<>();
588                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
589                         if ("mailingList".equals(parser.getLocalName())) {
590                             mailingLists.add(parseMailingList(parser, strict, source));
591                         } else {
592                             checkUnknownElement(parser, strict);
593                         }
594                     }
595                     model.mailingLists(mailingLists);
596                     break;
597                 }
598                 case "prerequisites": {
599                     model.prerequisites(parsePrerequisites(parser, strict, source));
600                     break;
601                 }
602                 case "modules": {
603                     List<String> modules = new ArrayList<>();
604                     locations = new HashMap<>();
605                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
606                         if ("module".equals(parser.getLocalName())) {
607                             if (addLocationInformation) {
608                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
609                             }
610                             modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
611                         } else {
612                             checkUnknownElement(parser, strict);
613                         }
614                     }
615                     model.modules(modules);
616                     break;
617                 }
618                 case "subprojects": {
619                     List<String> subprojects = new ArrayList<>();
620                     locations = new HashMap<>();
621                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
622                         if ("subproject".equals(parser.getLocalName())) {
623                             if (addLocationInformation) {
624                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
625                             }
626                             subprojects.add(interpolatedTrimmed(nextText(parser, strict), "subprojects"));
627                         } else {
628                             checkUnknownElement(parser, strict);
629                         }
630                     }
631                     model.subprojects(subprojects);
632                     break;
633                 }
634                 case "scm": {
635                     model.scm(parseScm(parser, strict, source));
636                     break;
637                 }
638                 case "issueManagement": {
639                     model.issueManagement(parseIssueManagement(parser, strict, source));
640                     break;
641                 }
642                 case "ciManagement": {
643                     model.ciManagement(parseCiManagement(parser, strict, source));
644                     break;
645                 }
646                 case "distributionManagement": {
647                     model.distributionManagement(parseDistributionManagement(parser, strict, source));
648                     break;
649                 }
650                 case "properties": {
651                     Map<String, String> properties = new LinkedHashMap<>();
652                     locations = new HashMap<>();
653                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
654                         String key = parser.getLocalName();
655                         String value = nextText(parser, strict).trim();
656                         if (addLocationInformation) {
657                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
658                         }
659                         properties.put(key, value);
660                     }
661                     model.properties(properties);
662                     break;
663                 }
664                 case "dependencyManagement": {
665                     model.dependencyManagement(parseDependencyManagement(parser, strict, source));
666                     break;
667                 }
668                 case "dependencies": {
669                     List<Dependency> dependencies = new ArrayList<>();
670                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
671                         if ("dependency".equals(parser.getLocalName())) {
672                             dependencies.add(parseDependency(parser, strict, source));
673                         } else {
674                             checkUnknownElement(parser, strict);
675                         }
676                     }
677                     model.dependencies(dependencies);
678                     break;
679                 }
680                 case "repositories": {
681                     List<Repository> repositories = new ArrayList<>();
682                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
683                         if ("repository".equals(parser.getLocalName())) {
684                             repositories.add(parseRepository(parser, strict, source));
685                         } else {
686                             checkUnknownElement(parser, strict);
687                         }
688                     }
689                     model.repositories(repositories);
690                     break;
691                 }
692                 case "pluginRepositories": {
693                     List<Repository> pluginRepositories = new ArrayList<>();
694                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
695                         if ("pluginRepository".equals(parser.getLocalName())) {
696                             pluginRepositories.add(parseRepository(parser, strict, source));
697                         } else {
698                             checkUnknownElement(parser, strict);
699                         }
700                     }
701                     model.pluginRepositories(pluginRepositories);
702                     break;
703                 }
704                 case "build": {
705                     model.build(parseBuild(parser, strict, source));
706                     break;
707                 }
708                 case "reporting": {
709                     model.reporting(parseReporting(parser, strict, source));
710                     break;
711                 }
712                 case "profiles": {
713                     List<Profile> profiles = new ArrayList<>();
714                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
715                         if ("profile".equals(parser.getLocalName())) {
716                             profiles.add(parseProfile(parser, strict, source));
717                         } else {
718                             checkUnknownElement(parser, strict);
719                         }
720                     }
721                     model.profiles(profiles);
722                     break;
723                 }
724                 default: {
725                     checkUnknownElement(parser, strict);
726                     break;
727                 }
728             }
729             if (addLocationInformation) {
730                 model.location(childName, new InputLocation(line, column, source, locations));
731             }
732         }
733         model.namespaceUri(parser.getNamespaceURI());
734         model.modelEncoding(parser.getEncoding());
735         return model.build();
736     }
737 
738     private ModelBase parseModelBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
739         String tagName = parser.getLocalName();
740         ModelBase.Builder modelBase = ModelBase.newBuilder(true);
741         if (addLocationInformation) {
742             modelBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
743         }
744         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
745             String name = parser.getAttributeLocalName(i);
746             String ns = parser.getAttributeNamespace(i);
747             String value = parser.getAttributeValue(i);
748             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
749                 // just ignore attributes with non-default namespace (for example: xsi and xml)
750             } else {
751                 checkUnknownAttribute(parser, name, tagName, strict);
752             }
753         }
754         Set<String> parsed = new HashSet<>();
755         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
756             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
757             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
758             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
759             Map<Object, InputLocation> locations = null;
760             switch (childName) {
761                 case "modules": {
762                     List<String> modules = new ArrayList<>();
763                     locations = new HashMap<>();
764                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
765                         if ("module".equals(parser.getLocalName())) {
766                             if (addLocationInformation) {
767                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
768                             }
769                             modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
770                         } else {
771                             checkUnknownElement(parser, strict);
772                         }
773                     }
774                     modelBase.modules(modules);
775                     break;
776                 }
777                 case "subprojects": {
778                     List<String> subprojects = new ArrayList<>();
779                     locations = new HashMap<>();
780                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
781                         if ("subproject".equals(parser.getLocalName())) {
782                             if (addLocationInformation) {
783                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
784                             }
785                             subprojects.add(interpolatedTrimmed(nextText(parser, strict), "subprojects"));
786                         } else {
787                             checkUnknownElement(parser, strict);
788                         }
789                     }
790                     modelBase.subprojects(subprojects);
791                     break;
792                 }
793                 case "distributionManagement": {
794                     modelBase.distributionManagement(parseDistributionManagement(parser, strict, source));
795                     break;
796                 }
797                 case "properties": {
798                     Map<String, String> properties = new LinkedHashMap<>();
799                     locations = new HashMap<>();
800                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
801                         String key = parser.getLocalName();
802                         String value = nextText(parser, strict).trim();
803                         if (addLocationInformation) {
804                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
805                         }
806                         properties.put(key, value);
807                     }
808                     modelBase.properties(properties);
809                     break;
810                 }
811                 case "dependencyManagement": {
812                     modelBase.dependencyManagement(parseDependencyManagement(parser, strict, source));
813                     break;
814                 }
815                 case "dependencies": {
816                     List<Dependency> dependencies = new ArrayList<>();
817                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
818                         if ("dependency".equals(parser.getLocalName())) {
819                             dependencies.add(parseDependency(parser, strict, source));
820                         } else {
821                             checkUnknownElement(parser, strict);
822                         }
823                     }
824                     modelBase.dependencies(dependencies);
825                     break;
826                 }
827                 case "repositories": {
828                     List<Repository> repositories = new ArrayList<>();
829                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
830                         if ("repository".equals(parser.getLocalName())) {
831                             repositories.add(parseRepository(parser, strict, source));
832                         } else {
833                             checkUnknownElement(parser, strict);
834                         }
835                     }
836                     modelBase.repositories(repositories);
837                     break;
838                 }
839                 case "pluginRepositories": {
840                     List<Repository> pluginRepositories = new ArrayList<>();
841                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
842                         if ("pluginRepository".equals(parser.getLocalName())) {
843                             pluginRepositories.add(parseRepository(parser, strict, source));
844                         } else {
845                             checkUnknownElement(parser, strict);
846                         }
847                     }
848                     modelBase.pluginRepositories(pluginRepositories);
849                     break;
850                 }
851                 case "reporting": {
852                     modelBase.reporting(parseReporting(parser, strict, source));
853                     break;
854                 }
855                 default: {
856                     checkUnknownElement(parser, strict);
857                     break;
858                 }
859             }
860             if (addLocationInformation) {
861                 modelBase.location(childName, new InputLocation(line, column, source, locations));
862             }
863         }
864         return modelBase.build();
865     }
866 
867     private PluginContainer parsePluginContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
868         String tagName = parser.getLocalName();
869         PluginContainer.Builder pluginContainer = PluginContainer.newBuilder(true);
870         if (addLocationInformation) {
871             pluginContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
872         }
873         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
874             String name = parser.getAttributeLocalName(i);
875             String ns = parser.getAttributeNamespace(i);
876             String value = parser.getAttributeValue(i);
877             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
878                 // just ignore attributes with non-default namespace (for example: xsi and xml)
879             } else {
880                 checkUnknownAttribute(parser, name, tagName, strict);
881             }
882         }
883         Set<String> parsed = new HashSet<>();
884         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
885             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
886             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
887             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
888             Map<Object, InputLocation> locations = null;
889             switch (childName) {
890                 case "plugins": {
891                     List<Plugin> plugins = new ArrayList<>();
892                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
893                         if ("plugin".equals(parser.getLocalName())) {
894                             plugins.add(parsePlugin(parser, strict, source));
895                         } else {
896                             checkUnknownElement(parser, strict);
897                         }
898                     }
899                     pluginContainer.plugins(plugins);
900                     break;
901                 }
902                 default: {
903                     checkUnknownElement(parser, strict);
904                     break;
905                 }
906             }
907             if (addLocationInformation) {
908                 pluginContainer.location(childName, new InputLocation(line, column, source, locations));
909             }
910         }
911         return pluginContainer.build();
912     }
913 
914     private PluginConfiguration parsePluginConfiguration(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
915         String tagName = parser.getLocalName();
916         PluginConfiguration.Builder pluginConfiguration = PluginConfiguration.newBuilder(true);
917         if (addLocationInformation) {
918             pluginConfiguration.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
919         }
920         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
921             String name = parser.getAttributeLocalName(i);
922             String ns = parser.getAttributeNamespace(i);
923             String value = parser.getAttributeValue(i);
924             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
925                 // just ignore attributes with non-default namespace (for example: xsi and xml)
926             } else {
927                 checkUnknownAttribute(parser, name, tagName, strict);
928             }
929         }
930         Set<String> parsed = new HashSet<>();
931         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
932             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
933             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
934             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
935             Map<Object, InputLocation> locations = null;
936             switch (childName) {
937                 case "pluginManagement": {
938                     pluginConfiguration.pluginManagement(parsePluginManagement(parser, strict, source));
939                     break;
940                 }
941                 case "plugins": {
942                     List<Plugin> plugins = new ArrayList<>();
943                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
944                         if ("plugin".equals(parser.getLocalName())) {
945                             plugins.add(parsePlugin(parser, strict, source));
946                         } else {
947                             checkUnknownElement(parser, strict);
948                         }
949                     }
950                     pluginConfiguration.plugins(plugins);
951                     break;
952                 }
953                 default: {
954                     checkUnknownElement(parser, strict);
955                     break;
956                 }
957             }
958             if (addLocationInformation) {
959                 pluginConfiguration.location(childName, new InputLocation(line, column, source, locations));
960             }
961         }
962         return pluginConfiguration.build();
963     }
964 
965     private BuildBase parseBuildBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
966         String tagName = parser.getLocalName();
967         BuildBase.Builder buildBase = BuildBase.newBuilder(true);
968         if (addLocationInformation) {
969             buildBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
970         }
971         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
972             String name = parser.getAttributeLocalName(i);
973             String ns = parser.getAttributeNamespace(i);
974             String value = parser.getAttributeValue(i);
975             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
976                 // just ignore attributes with non-default namespace (for example: xsi and xml)
977             } else {
978                 checkUnknownAttribute(parser, name, tagName, strict);
979             }
980         }
981         Set<String> parsed = new HashSet<>();
982         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
983             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
984             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
985             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
986             Map<Object, InputLocation> locations = null;
987             switch (childName) {
988                 case "defaultGoal": {
989                     buildBase.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
990                     break;
991                 }
992                 case "resources": {
993                     List<Resource> resources = new ArrayList<>();
994                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
995                         if ("resource".equals(parser.getLocalName())) {
996                             resources.add(parseResource(parser, strict, source));
997                         } else {
998                             checkUnknownElement(parser, strict);
999                         }
1000                     }
1001                     buildBase.resources(resources);
1002                     break;
1003                 }
1004                 case "testResources": {
1005                     List<Resource> testResources = new ArrayList<>();
1006                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1007                         if ("testResource".equals(parser.getLocalName())) {
1008                             testResources.add(parseResource(parser, strict, source));
1009                         } else {
1010                             checkUnknownElement(parser, strict);
1011                         }
1012                     }
1013                     buildBase.testResources(testResources);
1014                     break;
1015                 }
1016                 case "directory": {
1017                     buildBase.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
1018                     break;
1019                 }
1020                 case "finalName": {
1021                     buildBase.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
1022                     break;
1023                 }
1024                 case "filters": {
1025                     List<String> filters = new ArrayList<>();
1026                     locations = new HashMap<>();
1027                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1028                         if ("filter".equals(parser.getLocalName())) {
1029                             if (addLocationInformation) {
1030                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1031                             }
1032                             filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
1033                         } else {
1034                             checkUnknownElement(parser, strict);
1035                         }
1036                     }
1037                     buildBase.filters(filters);
1038                     break;
1039                 }
1040                 case "pluginManagement": {
1041                     buildBase.pluginManagement(parsePluginManagement(parser, strict, source));
1042                     break;
1043                 }
1044                 case "plugins": {
1045                     List<Plugin> plugins = new ArrayList<>();
1046                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1047                         if ("plugin".equals(parser.getLocalName())) {
1048                             plugins.add(parsePlugin(parser, strict, source));
1049                         } else {
1050                             checkUnknownElement(parser, strict);
1051                         }
1052                     }
1053                     buildBase.plugins(plugins);
1054                     break;
1055                 }
1056                 default: {
1057                     checkUnknownElement(parser, strict);
1058                     break;
1059                 }
1060             }
1061             if (addLocationInformation) {
1062                 buildBase.location(childName, new InputLocation(line, column, source, locations));
1063             }
1064         }
1065         return buildBase.build();
1066     }
1067 
1068     private Build parseBuild(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1069         String tagName = parser.getLocalName();
1070         Build.Builder build = Build.newBuilder(true);
1071         if (addLocationInformation) {
1072             build.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1073         }
1074         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1075             String name = parser.getAttributeLocalName(i);
1076             String ns = parser.getAttributeNamespace(i);
1077             String value = parser.getAttributeValue(i);
1078             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1079                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1080             } else {
1081                 checkUnknownAttribute(parser, name, tagName, strict);
1082             }
1083         }
1084         Set<String> parsed = new HashSet<>();
1085         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1086             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1087             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1088             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1089             Map<Object, InputLocation> locations = null;
1090             switch (childName) {
1091                 case "sourceDirectory": {
1092                     build.sourceDirectory(interpolatedTrimmed(nextText(parser, strict), "sourceDirectory"));
1093                     break;
1094                 }
1095                 case "scriptSourceDirectory": {
1096                     build.scriptSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "scriptSourceDirectory"));
1097                     break;
1098                 }
1099                 case "testSourceDirectory": {
1100                     build.testSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "testSourceDirectory"));
1101                     break;
1102                 }
1103                 case "outputDirectory": {
1104                     build.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
1105                     break;
1106                 }
1107                 case "testOutputDirectory": {
1108                     build.testOutputDirectory(interpolatedTrimmed(nextText(parser, strict), "testOutputDirectory"));
1109                     break;
1110                 }
1111                 case "extensions": {
1112                     List<Extension> extensions = new ArrayList<>();
1113                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1114                         if ("extension".equals(parser.getLocalName())) {
1115                             extensions.add(parseExtension(parser, strict, source));
1116                         } else {
1117                             checkUnknownElement(parser, strict);
1118                         }
1119                     }
1120                     build.extensions(extensions);
1121                     break;
1122                 }
1123                 case "defaultGoal": {
1124                     build.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
1125                     break;
1126                 }
1127                 case "resources": {
1128                     List<Resource> resources = new ArrayList<>();
1129                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1130                         if ("resource".equals(parser.getLocalName())) {
1131                             resources.add(parseResource(parser, strict, source));
1132                         } else {
1133                             checkUnknownElement(parser, strict);
1134                         }
1135                     }
1136                     build.resources(resources);
1137                     break;
1138                 }
1139                 case "testResources": {
1140                     List<Resource> testResources = new ArrayList<>();
1141                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1142                         if ("testResource".equals(parser.getLocalName())) {
1143                             testResources.add(parseResource(parser, strict, source));
1144                         } else {
1145                             checkUnknownElement(parser, strict);
1146                         }
1147                     }
1148                     build.testResources(testResources);
1149                     break;
1150                 }
1151                 case "directory": {
1152                     build.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
1153                     break;
1154                 }
1155                 case "finalName": {
1156                     build.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
1157                     break;
1158                 }
1159                 case "filters": {
1160                     List<String> filters = new ArrayList<>();
1161                     locations = new HashMap<>();
1162                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1163                         if ("filter".equals(parser.getLocalName())) {
1164                             if (addLocationInformation) {
1165                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1166                             }
1167                             filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
1168                         } else {
1169                             checkUnknownElement(parser, strict);
1170                         }
1171                     }
1172                     build.filters(filters);
1173                     break;
1174                 }
1175                 case "pluginManagement": {
1176                     build.pluginManagement(parsePluginManagement(parser, strict, source));
1177                     break;
1178                 }
1179                 case "plugins": {
1180                     List<Plugin> plugins = new ArrayList<>();
1181                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1182                         if ("plugin".equals(parser.getLocalName())) {
1183                             plugins.add(parsePlugin(parser, strict, source));
1184                         } else {
1185                             checkUnknownElement(parser, strict);
1186                         }
1187                     }
1188                     build.plugins(plugins);
1189                     break;
1190                 }
1191                 default: {
1192                     checkUnknownElement(parser, strict);
1193                     break;
1194                 }
1195             }
1196             if (addLocationInformation) {
1197                 build.location(childName, new InputLocation(line, column, source, locations));
1198             }
1199         }
1200         return build.build();
1201     }
1202 
1203     private CiManagement parseCiManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1204         String tagName = parser.getLocalName();
1205         CiManagement.Builder ciManagement = CiManagement.newBuilder(true);
1206         if (addLocationInformation) {
1207             ciManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1208         }
1209         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1210             String name = parser.getAttributeLocalName(i);
1211             String ns = parser.getAttributeNamespace(i);
1212             String value = parser.getAttributeValue(i);
1213             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1214                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1215             } else {
1216                 checkUnknownAttribute(parser, name, tagName, strict);
1217             }
1218         }
1219         Set<String> parsed = new HashSet<>();
1220         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1221             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1222             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1223             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1224             Map<Object, InputLocation> locations = null;
1225             switch (childName) {
1226                 case "system": {
1227                     ciManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
1228                     break;
1229                 }
1230                 case "url": {
1231                     ciManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1232                     break;
1233                 }
1234                 case "notifiers": {
1235                     List<Notifier> notifiers = new ArrayList<>();
1236                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1237                         if ("notifier".equals(parser.getLocalName())) {
1238                             notifiers.add(parseNotifier(parser, strict, source));
1239                         } else {
1240                             checkUnknownElement(parser, strict);
1241                         }
1242                     }
1243                     ciManagement.notifiers(notifiers);
1244                     break;
1245                 }
1246                 default: {
1247                     checkUnknownElement(parser, strict);
1248                     break;
1249                 }
1250             }
1251             if (addLocationInformation) {
1252                 ciManagement.location(childName, new InputLocation(line, column, source, locations));
1253             }
1254         }
1255         return ciManagement.build();
1256     }
1257 
1258     private Notifier parseNotifier(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1259         String tagName = parser.getLocalName();
1260         Notifier.Builder notifier = Notifier.newBuilder(true);
1261         if (addLocationInformation) {
1262             notifier.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1263         }
1264         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1265             String name = parser.getAttributeLocalName(i);
1266             String ns = parser.getAttributeNamespace(i);
1267             String value = parser.getAttributeValue(i);
1268             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1269                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1270             } else {
1271                 checkUnknownAttribute(parser, name, tagName, strict);
1272             }
1273         }
1274         Set<String> parsed = new HashSet<>();
1275         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1276             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1277             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1278             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1279             Map<Object, InputLocation> locations = null;
1280             switch (childName) {
1281                 case "type": {
1282                     notifier.type(interpolatedTrimmed(nextText(parser, strict), "type"));
1283                     break;
1284                 }
1285                 case "sendOnError": {
1286                     notifier.sendOnError(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnError"), "sendOnError", parser, true));
1287                     break;
1288                 }
1289                 case "sendOnFailure": {
1290                     notifier.sendOnFailure(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnFailure"), "sendOnFailure", parser, true));
1291                     break;
1292                 }
1293                 case "sendOnSuccess": {
1294                     notifier.sendOnSuccess(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnSuccess"), "sendOnSuccess", parser, true));
1295                     break;
1296                 }
1297                 case "sendOnWarning": {
1298                     notifier.sendOnWarning(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnWarning"), "sendOnWarning", parser, true));
1299                     break;
1300                 }
1301                 case "address": {
1302                     notifier.address(interpolatedTrimmed(nextText(parser, strict), "address"));
1303                     break;
1304                 }
1305                 case "configuration": {
1306                     Map<String, String> configuration = new LinkedHashMap<>();
1307                     locations = new HashMap<>();
1308                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1309                         String key = parser.getLocalName();
1310                         String value = nextText(parser, strict).trim();
1311                         if (addLocationInformation) {
1312                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1313                         }
1314                         configuration.put(key, value);
1315                     }
1316                     notifier.configuration(configuration);
1317                     break;
1318                 }
1319                 default: {
1320                     checkUnknownElement(parser, strict);
1321                     break;
1322                 }
1323             }
1324             if (addLocationInformation) {
1325                 notifier.location(childName, new InputLocation(line, column, source, locations));
1326             }
1327         }
1328         return notifier.build();
1329     }
1330 
1331     private Contributor parseContributor(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1332         String tagName = parser.getLocalName();
1333         Contributor.Builder contributor = Contributor.newBuilder(true);
1334         if (addLocationInformation) {
1335             contributor.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1336         }
1337         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1338             String name = parser.getAttributeLocalName(i);
1339             String ns = parser.getAttributeNamespace(i);
1340             String value = parser.getAttributeValue(i);
1341             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1342                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1343             } else {
1344                 checkUnknownAttribute(parser, name, tagName, strict);
1345             }
1346         }
1347         Set<String> parsed = new HashSet<>();
1348         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1349             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1350             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1351             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1352             Map<Object, InputLocation> locations = null;
1353             switch (childName) {
1354                 case "name": {
1355                     contributor.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1356                     break;
1357                 }
1358                 case "email": {
1359                     contributor.email(interpolatedTrimmed(nextText(parser, strict), "email"));
1360                     break;
1361                 }
1362                 case "url": {
1363                     contributor.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1364                     break;
1365                 }
1366                 case "organization": {
1367                     contributor.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
1368                     break;
1369                 }
1370                 case "organizationUrl": {
1371                     contributor.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
1372                     break;
1373                 }
1374                 case "roles": {
1375                     List<String> roles = new ArrayList<>();
1376                     locations = new HashMap<>();
1377                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1378                         if ("role".equals(parser.getLocalName())) {
1379                             if (addLocationInformation) {
1380                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1381                             }
1382                             roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
1383                         } else {
1384                             checkUnknownElement(parser, strict);
1385                         }
1386                     }
1387                     contributor.roles(roles);
1388                     break;
1389                 }
1390                 case "timezone": {
1391                     contributor.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
1392                     break;
1393                 }
1394                 case "properties": {
1395                     Map<String, String> properties = new LinkedHashMap<>();
1396                     locations = new HashMap<>();
1397                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1398                         String key = parser.getLocalName();
1399                         String value = nextText(parser, strict).trim();
1400                         if (addLocationInformation) {
1401                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1402                         }
1403                         properties.put(key, value);
1404                     }
1405                     contributor.properties(properties);
1406                     break;
1407                 }
1408                 default: {
1409                     checkUnknownElement(parser, strict);
1410                     break;
1411                 }
1412             }
1413             if (addLocationInformation) {
1414                 contributor.location(childName, new InputLocation(line, column, source, locations));
1415             }
1416         }
1417         return contributor.build();
1418     }
1419 
1420     private Dependency parseDependency(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1421         String tagName = parser.getLocalName();
1422         Dependency.Builder dependency = Dependency.newBuilder(true);
1423         if (addLocationInformation) {
1424             dependency.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1425         }
1426         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1427             String name = parser.getAttributeLocalName(i);
1428             String ns = parser.getAttributeNamespace(i);
1429             String value = parser.getAttributeValue(i);
1430             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1431                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1432             } else {
1433                 checkUnknownAttribute(parser, name, tagName, strict);
1434             }
1435         }
1436         Set<String> parsed = new HashSet<>();
1437         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1438             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1439             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1440             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1441             Map<Object, InputLocation> locations = null;
1442             switch (childName) {
1443                 case "groupId": {
1444                     dependency.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1445                     break;
1446                 }
1447                 case "artifactId": {
1448                     dependency.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1449                     break;
1450                 }
1451                 case "version": {
1452                     dependency.version(interpolatedTrimmed(nextText(parser, strict), "version"));
1453                     break;
1454                 }
1455                 case "type": {
1456                     dependency.type(interpolatedTrimmed(nextText(parser, strict), "type"));
1457                     break;
1458                 }
1459                 case "classifier": {
1460                     dependency.classifier(interpolatedTrimmed(nextText(parser, strict), "classifier"));
1461                     break;
1462                 }
1463                 case "scope": {
1464                     dependency.scope(interpolatedTrimmed(nextText(parser, strict), "scope"));
1465                     break;
1466                 }
1467                 case "systemPath": {
1468                     dependency.systemPath(interpolatedTrimmed(nextText(parser, strict), "systemPath"));
1469                     break;
1470                 }
1471                 case "exclusions": {
1472                     List<Exclusion> exclusions = new ArrayList<>();
1473                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1474                         if ("exclusion".equals(parser.getLocalName())) {
1475                             exclusions.add(parseExclusion(parser, strict, source));
1476                         } else {
1477                             checkUnknownElement(parser, strict);
1478                         }
1479                     }
1480                     dependency.exclusions(exclusions);
1481                     break;
1482                 }
1483                 case "optional": {
1484                     dependency.optional(interpolatedTrimmed(nextText(parser, strict), "optional"));
1485                     break;
1486                 }
1487                 default: {
1488                     checkUnknownElement(parser, strict);
1489                     break;
1490                 }
1491             }
1492             if (addLocationInformation) {
1493                 dependency.location(childName, new InputLocation(line, column, source, locations));
1494             }
1495         }
1496         return dependency.build();
1497     }
1498 
1499     private Developer parseDeveloper(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1500         String tagName = parser.getLocalName();
1501         Developer.Builder developer = Developer.newBuilder(true);
1502         if (addLocationInformation) {
1503             developer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1504         }
1505         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1506             String name = parser.getAttributeLocalName(i);
1507             String ns = parser.getAttributeNamespace(i);
1508             String value = parser.getAttributeValue(i);
1509             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1510                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1511             } else {
1512                 checkUnknownAttribute(parser, name, tagName, strict);
1513             }
1514         }
1515         Set<String> parsed = new HashSet<>();
1516         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1517             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1518             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1519             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1520             Map<Object, InputLocation> locations = null;
1521             switch (childName) {
1522                 case "id": {
1523                     developer.id(interpolatedTrimmed(nextText(parser, strict), "id"));
1524                     break;
1525                 }
1526                 case "name": {
1527                     developer.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1528                     break;
1529                 }
1530                 case "email": {
1531                     developer.email(interpolatedTrimmed(nextText(parser, strict), "email"));
1532                     break;
1533                 }
1534                 case "url": {
1535                     developer.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1536                     break;
1537                 }
1538                 case "organization": {
1539                     developer.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
1540                     break;
1541                 }
1542                 case "organizationUrl": {
1543                     developer.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
1544                     break;
1545                 }
1546                 case "roles": {
1547                     List<String> roles = new ArrayList<>();
1548                     locations = new HashMap<>();
1549                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1550                         if ("role".equals(parser.getLocalName())) {
1551                             if (addLocationInformation) {
1552                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1553                             }
1554                             roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
1555                         } else {
1556                             checkUnknownElement(parser, strict);
1557                         }
1558                     }
1559                     developer.roles(roles);
1560                     break;
1561                 }
1562                 case "timezone": {
1563                     developer.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
1564                     break;
1565                 }
1566                 case "properties": {
1567                     Map<String, String> properties = new LinkedHashMap<>();
1568                     locations = new HashMap<>();
1569                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1570                         String key = parser.getLocalName();
1571                         String value = nextText(parser, strict).trim();
1572                         if (addLocationInformation) {
1573                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1574                         }
1575                         properties.put(key, value);
1576                     }
1577                     developer.properties(properties);
1578                     break;
1579                 }
1580                 default: {
1581                     checkUnknownElement(parser, strict);
1582                     break;
1583                 }
1584             }
1585             if (addLocationInformation) {
1586                 developer.location(childName, new InputLocation(line, column, source, locations));
1587             }
1588         }
1589         return developer.build();
1590     }
1591 
1592     private Exclusion parseExclusion(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1593         String tagName = parser.getLocalName();
1594         Exclusion.Builder exclusion = Exclusion.newBuilder(true);
1595         if (addLocationInformation) {
1596             exclusion.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1597         }
1598         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1599             String name = parser.getAttributeLocalName(i);
1600             String ns = parser.getAttributeNamespace(i);
1601             String value = parser.getAttributeValue(i);
1602             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1603                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1604             } else {
1605                 checkUnknownAttribute(parser, name, tagName, strict);
1606             }
1607         }
1608         Set<String> parsed = new HashSet<>();
1609         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1610             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1611             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1612             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1613             Map<Object, InputLocation> locations = null;
1614             switch (childName) {
1615                 case "groupId": {
1616                     exclusion.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1617                     break;
1618                 }
1619                 case "artifactId": {
1620                     exclusion.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1621                     break;
1622                 }
1623                 default: {
1624                     checkUnknownElement(parser, strict);
1625                     break;
1626                 }
1627             }
1628             if (addLocationInformation) {
1629                 exclusion.location(childName, new InputLocation(line, column, source, locations));
1630             }
1631         }
1632         return exclusion.build();
1633     }
1634 
1635     private IssueManagement parseIssueManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1636         String tagName = parser.getLocalName();
1637         IssueManagement.Builder issueManagement = IssueManagement.newBuilder(true);
1638         if (addLocationInformation) {
1639             issueManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1640         }
1641         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1642             String name = parser.getAttributeLocalName(i);
1643             String ns = parser.getAttributeNamespace(i);
1644             String value = parser.getAttributeValue(i);
1645             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1646                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1647             } else {
1648                 checkUnknownAttribute(parser, name, tagName, strict);
1649             }
1650         }
1651         Set<String> parsed = new HashSet<>();
1652         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1653             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1654             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1655             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1656             Map<Object, InputLocation> locations = null;
1657             switch (childName) {
1658                 case "system": {
1659                     issueManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
1660                     break;
1661                 }
1662                 case "url": {
1663                     issueManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1664                     break;
1665                 }
1666                 default: {
1667                     checkUnknownElement(parser, strict);
1668                     break;
1669                 }
1670             }
1671             if (addLocationInformation) {
1672                 issueManagement.location(childName, new InputLocation(line, column, source, locations));
1673             }
1674         }
1675         return issueManagement.build();
1676     }
1677 
1678     private DistributionManagement parseDistributionManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1679         String tagName = parser.getLocalName();
1680         DistributionManagement.Builder distributionManagement = DistributionManagement.newBuilder(true);
1681         if (addLocationInformation) {
1682             distributionManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1683         }
1684         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1685             String name = parser.getAttributeLocalName(i);
1686             String ns = parser.getAttributeNamespace(i);
1687             String value = parser.getAttributeValue(i);
1688             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1689                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1690             } else {
1691                 checkUnknownAttribute(parser, name, tagName, strict);
1692             }
1693         }
1694         Set<String> parsed = new HashSet<>();
1695         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1696             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1697             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1698             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1699             Map<Object, InputLocation> locations = null;
1700             switch (childName) {
1701                 case "repository": {
1702                     distributionManagement.repository(parseDeploymentRepository(parser, strict, source));
1703                     break;
1704                 }
1705                 case "snapshotRepository": {
1706                     distributionManagement.snapshotRepository(parseDeploymentRepository(parser, strict, source));
1707                     break;
1708                 }
1709                 case "site": {
1710                     distributionManagement.site(parseSite(parser, strict, source));
1711                     break;
1712                 }
1713                 case "downloadUrl": {
1714                     distributionManagement.downloadUrl(interpolatedTrimmed(nextText(parser, strict), "downloadUrl"));
1715                     break;
1716                 }
1717                 case "relocation": {
1718                     distributionManagement.relocation(parseRelocation(parser, strict, source));
1719                     break;
1720                 }
1721                 case "status": {
1722                     distributionManagement.status(interpolatedTrimmed(nextText(parser, strict), "status"));
1723                     break;
1724                 }
1725                 default: {
1726                     checkUnknownElement(parser, strict);
1727                     break;
1728                 }
1729             }
1730             if (addLocationInformation) {
1731                 distributionManagement.location(childName, new InputLocation(line, column, source, locations));
1732             }
1733         }
1734         return distributionManagement.build();
1735     }
1736 
1737     private License parseLicense(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1738         String tagName = parser.getLocalName();
1739         License.Builder license = License.newBuilder(true);
1740         if (addLocationInformation) {
1741             license.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1742         }
1743         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1744             String name = parser.getAttributeLocalName(i);
1745             String ns = parser.getAttributeNamespace(i);
1746             String value = parser.getAttributeValue(i);
1747             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1748                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1749             } else {
1750                 checkUnknownAttribute(parser, name, tagName, strict);
1751             }
1752         }
1753         Set<String> parsed = new HashSet<>();
1754         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1755             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1756             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1757             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1758             Map<Object, InputLocation> locations = null;
1759             switch (childName) {
1760                 case "name": {
1761                     license.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1762                     break;
1763                 }
1764                 case "url": {
1765                     license.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1766                     break;
1767                 }
1768                 case "distribution": {
1769                     license.distribution(interpolatedTrimmed(nextText(parser, strict), "distribution"));
1770                     break;
1771                 }
1772                 case "comments": {
1773                     license.comments(interpolatedTrimmed(nextText(parser, strict), "comments"));
1774                     break;
1775                 }
1776                 default: {
1777                     checkUnknownElement(parser, strict);
1778                     break;
1779                 }
1780             }
1781             if (addLocationInformation) {
1782                 license.location(childName, new InputLocation(line, column, source, locations));
1783             }
1784         }
1785         return license.build();
1786     }
1787 
1788     private MailingList parseMailingList(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1789         String tagName = parser.getLocalName();
1790         MailingList.Builder mailingList = MailingList.newBuilder(true);
1791         if (addLocationInformation) {
1792             mailingList.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1793         }
1794         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1795             String name = parser.getAttributeLocalName(i);
1796             String ns = parser.getAttributeNamespace(i);
1797             String value = parser.getAttributeValue(i);
1798             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1799                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1800             } else {
1801                 checkUnknownAttribute(parser, name, tagName, strict);
1802             }
1803         }
1804         Set<String> parsed = new HashSet<>();
1805         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1806             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1807             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1808             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1809             Map<Object, InputLocation> locations = null;
1810             switch (childName) {
1811                 case "name": {
1812                     mailingList.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1813                     break;
1814                 }
1815                 case "subscribe": {
1816                     mailingList.subscribe(interpolatedTrimmed(nextText(parser, strict), "subscribe"));
1817                     break;
1818                 }
1819                 case "unsubscribe": {
1820                     mailingList.unsubscribe(interpolatedTrimmed(nextText(parser, strict), "unsubscribe"));
1821                     break;
1822                 }
1823                 case "post": {
1824                     mailingList.post(interpolatedTrimmed(nextText(parser, strict), "post"));
1825                     break;
1826                 }
1827                 case "archive": {
1828                     mailingList.archive(interpolatedTrimmed(nextText(parser, strict), "archive"));
1829                     break;
1830                 }
1831                 case "otherArchives": {
1832                     List<String> otherArchives = new ArrayList<>();
1833                     locations = new HashMap<>();
1834                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1835                         if ("otherArchive".equals(parser.getLocalName())) {
1836                             if (addLocationInformation) {
1837                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1838                             }
1839                             otherArchives.add(interpolatedTrimmed(nextText(parser, strict), "otherArchives"));
1840                         } else {
1841                             checkUnknownElement(parser, strict);
1842                         }
1843                     }
1844                     mailingList.otherArchives(otherArchives);
1845                     break;
1846                 }
1847                 default: {
1848                     checkUnknownElement(parser, strict);
1849                     break;
1850                 }
1851             }
1852             if (addLocationInformation) {
1853                 mailingList.location(childName, new InputLocation(line, column, source, locations));
1854             }
1855         }
1856         return mailingList.build();
1857     }
1858 
1859     private Organization parseOrganization(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1860         String tagName = parser.getLocalName();
1861         Organization.Builder organization = Organization.newBuilder(true);
1862         if (addLocationInformation) {
1863             organization.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1864         }
1865         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1866             String name = parser.getAttributeLocalName(i);
1867             String ns = parser.getAttributeNamespace(i);
1868             String value = parser.getAttributeValue(i);
1869             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1870                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1871             } else {
1872                 checkUnknownAttribute(parser, name, tagName, strict);
1873             }
1874         }
1875         Set<String> parsed = new HashSet<>();
1876         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1877             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1878             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1879             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1880             Map<Object, InputLocation> locations = null;
1881             switch (childName) {
1882                 case "name": {
1883                     organization.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1884                     break;
1885                 }
1886                 case "url": {
1887                     organization.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1888                     break;
1889                 }
1890                 default: {
1891                     checkUnknownElement(parser, strict);
1892                     break;
1893                 }
1894             }
1895             if (addLocationInformation) {
1896                 organization.location(childName, new InputLocation(line, column, source, locations));
1897             }
1898         }
1899         return organization.build();
1900     }
1901 
1902     private PatternSet parsePatternSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1903         String tagName = parser.getLocalName();
1904         PatternSet.Builder patternSet = PatternSet.newBuilder(true);
1905         if (addLocationInformation) {
1906             patternSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1907         }
1908         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1909             String name = parser.getAttributeLocalName(i);
1910             String ns = parser.getAttributeNamespace(i);
1911             String value = parser.getAttributeValue(i);
1912             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1913                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1914             } else {
1915                 checkUnknownAttribute(parser, name, tagName, strict);
1916             }
1917         }
1918         Set<String> parsed = new HashSet<>();
1919         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1920             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1921             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1922             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1923             Map<Object, InputLocation> locations = null;
1924             switch (childName) {
1925                 case "includes": {
1926                     List<String> includes = new ArrayList<>();
1927                     locations = new HashMap<>();
1928                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1929                         if ("include".equals(parser.getLocalName())) {
1930                             if (addLocationInformation) {
1931                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1932                             }
1933                             includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
1934                         } else {
1935                             checkUnknownElement(parser, strict);
1936                         }
1937                     }
1938                     patternSet.includes(includes);
1939                     break;
1940                 }
1941                 case "excludes": {
1942                     List<String> excludes = new ArrayList<>();
1943                     locations = new HashMap<>();
1944                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1945                         if ("exclude".equals(parser.getLocalName())) {
1946                             if (addLocationInformation) {
1947                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1948                             }
1949                             excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
1950                         } else {
1951                             checkUnknownElement(parser, strict);
1952                         }
1953                     }
1954                     patternSet.excludes(excludes);
1955                     break;
1956                 }
1957                 default: {
1958                     checkUnknownElement(parser, strict);
1959                     break;
1960                 }
1961             }
1962             if (addLocationInformation) {
1963                 patternSet.location(childName, new InputLocation(line, column, source, locations));
1964             }
1965         }
1966         return patternSet.build();
1967     }
1968 
1969     private Parent parseParent(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1970         String tagName = parser.getLocalName();
1971         Parent.Builder parent = Parent.newBuilder(true);
1972         if (addLocationInformation) {
1973             parent.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1974         }
1975         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1976             String name = parser.getAttributeLocalName(i);
1977             String ns = parser.getAttributeNamespace(i);
1978             String value = parser.getAttributeValue(i);
1979             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1980                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1981             } else {
1982                 checkUnknownAttribute(parser, name, tagName, strict);
1983             }
1984         }
1985         Set<String> parsed = new HashSet<>();
1986         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1987             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1988             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1989             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1990             Map<Object, InputLocation> locations = null;
1991             switch (childName) {
1992                 case "groupId": {
1993                     parent.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1994                     break;
1995                 }
1996                 case "artifactId": {
1997                     parent.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1998                     break;
1999                 }
2000                 case "version": {
2001                     parent.version(interpolatedTrimmed(nextText(parser, strict), "version"));
2002                     break;
2003                 }
2004                 case "relativePath": {
2005                     parent.relativePath(interpolatedTrimmed(nextText(parser, strict), "relativePath"));
2006                     break;
2007                 }
2008                 default: {
2009                     checkUnknownElement(parser, strict);
2010                     break;
2011                 }
2012             }
2013             if (addLocationInformation) {
2014                 parent.location(childName, new InputLocation(line, column, source, locations));
2015             }
2016         }
2017         return parent.build();
2018     }
2019 
2020     private Scm parseScm(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2021         String tagName = parser.getLocalName();
2022         Scm.Builder scm = Scm.newBuilder(true);
2023         if (addLocationInformation) {
2024             scm.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2025         }
2026         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2027             String name = parser.getAttributeLocalName(i);
2028             String ns = parser.getAttributeNamespace(i);
2029             String value = parser.getAttributeValue(i);
2030             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2031                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2032             } else if ("child.scm.connection.inherit.append.path".equals(name)) {
2033                 if (addLocationInformation) {
2034                     scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2035                 }
2036                 scm.childScmConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.connection.inherit.append.path"));
2037             } else if ("child.scm.developerConnection.inherit.append.path".equals(name)) {
2038                 if (addLocationInformation) {
2039                     scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2040                 }
2041                 scm.childScmDeveloperConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.developerConnection.inherit.append.path"));
2042             } else if ("child.scm.url.inherit.append.path".equals(name)) {
2043                 if (addLocationInformation) {
2044                     scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2045                 }
2046                 scm.childScmUrlInheritAppendPath(interpolatedTrimmed(value, "child.scm.url.inherit.append.path"));
2047             } else {
2048                 checkUnknownAttribute(parser, name, tagName, strict);
2049             }
2050         }
2051         Set<String> parsed = new HashSet<>();
2052         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2053             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2054             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2055             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2056             Map<Object, InputLocation> locations = null;
2057             switch (childName) {
2058                 case "connection": {
2059                     scm.connection(interpolatedTrimmed(nextText(parser, strict), "connection"));
2060                     break;
2061                 }
2062                 case "developerConnection": {
2063                     scm.developerConnection(interpolatedTrimmed(nextText(parser, strict), "developerConnection"));
2064                     break;
2065                 }
2066                 case "tag": {
2067                     scm.tag(interpolatedTrimmed(nextText(parser, strict), "tag"));
2068                     break;
2069                 }
2070                 case "url": {
2071                     scm.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2072                     break;
2073                 }
2074                 default: {
2075                     checkUnknownElement(parser, strict);
2076                     break;
2077                 }
2078             }
2079             if (addLocationInformation) {
2080                 scm.location(childName, new InputLocation(line, column, source, locations));
2081             }
2082         }
2083         return scm.build();
2084     }
2085 
2086     private FileSet parseFileSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2087         String tagName = parser.getLocalName();
2088         FileSet.Builder fileSet = FileSet.newBuilder(true);
2089         if (addLocationInformation) {
2090             fileSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2091         }
2092         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2093             String name = parser.getAttributeLocalName(i);
2094             String ns = parser.getAttributeNamespace(i);
2095             String value = parser.getAttributeValue(i);
2096             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2097                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2098             } else {
2099                 checkUnknownAttribute(parser, name, tagName, strict);
2100             }
2101         }
2102         Set<String> parsed = new HashSet<>();
2103         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2104             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2105             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2106             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2107             Map<Object, InputLocation> locations = null;
2108             switch (childName) {
2109                 case "directory": {
2110                     fileSet.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
2111                     break;
2112                 }
2113                 case "includes": {
2114                     List<String> includes = new ArrayList<>();
2115                     locations = new HashMap<>();
2116                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2117                         if ("include".equals(parser.getLocalName())) {
2118                             if (addLocationInformation) {
2119                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2120                             }
2121                             includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
2122                         } else {
2123                             checkUnknownElement(parser, strict);
2124                         }
2125                     }
2126                     fileSet.includes(includes);
2127                     break;
2128                 }
2129                 case "excludes": {
2130                     List<String> excludes = new ArrayList<>();
2131                     locations = new HashMap<>();
2132                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2133                         if ("exclude".equals(parser.getLocalName())) {
2134                             if (addLocationInformation) {
2135                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2136                             }
2137                             excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
2138                         } else {
2139                             checkUnknownElement(parser, strict);
2140                         }
2141                     }
2142                     fileSet.excludes(excludes);
2143                     break;
2144                 }
2145                 default: {
2146                     checkUnknownElement(parser, strict);
2147                     break;
2148                 }
2149             }
2150             if (addLocationInformation) {
2151                 fileSet.location(childName, new InputLocation(line, column, source, locations));
2152             }
2153         }
2154         return fileSet.build();
2155     }
2156 
2157     private Resource parseResource(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2158         String tagName = parser.getLocalName();
2159         Resource.Builder resource = Resource.newBuilder(true);
2160         if (addLocationInformation) {
2161             resource.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2162         }
2163         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2164             String name = parser.getAttributeLocalName(i);
2165             String ns = parser.getAttributeNamespace(i);
2166             String value = parser.getAttributeValue(i);
2167             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2168                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2169             } else {
2170                 checkUnknownAttribute(parser, name, tagName, strict);
2171             }
2172         }
2173         Set<String> parsed = new HashSet<>();
2174         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2175             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2176             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2177             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2178             Map<Object, InputLocation> locations = null;
2179             switch (childName) {
2180                 case "targetPath": {
2181                     resource.targetPath(interpolatedTrimmed(nextText(parser, strict), "targetPath"));
2182                     break;
2183                 }
2184                 case "filtering": {
2185                     resource.filtering(interpolatedTrimmed(nextText(parser, strict), "filtering"));
2186                     break;
2187                 }
2188                 case "directory": {
2189                     resource.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
2190                     break;
2191                 }
2192                 case "includes": {
2193                     List<String> includes = new ArrayList<>();
2194                     locations = new HashMap<>();
2195                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2196                         if ("include".equals(parser.getLocalName())) {
2197                             if (addLocationInformation) {
2198                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2199                             }
2200                             includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
2201                         } else {
2202                             checkUnknownElement(parser, strict);
2203                         }
2204                     }
2205                     resource.includes(includes);
2206                     break;
2207                 }
2208                 case "excludes": {
2209                     List<String> excludes = new ArrayList<>();
2210                     locations = new HashMap<>();
2211                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2212                         if ("exclude".equals(parser.getLocalName())) {
2213                             if (addLocationInformation) {
2214                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2215                             }
2216                             excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
2217                         } else {
2218                             checkUnknownElement(parser, strict);
2219                         }
2220                     }
2221                     resource.excludes(excludes);
2222                     break;
2223                 }
2224                 default: {
2225                     checkUnknownElement(parser, strict);
2226                     break;
2227                 }
2228             }
2229             if (addLocationInformation) {
2230                 resource.location(childName, new InputLocation(line, column, source, locations));
2231             }
2232         }
2233         return resource.build();
2234     }
2235 
2236     private RepositoryBase parseRepositoryBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2237         String tagName = parser.getLocalName();
2238         RepositoryBase.Builder repositoryBase = RepositoryBase.newBuilder(true);
2239         if (addLocationInformation) {
2240             repositoryBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2241         }
2242         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2243             String name = parser.getAttributeLocalName(i);
2244             String ns = parser.getAttributeNamespace(i);
2245             String value = parser.getAttributeValue(i);
2246             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2247                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2248             } else {
2249                 checkUnknownAttribute(parser, name, tagName, strict);
2250             }
2251         }
2252         Set<String> parsed = new HashSet<>();
2253         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2254             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2255             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2256             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2257             Map<Object, InputLocation> locations = null;
2258             switch (childName) {
2259                 case "id": {
2260                     repositoryBase.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2261                     break;
2262                 }
2263                 case "name": {
2264                     repositoryBase.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2265                     break;
2266                 }
2267                 case "url": {
2268                     repositoryBase.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2269                     break;
2270                 }
2271                 case "layout": {
2272                     repositoryBase.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2273                     break;
2274                 }
2275                 default: {
2276                     checkUnknownElement(parser, strict);
2277                     break;
2278                 }
2279             }
2280             if (addLocationInformation) {
2281                 repositoryBase.location(childName, new InputLocation(line, column, source, locations));
2282             }
2283         }
2284         return repositoryBase.build();
2285     }
2286 
2287     private Repository parseRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2288         String tagName = parser.getLocalName();
2289         Repository.Builder repository = Repository.newBuilder(true);
2290         if (addLocationInformation) {
2291             repository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2292         }
2293         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2294             String name = parser.getAttributeLocalName(i);
2295             String ns = parser.getAttributeNamespace(i);
2296             String value = parser.getAttributeValue(i);
2297             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2298                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2299             } else {
2300                 checkUnknownAttribute(parser, name, tagName, strict);
2301             }
2302         }
2303         Set<String> parsed = new HashSet<>();
2304         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2305             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2306             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2307             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2308             Map<Object, InputLocation> locations = null;
2309             switch (childName) {
2310                 case "releases": {
2311                     repository.releases(parseRepositoryPolicy(parser, strict, source));
2312                     break;
2313                 }
2314                 case "snapshots": {
2315                     repository.snapshots(parseRepositoryPolicy(parser, strict, source));
2316                     break;
2317                 }
2318                 case "id": {
2319                     repository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2320                     break;
2321                 }
2322                 case "name": {
2323                     repository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2324                     break;
2325                 }
2326                 case "url": {
2327                     repository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2328                     break;
2329                 }
2330                 case "layout": {
2331                     repository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2332                     break;
2333                 }
2334                 default: {
2335                     checkUnknownElement(parser, strict);
2336                     break;
2337                 }
2338             }
2339             if (addLocationInformation) {
2340                 repository.location(childName, new InputLocation(line, column, source, locations));
2341             }
2342         }
2343         return repository.build();
2344     }
2345 
2346     private DeploymentRepository parseDeploymentRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2347         String tagName = parser.getLocalName();
2348         DeploymentRepository.Builder deploymentRepository = DeploymentRepository.newBuilder(true);
2349         if (addLocationInformation) {
2350             deploymentRepository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2351         }
2352         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2353             String name = parser.getAttributeLocalName(i);
2354             String ns = parser.getAttributeNamespace(i);
2355             String value = parser.getAttributeValue(i);
2356             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2357                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2358             } else {
2359                 checkUnknownAttribute(parser, name, tagName, strict);
2360             }
2361         }
2362         Set<String> parsed = new HashSet<>();
2363         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2364             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2365             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2366             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2367             Map<Object, InputLocation> locations = null;
2368             switch (childName) {
2369                 case "uniqueVersion": {
2370                     deploymentRepository.uniqueVersion(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "uniqueVersion"), "uniqueVersion", parser, true));
2371                     break;
2372                 }
2373                 case "releases": {
2374                     deploymentRepository.releases(parseRepositoryPolicy(parser, strict, source));
2375                     break;
2376                 }
2377                 case "snapshots": {
2378                     deploymentRepository.snapshots(parseRepositoryPolicy(parser, strict, source));
2379                     break;
2380                 }
2381                 case "id": {
2382                     deploymentRepository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2383                     break;
2384                 }
2385                 case "name": {
2386                     deploymentRepository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2387                     break;
2388                 }
2389                 case "url": {
2390                     deploymentRepository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2391                     break;
2392                 }
2393                 case "layout": {
2394                     deploymentRepository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2395                     break;
2396                 }
2397                 default: {
2398                     checkUnknownElement(parser, strict);
2399                     break;
2400                 }
2401             }
2402             if (addLocationInformation) {
2403                 deploymentRepository.location(childName, new InputLocation(line, column, source, locations));
2404             }
2405         }
2406         return deploymentRepository.build();
2407     }
2408 
2409     private RepositoryPolicy parseRepositoryPolicy(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2410         String tagName = parser.getLocalName();
2411         RepositoryPolicy.Builder repositoryPolicy = RepositoryPolicy.newBuilder(true);
2412         if (addLocationInformation) {
2413             repositoryPolicy.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2414         }
2415         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2416             String name = parser.getAttributeLocalName(i);
2417             String ns = parser.getAttributeNamespace(i);
2418             String value = parser.getAttributeValue(i);
2419             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2420                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2421             } else {
2422                 checkUnknownAttribute(parser, name, tagName, strict);
2423             }
2424         }
2425         Set<String> parsed = new HashSet<>();
2426         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2427             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2428             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2429             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2430             Map<Object, InputLocation> locations = null;
2431             switch (childName) {
2432                 case "enabled": {
2433                     repositoryPolicy.enabled(interpolatedTrimmed(nextText(parser, strict), "enabled"));
2434                     break;
2435                 }
2436                 case "updatePolicy": {
2437                     repositoryPolicy.updatePolicy(interpolatedTrimmed(nextText(parser, strict), "updatePolicy"));
2438                     break;
2439                 }
2440                 case "checksumPolicy": {
2441                     repositoryPolicy.checksumPolicy(interpolatedTrimmed(nextText(parser, strict), "checksumPolicy"));
2442                     break;
2443                 }
2444                 default: {
2445                     checkUnknownElement(parser, strict);
2446                     break;
2447                 }
2448             }
2449             if (addLocationInformation) {
2450                 repositoryPolicy.location(childName, new InputLocation(line, column, source, locations));
2451             }
2452         }
2453         return repositoryPolicy.build();
2454     }
2455 
2456     private Site parseSite(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2457         String tagName = parser.getLocalName();
2458         Site.Builder site = Site.newBuilder(true);
2459         if (addLocationInformation) {
2460             site.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2461         }
2462         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2463             String name = parser.getAttributeLocalName(i);
2464             String ns = parser.getAttributeNamespace(i);
2465             String value = parser.getAttributeValue(i);
2466             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2467                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2468             } else if ("child.site.url.inherit.append.path".equals(name)) {
2469                 if (addLocationInformation) {
2470                     site.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2471                 }
2472                 site.childSiteUrlInheritAppendPath(interpolatedTrimmed(value, "child.site.url.inherit.append.path"));
2473             } else {
2474                 checkUnknownAttribute(parser, name, tagName, strict);
2475             }
2476         }
2477         Set<String> parsed = new HashSet<>();
2478         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2479             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2480             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2481             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2482             Map<Object, InputLocation> locations = null;
2483             switch (childName) {
2484                 case "id": {
2485                     site.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2486                     break;
2487                 }
2488                 case "name": {
2489                     site.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2490                     break;
2491                 }
2492                 case "url": {
2493                     site.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2494                     break;
2495                 }
2496                 default: {
2497                     checkUnknownElement(parser, strict);
2498                     break;
2499                 }
2500             }
2501             if (addLocationInformation) {
2502                 site.location(childName, new InputLocation(line, column, source, locations));
2503             }
2504         }
2505         return site.build();
2506     }
2507 
2508     private ConfigurationContainer parseConfigurationContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2509         String tagName = parser.getLocalName();
2510         ConfigurationContainer.Builder configurationContainer = ConfigurationContainer.newBuilder(true);
2511         if (addLocationInformation) {
2512             configurationContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2513         }
2514         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2515             String name = parser.getAttributeLocalName(i);
2516             String ns = parser.getAttributeNamespace(i);
2517             String value = parser.getAttributeValue(i);
2518             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2519                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2520             } else {
2521                 checkUnknownAttribute(parser, name, tagName, strict);
2522             }
2523         }
2524         Set<String> parsed = new HashSet<>();
2525         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2526             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2527             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2528             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2529             Map<Object, InputLocation> locations = null;
2530             switch (childName) {
2531                 case "inherited": {
2532                     configurationContainer.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2533                     break;
2534                 }
2535                 case "configuration": {
2536                     configurationContainer.configuration(buildXmlNode(parser, source));
2537                     break;
2538                 }
2539                 default: {
2540                     checkUnknownElement(parser, strict);
2541                     break;
2542                 }
2543             }
2544             if (addLocationInformation) {
2545                 configurationContainer.location(childName, new InputLocation(line, column, source, locations));
2546             }
2547         }
2548         return configurationContainer.build();
2549     }
2550 
2551     private Plugin parsePlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2552         String tagName = parser.getLocalName();
2553         Plugin.Builder plugin = Plugin.newBuilder(true);
2554         if (addLocationInformation) {
2555             plugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2556         }
2557         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2558             String name = parser.getAttributeLocalName(i);
2559             String ns = parser.getAttributeNamespace(i);
2560             String value = parser.getAttributeValue(i);
2561             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2562                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2563             } else {
2564                 checkUnknownAttribute(parser, name, tagName, strict);
2565             }
2566         }
2567         Set<String> parsed = new HashSet<>();
2568         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2569             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2570             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2571             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2572             Map<Object, InputLocation> locations = null;
2573             switch (childName) {
2574                 case "groupId": {
2575                     plugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
2576                     break;
2577                 }
2578                 case "artifactId": {
2579                     plugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
2580                     break;
2581                 }
2582                 case "version": {
2583                     plugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
2584                     break;
2585                 }
2586                 case "extensions": {
2587                     plugin.extensions(interpolatedTrimmed(nextText(parser, strict), "extensions"));
2588                     break;
2589                 }
2590                 case "executions": {
2591                     List<PluginExecution> executions = new ArrayList<>();
2592                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2593                         if ("execution".equals(parser.getLocalName())) {
2594                             executions.add(parsePluginExecution(parser, strict, source));
2595                         } else {
2596                             checkUnknownElement(parser, strict);
2597                         }
2598                     }
2599                     plugin.executions(executions);
2600                     break;
2601                 }
2602                 case "dependencies": {
2603                     List<Dependency> dependencies = new ArrayList<>();
2604                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2605                         if ("dependency".equals(parser.getLocalName())) {
2606                             dependencies.add(parseDependency(parser, strict, source));
2607                         } else {
2608                             checkUnknownElement(parser, strict);
2609                         }
2610                     }
2611                     plugin.dependencies(dependencies);
2612                     break;
2613                 }
2614                 case "inherited": {
2615                     plugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2616                     break;
2617                 }
2618                 case "configuration": {
2619                     plugin.configuration(buildXmlNode(parser, source));
2620                     break;
2621                 }
2622                 default: {
2623                     checkUnknownElement(parser, strict);
2624                     break;
2625                 }
2626             }
2627             if (addLocationInformation) {
2628                 plugin.location(childName, new InputLocation(line, column, source, locations));
2629             }
2630         }
2631         return plugin.build();
2632     }
2633 
2634     private PluginExecution parsePluginExecution(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2635         String tagName = parser.getLocalName();
2636         PluginExecution.Builder pluginExecution = PluginExecution.newBuilder(true);
2637         if (addLocationInformation) {
2638             pluginExecution.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2639         }
2640         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2641             String name = parser.getAttributeLocalName(i);
2642             String ns = parser.getAttributeNamespace(i);
2643             String value = parser.getAttributeValue(i);
2644             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2645                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2646             } else {
2647                 checkUnknownAttribute(parser, name, tagName, strict);
2648             }
2649         }
2650         Set<String> parsed = new HashSet<>();
2651         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2652             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2653             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2654             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2655             Map<Object, InputLocation> locations = null;
2656             switch (childName) {
2657                 case "id": {
2658                     pluginExecution.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2659                     break;
2660                 }
2661                 case "phase": {
2662                     pluginExecution.phase(interpolatedTrimmed(nextText(parser, strict), "phase"));
2663                     break;
2664                 }
2665                 case "priority": {
2666                     pluginExecution.priority(getIntegerValue(interpolatedTrimmed(nextText(parser, strict), "priority"), "priority", parser, strict, 0));
2667                     break;
2668                 }
2669                 case "goals": {
2670                     List<String> goals = new ArrayList<>();
2671                     locations = new HashMap<>();
2672                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2673                         if ("goal".equals(parser.getLocalName())) {
2674                             if (addLocationInformation) {
2675                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2676                             }
2677                             goals.add(interpolatedTrimmed(nextText(parser, strict), "goals"));
2678                         } else {
2679                             checkUnknownElement(parser, strict);
2680                         }
2681                     }
2682                     pluginExecution.goals(goals);
2683                     break;
2684                 }
2685                 case "inherited": {
2686                     pluginExecution.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2687                     break;
2688                 }
2689                 case "configuration": {
2690                     pluginExecution.configuration(buildXmlNode(parser, source));
2691                     break;
2692                 }
2693                 default: {
2694                     checkUnknownElement(parser, strict);
2695                     break;
2696                 }
2697             }
2698             if (addLocationInformation) {
2699                 pluginExecution.location(childName, new InputLocation(line, column, source, locations));
2700             }
2701         }
2702         return pluginExecution.build();
2703     }
2704 
2705     private DependencyManagement parseDependencyManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2706         String tagName = parser.getLocalName();
2707         DependencyManagement.Builder dependencyManagement = DependencyManagement.newBuilder(true);
2708         if (addLocationInformation) {
2709             dependencyManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2710         }
2711         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2712             String name = parser.getAttributeLocalName(i);
2713             String ns = parser.getAttributeNamespace(i);
2714             String value = parser.getAttributeValue(i);
2715             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2716                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2717             } else {
2718                 checkUnknownAttribute(parser, name, tagName, strict);
2719             }
2720         }
2721         Set<String> parsed = new HashSet<>();
2722         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2723             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2724             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2725             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2726             Map<Object, InputLocation> locations = null;
2727             switch (childName) {
2728                 case "dependencies": {
2729                     List<Dependency> dependencies = new ArrayList<>();
2730                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2731                         if ("dependency".equals(parser.getLocalName())) {
2732                             dependencies.add(parseDependency(parser, strict, source));
2733                         } else {
2734                             checkUnknownElement(parser, strict);
2735                         }
2736                     }
2737                     dependencyManagement.dependencies(dependencies);
2738                     break;
2739                 }
2740                 default: {
2741                     checkUnknownElement(parser, strict);
2742                     break;
2743                 }
2744             }
2745             if (addLocationInformation) {
2746                 dependencyManagement.location(childName, new InputLocation(line, column, source, locations));
2747             }
2748         }
2749         return dependencyManagement.build();
2750     }
2751 
2752     private PluginManagement parsePluginManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2753         String tagName = parser.getLocalName();
2754         PluginManagement.Builder pluginManagement = PluginManagement.newBuilder(true);
2755         if (addLocationInformation) {
2756             pluginManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2757         }
2758         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2759             String name = parser.getAttributeLocalName(i);
2760             String ns = parser.getAttributeNamespace(i);
2761             String value = parser.getAttributeValue(i);
2762             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2763                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2764             } else {
2765                 checkUnknownAttribute(parser, name, tagName, strict);
2766             }
2767         }
2768         Set<String> parsed = new HashSet<>();
2769         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2770             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2771             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2772             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2773             Map<Object, InputLocation> locations = null;
2774             switch (childName) {
2775                 case "plugins": {
2776                     List<Plugin> plugins = new ArrayList<>();
2777                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2778                         if ("plugin".equals(parser.getLocalName())) {
2779                             plugins.add(parsePlugin(parser, strict, source));
2780                         } else {
2781                             checkUnknownElement(parser, strict);
2782                         }
2783                     }
2784                     pluginManagement.plugins(plugins);
2785                     break;
2786                 }
2787                 default: {
2788                     checkUnknownElement(parser, strict);
2789                     break;
2790                 }
2791             }
2792             if (addLocationInformation) {
2793                 pluginManagement.location(childName, new InputLocation(line, column, source, locations));
2794             }
2795         }
2796         return pluginManagement.build();
2797     }
2798 
2799     private Reporting parseReporting(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2800         String tagName = parser.getLocalName();
2801         Reporting.Builder reporting = Reporting.newBuilder(true);
2802         if (addLocationInformation) {
2803             reporting.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2804         }
2805         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2806             String name = parser.getAttributeLocalName(i);
2807             String ns = parser.getAttributeNamespace(i);
2808             String value = parser.getAttributeValue(i);
2809             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2810                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2811             } else {
2812                 checkUnknownAttribute(parser, name, tagName, strict);
2813             }
2814         }
2815         Set<String> parsed = new HashSet<>();
2816         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2817             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2818             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2819             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2820             Map<Object, InputLocation> locations = null;
2821             switch (childName) {
2822                 case "excludeDefaults": {
2823                     reporting.excludeDefaults(interpolatedTrimmed(nextText(parser, strict), "excludeDefaults"));
2824                     break;
2825                 }
2826                 case "outputDirectory": {
2827                     reporting.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
2828                     break;
2829                 }
2830                 case "plugins": {
2831                     List<ReportPlugin> plugins = new ArrayList<>();
2832                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2833                         if ("plugin".equals(parser.getLocalName())) {
2834                             plugins.add(parseReportPlugin(parser, strict, source));
2835                         } else {
2836                             checkUnknownElement(parser, strict);
2837                         }
2838                     }
2839                     reporting.plugins(plugins);
2840                     break;
2841                 }
2842                 default: {
2843                     checkUnknownElement(parser, strict);
2844                     break;
2845                 }
2846             }
2847             if (addLocationInformation) {
2848                 reporting.location(childName, new InputLocation(line, column, source, locations));
2849             }
2850         }
2851         return reporting.build();
2852     }
2853 
2854     private Profile parseProfile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2855         String tagName = parser.getLocalName();
2856         Profile.Builder profile = Profile.newBuilder(true);
2857         if (addLocationInformation) {
2858             profile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2859         }
2860         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2861             String name = parser.getAttributeLocalName(i);
2862             String ns = parser.getAttributeNamespace(i);
2863             String value = parser.getAttributeValue(i);
2864             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2865                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2866             } else {
2867                 checkUnknownAttribute(parser, name, tagName, strict);
2868             }
2869         }
2870         Set<String> parsed = new HashSet<>();
2871         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2872             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2873             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2874             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2875             Map<Object, InputLocation> locations = null;
2876             switch (childName) {
2877                 case "id": {
2878                     profile.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2879                     break;
2880                 }
2881                 case "activation": {
2882                     profile.activation(parseActivation(parser, strict, source));
2883                     break;
2884                 }
2885                 case "build": {
2886                     profile.build(parseBuildBase(parser, strict, source));
2887                     break;
2888                 }
2889                 case "modules": {
2890                     List<String> modules = new ArrayList<>();
2891                     locations = new HashMap<>();
2892                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2893                         if ("module".equals(parser.getLocalName())) {
2894                             if (addLocationInformation) {
2895                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2896                             }
2897                             modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
2898                         } else {
2899                             checkUnknownElement(parser, strict);
2900                         }
2901                     }
2902                     profile.modules(modules);
2903                     break;
2904                 }
2905                 case "subprojects": {
2906                     List<String> subprojects = new ArrayList<>();
2907                     locations = new HashMap<>();
2908                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2909                         if ("subproject".equals(parser.getLocalName())) {
2910                             if (addLocationInformation) {
2911                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2912                             }
2913                             subprojects.add(interpolatedTrimmed(nextText(parser, strict), "subprojects"));
2914                         } else {
2915                             checkUnknownElement(parser, strict);
2916                         }
2917                     }
2918                     profile.subprojects(subprojects);
2919                     break;
2920                 }
2921                 case "distributionManagement": {
2922                     profile.distributionManagement(parseDistributionManagement(parser, strict, source));
2923                     break;
2924                 }
2925                 case "properties": {
2926                     Map<String, String> properties = new LinkedHashMap<>();
2927                     locations = new HashMap<>();
2928                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2929                         String key = parser.getLocalName();
2930                         String value = nextText(parser, strict).trim();
2931                         if (addLocationInformation) {
2932                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2933                         }
2934                         properties.put(key, value);
2935                     }
2936                     profile.properties(properties);
2937                     break;
2938                 }
2939                 case "dependencyManagement": {
2940                     profile.dependencyManagement(parseDependencyManagement(parser, strict, source));
2941                     break;
2942                 }
2943                 case "dependencies": {
2944                     List<Dependency> dependencies = new ArrayList<>();
2945                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2946                         if ("dependency".equals(parser.getLocalName())) {
2947                             dependencies.add(parseDependency(parser, strict, source));
2948                         } else {
2949                             checkUnknownElement(parser, strict);
2950                         }
2951                     }
2952                     profile.dependencies(dependencies);
2953                     break;
2954                 }
2955                 case "repositories": {
2956                     List<Repository> repositories = new ArrayList<>();
2957                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2958                         if ("repository".equals(parser.getLocalName())) {
2959                             repositories.add(parseRepository(parser, strict, source));
2960                         } else {
2961                             checkUnknownElement(parser, strict);
2962                         }
2963                     }
2964                     profile.repositories(repositories);
2965                     break;
2966                 }
2967                 case "pluginRepositories": {
2968                     List<Repository> pluginRepositories = new ArrayList<>();
2969                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2970                         if ("pluginRepository".equals(parser.getLocalName())) {
2971                             pluginRepositories.add(parseRepository(parser, strict, source));
2972                         } else {
2973                             checkUnknownElement(parser, strict);
2974                         }
2975                     }
2976                     profile.pluginRepositories(pluginRepositories);
2977                     break;
2978                 }
2979                 case "reporting": {
2980                     profile.reporting(parseReporting(parser, strict, source));
2981                     break;
2982                 }
2983                 default: {
2984                     checkUnknownElement(parser, strict);
2985                     break;
2986                 }
2987             }
2988             if (addLocationInformation) {
2989                 profile.location(childName, new InputLocation(line, column, source, locations));
2990             }
2991         }
2992         return profile.build();
2993     }
2994 
2995     private Activation parseActivation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2996         String tagName = parser.getLocalName();
2997         Activation.Builder activation = Activation.newBuilder(true);
2998         if (addLocationInformation) {
2999             activation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3000         }
3001         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3002             String name = parser.getAttributeLocalName(i);
3003             String ns = parser.getAttributeNamespace(i);
3004             String value = parser.getAttributeValue(i);
3005             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3006                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3007             } else {
3008                 checkUnknownAttribute(parser, name, tagName, strict);
3009             }
3010         }
3011         Set<String> parsed = new HashSet<>();
3012         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3013             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3014             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3015             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3016             Map<Object, InputLocation> locations = null;
3017             switch (childName) {
3018                 case "activeByDefault": {
3019                     activation.activeByDefault(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "activeByDefault"), "activeByDefault", parser, false));
3020                     break;
3021                 }
3022                 case "jdk": {
3023                     activation.jdk(interpolatedTrimmed(nextText(parser, strict), "jdk"));
3024                     break;
3025                 }
3026                 case "os": {
3027                     activation.os(parseActivationOS(parser, strict, source));
3028                     break;
3029                 }
3030                 case "property": {
3031                     activation.property(parseActivationProperty(parser, strict, source));
3032                     break;
3033                 }
3034                 case "file": {
3035                     activation.file(parseActivationFile(parser, strict, source));
3036                     break;
3037                 }
3038                 case "packaging": {
3039                     activation.packaging(interpolatedTrimmed(nextText(parser, strict), "packaging"));
3040                     break;
3041                 }
3042                 default: {
3043                     checkUnknownElement(parser, strict);
3044                     break;
3045                 }
3046             }
3047             if (addLocationInformation) {
3048                 activation.location(childName, new InputLocation(line, column, source, locations));
3049             }
3050         }
3051         return activation.build();
3052     }
3053 
3054     private ActivationProperty parseActivationProperty(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3055         String tagName = parser.getLocalName();
3056         ActivationProperty.Builder activationProperty = ActivationProperty.newBuilder(true);
3057         if (addLocationInformation) {
3058             activationProperty.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3059         }
3060         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3061             String name = parser.getAttributeLocalName(i);
3062             String ns = parser.getAttributeNamespace(i);
3063             String value = parser.getAttributeValue(i);
3064             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3065                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3066             } else {
3067                 checkUnknownAttribute(parser, name, tagName, strict);
3068             }
3069         }
3070         Set<String> parsed = new HashSet<>();
3071         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3072             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3073             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3074             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3075             Map<Object, InputLocation> locations = null;
3076             switch (childName) {
3077                 case "name": {
3078                     activationProperty.name(interpolatedTrimmed(nextText(parser, strict), "name"));
3079                     break;
3080                 }
3081                 case "value": {
3082                     activationProperty.value(interpolatedTrimmed(nextText(parser, strict), "value"));
3083                     break;
3084                 }
3085                 default: {
3086                     checkUnknownElement(parser, strict);
3087                     break;
3088                 }
3089             }
3090             if (addLocationInformation) {
3091                 activationProperty.location(childName, new InputLocation(line, column, source, locations));
3092             }
3093         }
3094         return activationProperty.build();
3095     }
3096 
3097     private ActivationOS parseActivationOS(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3098         String tagName = parser.getLocalName();
3099         ActivationOS.Builder activationOS = ActivationOS.newBuilder(true);
3100         if (addLocationInformation) {
3101             activationOS.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3102         }
3103         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3104             String name = parser.getAttributeLocalName(i);
3105             String ns = parser.getAttributeNamespace(i);
3106             String value = parser.getAttributeValue(i);
3107             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3108                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3109             } else {
3110                 checkUnknownAttribute(parser, name, tagName, strict);
3111             }
3112         }
3113         Set<String> parsed = new HashSet<>();
3114         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3115             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3116             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3117             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3118             Map<Object, InputLocation> locations = null;
3119             switch (childName) {
3120                 case "name": {
3121                     activationOS.name(interpolatedTrimmed(nextText(parser, strict), "name"));
3122                     break;
3123                 }
3124                 case "family": {
3125                     activationOS.family(interpolatedTrimmed(nextText(parser, strict), "family"));
3126                     break;
3127                 }
3128                 case "arch": {
3129                     activationOS.arch(interpolatedTrimmed(nextText(parser, strict), "arch"));
3130                     break;
3131                 }
3132                 case "version": {
3133                     activationOS.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3134                     break;
3135                 }
3136                 default: {
3137                     checkUnknownElement(parser, strict);
3138                     break;
3139                 }
3140             }
3141             if (addLocationInformation) {
3142                 activationOS.location(childName, new InputLocation(line, column, source, locations));
3143             }
3144         }
3145         return activationOS.build();
3146     }
3147 
3148     private ActivationFile parseActivationFile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3149         String tagName = parser.getLocalName();
3150         ActivationFile.Builder activationFile = ActivationFile.newBuilder(true);
3151         if (addLocationInformation) {
3152             activationFile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3153         }
3154         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3155             String name = parser.getAttributeLocalName(i);
3156             String ns = parser.getAttributeNamespace(i);
3157             String value = parser.getAttributeValue(i);
3158             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3159                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3160             } else {
3161                 checkUnknownAttribute(parser, name, tagName, strict);
3162             }
3163         }
3164         Set<String> parsed = new HashSet<>();
3165         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3166             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3167             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3168             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3169             Map<Object, InputLocation> locations = null;
3170             switch (childName) {
3171                 case "missing": {
3172                     activationFile.missing(interpolatedTrimmed(nextText(parser, strict), "missing"));
3173                     break;
3174                 }
3175                 case "exists": {
3176                     activationFile.exists(interpolatedTrimmed(nextText(parser, strict), "exists"));
3177                     break;
3178                 }
3179                 default: {
3180                     checkUnknownElement(parser, strict);
3181                     break;
3182                 }
3183             }
3184             if (addLocationInformation) {
3185                 activationFile.location(childName, new InputLocation(line, column, source, locations));
3186             }
3187         }
3188         return activationFile.build();
3189     }
3190 
3191     private ReportPlugin parseReportPlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3192         String tagName = parser.getLocalName();
3193         ReportPlugin.Builder reportPlugin = ReportPlugin.newBuilder(true);
3194         if (addLocationInformation) {
3195             reportPlugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3196         }
3197         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3198             String name = parser.getAttributeLocalName(i);
3199             String ns = parser.getAttributeNamespace(i);
3200             String value = parser.getAttributeValue(i);
3201             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3202                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3203             } else {
3204                 checkUnknownAttribute(parser, name, tagName, strict);
3205             }
3206         }
3207         Set<String> parsed = new HashSet<>();
3208         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3209             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3210             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3211             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3212             Map<Object, InputLocation> locations = null;
3213             switch (childName) {
3214                 case "groupId": {
3215                     reportPlugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3216                     break;
3217                 }
3218                 case "artifactId": {
3219                     reportPlugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3220                     break;
3221                 }
3222                 case "version": {
3223                     reportPlugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3224                     break;
3225                 }
3226                 case "reportSets": {
3227                     List<ReportSet> reportSets = new ArrayList<>();
3228                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
3229                         if ("reportSet".equals(parser.getLocalName())) {
3230                             reportSets.add(parseReportSet(parser, strict, source));
3231                         } else {
3232                             checkUnknownElement(parser, strict);
3233                         }
3234                     }
3235                     reportPlugin.reportSets(reportSets);
3236                     break;
3237                 }
3238                 case "inherited": {
3239                     reportPlugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
3240                     break;
3241                 }
3242                 case "configuration": {
3243                     reportPlugin.configuration(buildXmlNode(parser, source));
3244                     break;
3245                 }
3246                 default: {
3247                     checkUnknownElement(parser, strict);
3248                     break;
3249                 }
3250             }
3251             if (addLocationInformation) {
3252                 reportPlugin.location(childName, new InputLocation(line, column, source, locations));
3253             }
3254         }
3255         return reportPlugin.build();
3256     }
3257 
3258     private ReportSet parseReportSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3259         String tagName = parser.getLocalName();
3260         ReportSet.Builder reportSet = ReportSet.newBuilder(true);
3261         if (addLocationInformation) {
3262             reportSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3263         }
3264         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3265             String name = parser.getAttributeLocalName(i);
3266             String ns = parser.getAttributeNamespace(i);
3267             String value = parser.getAttributeValue(i);
3268             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3269                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3270             } else {
3271                 checkUnknownAttribute(parser, name, tagName, strict);
3272             }
3273         }
3274         Set<String> parsed = new HashSet<>();
3275         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3276             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3277             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3278             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3279             Map<Object, InputLocation> locations = null;
3280             switch (childName) {
3281                 case "id": {
3282                     reportSet.id(interpolatedTrimmed(nextText(parser, strict), "id"));
3283                     break;
3284                 }
3285                 case "reports": {
3286                     List<String> reports = new ArrayList<>();
3287                     locations = new HashMap<>();
3288                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
3289                         if ("report".equals(parser.getLocalName())) {
3290                             if (addLocationInformation) {
3291                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3292                             }
3293                             reports.add(interpolatedTrimmed(nextText(parser, strict), "reports"));
3294                         } else {
3295                             checkUnknownElement(parser, strict);
3296                         }
3297                     }
3298                     reportSet.reports(reports);
3299                     break;
3300                 }
3301                 case "inherited": {
3302                     reportSet.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
3303                     break;
3304                 }
3305                 case "configuration": {
3306                     reportSet.configuration(buildXmlNode(parser, source));
3307                     break;
3308                 }
3309                 default: {
3310                     checkUnknownElement(parser, strict);
3311                     break;
3312                 }
3313             }
3314             if (addLocationInformation) {
3315                 reportSet.location(childName, new InputLocation(line, column, source, locations));
3316             }
3317         }
3318         return reportSet.build();
3319     }
3320 
3321     private Prerequisites parsePrerequisites(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3322         String tagName = parser.getLocalName();
3323         Prerequisites.Builder prerequisites = Prerequisites.newBuilder(true);
3324         if (addLocationInformation) {
3325             prerequisites.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3326         }
3327         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3328             String name = parser.getAttributeLocalName(i);
3329             String ns = parser.getAttributeNamespace(i);
3330             String value = parser.getAttributeValue(i);
3331             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3332                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3333             } else {
3334                 checkUnknownAttribute(parser, name, tagName, strict);
3335             }
3336         }
3337         Set<String> parsed = new HashSet<>();
3338         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3339             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3340             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3341             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3342             Map<Object, InputLocation> locations = null;
3343             switch (childName) {
3344                 case "maven": {
3345                     prerequisites.maven(interpolatedTrimmed(nextText(parser, strict), "maven"));
3346                     break;
3347                 }
3348                 default: {
3349                     checkUnknownElement(parser, strict);
3350                     break;
3351                 }
3352             }
3353             if (addLocationInformation) {
3354                 prerequisites.location(childName, new InputLocation(line, column, source, locations));
3355             }
3356         }
3357         return prerequisites.build();
3358     }
3359 
3360     private Relocation parseRelocation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3361         String tagName = parser.getLocalName();
3362         Relocation.Builder relocation = Relocation.newBuilder(true);
3363         if (addLocationInformation) {
3364             relocation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3365         }
3366         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3367             String name = parser.getAttributeLocalName(i);
3368             String ns = parser.getAttributeNamespace(i);
3369             String value = parser.getAttributeValue(i);
3370             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3371                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3372             } else {
3373                 checkUnknownAttribute(parser, name, tagName, strict);
3374             }
3375         }
3376         Set<String> parsed = new HashSet<>();
3377         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3378             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3379             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3380             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3381             Map<Object, InputLocation> locations = null;
3382             switch (childName) {
3383                 case "groupId": {
3384                     relocation.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3385                     break;
3386                 }
3387                 case "artifactId": {
3388                     relocation.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3389                     break;
3390                 }
3391                 case "version": {
3392                     relocation.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3393                     break;
3394                 }
3395                 case "message": {
3396                     relocation.message(interpolatedTrimmed(nextText(parser, strict), "message"));
3397                     break;
3398                 }
3399                 default: {
3400                     checkUnknownElement(parser, strict);
3401                     break;
3402                 }
3403             }
3404             if (addLocationInformation) {
3405                 relocation.location(childName, new InputLocation(line, column, source, locations));
3406             }
3407         }
3408         return relocation.build();
3409     }
3410 
3411     private Extension parseExtension(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3412         String tagName = parser.getLocalName();
3413         Extension.Builder extension = Extension.newBuilder(true);
3414         if (addLocationInformation) {
3415             extension.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3416         }
3417         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3418             String name = parser.getAttributeLocalName(i);
3419             String ns = parser.getAttributeNamespace(i);
3420             String value = parser.getAttributeValue(i);
3421             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3422                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3423             } else {
3424                 checkUnknownAttribute(parser, name, tagName, strict);
3425             }
3426         }
3427         Set<String> parsed = new HashSet<>();
3428         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3429             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3430             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3431             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3432             Map<Object, InputLocation> locations = null;
3433             switch (childName) {
3434                 case "groupId": {
3435                     extension.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3436                     break;
3437                 }
3438                 case "artifactId": {
3439                     extension.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3440                     break;
3441                 }
3442                 case "version": {
3443                     extension.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3444                     break;
3445                 }
3446                 case "configuration": {
3447                     extension.configuration(buildXmlNode(parser, source));
3448                     break;
3449                 }
3450                 default: {
3451                     checkUnknownElement(parser, strict);
3452                     break;
3453                 }
3454             }
3455             if (addLocationInformation) {
3456                 extension.location(childName, new InputLocation(line, column, source, locations));
3457             }
3458         }
3459         return extension.build();
3460     }
3461 
3462 
3463     private String checkDuplicate(String tagName, XMLStreamReader parser, Set<String> parsed) throws XMLStreamException {
3464         switch (tagName) {
3465         case "organisation":
3466             tagName = "organization";
3467             break;
3468         case "organisationUrl":
3469             tagName = "organizationUrl";
3470             break;
3471         }
3472         if (!parsed.add(tagName)) {
3473             throw new XMLStreamException("Duplicated tag: '" + tagName + "'", parser.getLocation(), null);
3474         }
3475         return tagName;
3476     }
3477 
3478     /**
3479      * Method checkUnknownAttribute.
3480      *
3481      * @param parser a parser object.
3482      * @param strict a strict object.
3483      * @param tagName a tagName object.
3484      * @param attribute a attribute object.
3485      * @throws XMLStreamException XMLStreamException if
3486      * any.
3487      * @throws IOException IOException if any.
3488      */
3489     private void checkUnknownAttribute(XMLStreamReader parser, String attribute, String tagName, boolean strict) throws XMLStreamException {
3490         // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
3491         if (strict) {
3492             throw new XMLStreamException("Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser.getLocation(), null);
3493         }
3494     } //-- void checkUnknownAttribute(XMLStreamReader, String, String, boolean)
3495 
3496     /**
3497      * Method checkUnknownElement.
3498      *
3499      * @param parser a parser object.
3500      * @param strict a strict object.
3501      * @throws XMLStreamException XMLStreamException if
3502      * any.
3503      * @throws IOException IOException if any.
3504      */
3505     private void checkUnknownElement(XMLStreamReader parser, boolean strict) throws XMLStreamException {
3506         if (strict) {
3507             throw new XMLStreamException("Unrecognised tag: '" + parser.getName() + "'", parser.getLocation(), null);
3508         }
3509 
3510         for (int unrecognizedTagCount = 1; unrecognizedTagCount > 0;) {
3511             int eventType = nextTag(parser);
3512             if (eventType == XMLStreamReader.START_ELEMENT) {
3513                 unrecognizedTagCount++;
3514             } else if (eventType == XMLStreamReader.END_ELEMENT) {
3515                 unrecognizedTagCount--;
3516             }
3517         }
3518     } //-- void checkUnknownElement(XMLStreamReader, boolean)
3519 
3520     /**
3521      * Method getTrimmedValue.
3522      *
3523      * @param s a s object.
3524      * @return String
3525      */
3526     private String getTrimmedValue(String s) {
3527         if (s != null) {
3528             s = s.trim();
3529         }
3530         return s;
3531     } //-- String getTrimmedValue(String)
3532 
3533     /**
3534      * Method interpolatedTrimmed.
3535      *
3536      * @param value a value object.
3537      * @param context a context object.
3538      * @return String
3539      */
3540     private String interpolatedTrimmed(String value, String context) {
3541         return getTrimmedValue(contentTransformer.transform(value, context));
3542     } //-- String interpolatedTrimmed(String, String)
3543 
3544     /**
3545      * Method nextTag.
3546      *
3547      * @param parser a parser object.
3548      * @throws IOException IOException if any.
3549      * @throws XMLStreamException XMLStreamException if
3550      * any.
3551      * @return int
3552      */
3553     private int nextTag(XMLStreamReader parser) throws XMLStreamException {
3554         while (true) {
3555             int next = parser.next();
3556             switch (next) {
3557                 case XMLStreamReader.SPACE:
3558                 case XMLStreamReader.COMMENT:
3559                 case XMLStreamReader.PROCESSING_INSTRUCTION:
3560                 case XMLStreamReader.CDATA:
3561                 case XMLStreamReader.CHARACTERS:
3562                     continue;
3563                 case XMLStreamReader.START_ELEMENT:
3564                 case XMLStreamReader.END_ELEMENT:
3565                     return next;
3566             }
3567         }
3568     } //-- int nextTag(XMLStreamReader)
3569 
3570     private String nextText(XMLStreamReader parser, boolean strict) throws XMLStreamException {
3571         int eventType = parser.getEventType();
3572         if (eventType != XMLStreamReader.START_ELEMENT) {
3573             throw new XMLStreamException("parser must be on START_ELEMENT to read next text", parser.getLocation(), null);
3574         }
3575         eventType = parser.next();
3576         StringBuilder result = new StringBuilder();
3577         while (true) {
3578             if (eventType == XMLStreamReader.CHARACTERS || eventType == XMLStreamReader.CDATA) {
3579                 result.append(parser.getText());
3580             } else if (eventType == XMLStreamReader.ENTITY_REFERENCE) {
3581                 String val = null;
3582                 if (strict) {
3583                     throw new XMLStreamException("Entities are not supported in strict mode", parser.getLocation(), null);
3584                 } else if (addDefaultEntities) {
3585                     val = DEFAULT_ENTITIES.get(parser.getLocalName());
3586                 }
3587                 if (val != null) {
3588                     result.append(val);
3589                 } else {
3590                     result.append("&").append(parser.getLocalName()).append(";");
3591                 }
3592             } else if (eventType != XMLStreamReader.COMMENT) {
3593                 break;
3594             }
3595             eventType = parser.next();
3596         }
3597         if (eventType != XMLStreamReader.END_ELEMENT) {
3598             throw new XMLStreamException(
3599                 "TEXT must be immediately followed by END_ELEMENT and not " + eventType /*TODO: TYPES[eventType]*/, parser.getLocation(), null);
3600         }
3601         return result.toString();
3602     }
3603 
3604     private XmlNode buildXmlNode(XMLStreamReader parser, InputSource source) throws XMLStreamException {
3605         return XmlNodeStaxBuilder.build(parser,
3606                 addLocationInformation
3607                         ? p -> new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source)
3608                         : null);
3609     }
3610 
3611     /**
3612      * Method getBooleanValue.
3613      *
3614      * @param s a s object.
3615      * @param defaultValue a defaultValue object.
3616      * @param parser a parser object.
3617      * @param attribute a attribute object.
3618      * @throws XMLStreamException XMLStreamException if
3619      * any.
3620      * @return boolean
3621      */
3622     private boolean getBooleanValue(String s, String attribute, XMLStreamReader parser, boolean defaultValue) throws XMLStreamException {
3623         if (s != null && s.length() != 0) {
3624             return Boolean.valueOf(s).booleanValue();
3625         }
3626         return defaultValue;
3627     } //-- boolean getBooleanValue(String, String, XMLStreamReader, String)
3628 
3629     /**
3630      * Method getIntegerValue.
3631      *
3632      * @param s a s object.
3633      * @param strict a strict object.
3634      * @param parser a parser object.
3635      * @param attribute a attribute object.
3636      * @throws XMLStreamException XMLStreamException if
3637      * any.
3638      * @return int
3639      */
3640     private int getIntegerValue(String s, String attribute, XMLStreamReader parser, boolean strict, int defaultValue) throws XMLStreamException {
3641         if (s != null) {
3642             try {
3643                 return Integer.valueOf(s).intValue();
3644             } catch (NumberFormatException nfe) {
3645                 if (strict) {
3646                     throw new XMLStreamException("Unable to parse element '" + attribute + "', must be an integer", parser.getLocation(), nfe);
3647                 }
3648             }
3649         }
3650         return defaultValue;
3651     } //-- int getIntegerValue(String, String, XMLStreamReader, boolean)
3652 
3653     public static interface ContentTransformer {
3654         /**
3655          * Interpolate the value read from the xpp3 document
3656          * @param source The source value
3657          * @param fieldName A description of the field being interpolated. The implementation may use this to
3658          *                           log stuff.
3659          * @return The interpolated value.
3660          */
3661         String transform(String source, String fieldName);
3662     }
3663 
3664 }