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.XmlNodeBuilder;
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 = new com.ctc.wstx.stax.WstxInputFactory();
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 = new com.ctc.wstx.stax.WstxInputFactory();
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 "scm": {
619                     model.scm(parseScm(parser, strict, source));
620                     break;
621                 }
622                 case "issueManagement": {
623                     model.issueManagement(parseIssueManagement(parser, strict, source));
624                     break;
625                 }
626                 case "ciManagement": {
627                     model.ciManagement(parseCiManagement(parser, strict, source));
628                     break;
629                 }
630                 case "distributionManagement": {
631                     model.distributionManagement(parseDistributionManagement(parser, strict, source));
632                     break;
633                 }
634                 case "properties": {
635                     Map<String, String> properties = new LinkedHashMap<>();
636                     locations = new HashMap<>();
637                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
638                         String key = parser.getLocalName();
639                         String value = nextText(parser, strict).trim();
640                         if (addLocationInformation) {
641                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
642                         }
643                         properties.put(key, value);
644                     }
645                     model.properties(properties);
646                     break;
647                 }
648                 case "dependencyManagement": {
649                     model.dependencyManagement(parseDependencyManagement(parser, strict, source));
650                     break;
651                 }
652                 case "dependencies": {
653                     List<Dependency> dependencies = new ArrayList<>();
654                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
655                         if ("dependency".equals(parser.getLocalName())) {
656                             dependencies.add(parseDependency(parser, strict, source));
657                         } else {
658                             checkUnknownElement(parser, strict);
659                         }
660                     }
661                     model.dependencies(dependencies);
662                     break;
663                 }
664                 case "repositories": {
665                     List<Repository> repositories = new ArrayList<>();
666                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
667                         if ("repository".equals(parser.getLocalName())) {
668                             repositories.add(parseRepository(parser, strict, source));
669                         } else {
670                             checkUnknownElement(parser, strict);
671                         }
672                     }
673                     model.repositories(repositories);
674                     break;
675                 }
676                 case "pluginRepositories": {
677                     List<Repository> pluginRepositories = new ArrayList<>();
678                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
679                         if ("pluginRepository".equals(parser.getLocalName())) {
680                             pluginRepositories.add(parseRepository(parser, strict, source));
681                         } else {
682                             checkUnknownElement(parser, strict);
683                         }
684                     }
685                     model.pluginRepositories(pluginRepositories);
686                     break;
687                 }
688                 case "build": {
689                     model.build(parseBuild(parser, strict, source));
690                     break;
691                 }
692                 case "reporting": {
693                     model.reporting(parseReporting(parser, strict, source));
694                     break;
695                 }
696                 case "profiles": {
697                     List<Profile> profiles = new ArrayList<>();
698                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
699                         if ("profile".equals(parser.getLocalName())) {
700                             profiles.add(parseProfile(parser, strict, source));
701                         } else {
702                             checkUnknownElement(parser, strict);
703                         }
704                     }
705                     model.profiles(profiles);
706                     break;
707                 }
708                 default: {
709                     checkUnknownElement(parser, strict);
710                     break;
711                 }
712             }
713             if (addLocationInformation) {
714                 model.location(childName, new InputLocation(line, column, source, locations));
715             }
716         }
717         model.namespaceUri(parser.getNamespaceURI());
718         model.modelEncoding(parser.getEncoding());
719         return model.build();
720     }
721 
722     private ModelBase parseModelBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
723         String tagName = parser.getLocalName();
724         ModelBase.Builder modelBase = ModelBase.newBuilder(true);
725         if (addLocationInformation) {
726             modelBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
727         }
728         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
729             String name = parser.getAttributeLocalName(i);
730             String ns = parser.getAttributeNamespace(i);
731             String value = parser.getAttributeValue(i);
732             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
733                 // just ignore attributes with non-default namespace (for example: xsi and xml)
734             } else {
735                 checkUnknownAttribute(parser, name, tagName, strict);
736             }
737         }
738         Set<String> parsed = new HashSet<>();
739         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
740             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
741             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
742             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
743             Map<Object, InputLocation> locations = null;
744             switch (childName) {
745                 case "modules": {
746                     List<String> modules = new ArrayList<>();
747                     locations = new HashMap<>();
748                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
749                         if ("module".equals(parser.getLocalName())) {
750                             if (addLocationInformation) {
751                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
752                             }
753                             modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
754                         } else {
755                             checkUnknownElement(parser, strict);
756                         }
757                     }
758                     modelBase.modules(modules);
759                     break;
760                 }
761                 case "distributionManagement": {
762                     modelBase.distributionManagement(parseDistributionManagement(parser, strict, source));
763                     break;
764                 }
765                 case "properties": {
766                     Map<String, String> properties = new LinkedHashMap<>();
767                     locations = new HashMap<>();
768                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
769                         String key = parser.getLocalName();
770                         String value = nextText(parser, strict).trim();
771                         if (addLocationInformation) {
772                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
773                         }
774                         properties.put(key, value);
775                     }
776                     modelBase.properties(properties);
777                     break;
778                 }
779                 case "dependencyManagement": {
780                     modelBase.dependencyManagement(parseDependencyManagement(parser, strict, source));
781                     break;
782                 }
783                 case "dependencies": {
784                     List<Dependency> dependencies = new ArrayList<>();
785                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
786                         if ("dependency".equals(parser.getLocalName())) {
787                             dependencies.add(parseDependency(parser, strict, source));
788                         } else {
789                             checkUnknownElement(parser, strict);
790                         }
791                     }
792                     modelBase.dependencies(dependencies);
793                     break;
794                 }
795                 case "repositories": {
796                     List<Repository> repositories = new ArrayList<>();
797                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
798                         if ("repository".equals(parser.getLocalName())) {
799                             repositories.add(parseRepository(parser, strict, source));
800                         } else {
801                             checkUnknownElement(parser, strict);
802                         }
803                     }
804                     modelBase.repositories(repositories);
805                     break;
806                 }
807                 case "pluginRepositories": {
808                     List<Repository> pluginRepositories = new ArrayList<>();
809                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
810                         if ("pluginRepository".equals(parser.getLocalName())) {
811                             pluginRepositories.add(parseRepository(parser, strict, source));
812                         } else {
813                             checkUnknownElement(parser, strict);
814                         }
815                     }
816                     modelBase.pluginRepositories(pluginRepositories);
817                     break;
818                 }
819                 case "reporting": {
820                     modelBase.reporting(parseReporting(parser, strict, source));
821                     break;
822                 }
823                 default: {
824                     checkUnknownElement(parser, strict);
825                     break;
826                 }
827             }
828             if (addLocationInformation) {
829                 modelBase.location(childName, new InputLocation(line, column, source, locations));
830             }
831         }
832         return modelBase.build();
833     }
834 
835     private PluginContainer parsePluginContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
836         String tagName = parser.getLocalName();
837         PluginContainer.Builder pluginContainer = PluginContainer.newBuilder(true);
838         if (addLocationInformation) {
839             pluginContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
840         }
841         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
842             String name = parser.getAttributeLocalName(i);
843             String ns = parser.getAttributeNamespace(i);
844             String value = parser.getAttributeValue(i);
845             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
846                 // just ignore attributes with non-default namespace (for example: xsi and xml)
847             } else {
848                 checkUnknownAttribute(parser, name, tagName, strict);
849             }
850         }
851         Set<String> parsed = new HashSet<>();
852         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
853             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
854             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
855             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
856             Map<Object, InputLocation> locations = null;
857             switch (childName) {
858                 case "plugins": {
859                     List<Plugin> plugins = new ArrayList<>();
860                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
861                         if ("plugin".equals(parser.getLocalName())) {
862                             plugins.add(parsePlugin(parser, strict, source));
863                         } else {
864                             checkUnknownElement(parser, strict);
865                         }
866                     }
867                     pluginContainer.plugins(plugins);
868                     break;
869                 }
870                 default: {
871                     checkUnknownElement(parser, strict);
872                     break;
873                 }
874             }
875             if (addLocationInformation) {
876                 pluginContainer.location(childName, new InputLocation(line, column, source, locations));
877             }
878         }
879         return pluginContainer.build();
880     }
881 
882     private PluginConfiguration parsePluginConfiguration(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
883         String tagName = parser.getLocalName();
884         PluginConfiguration.Builder pluginConfiguration = PluginConfiguration.newBuilder(true);
885         if (addLocationInformation) {
886             pluginConfiguration.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
887         }
888         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
889             String name = parser.getAttributeLocalName(i);
890             String ns = parser.getAttributeNamespace(i);
891             String value = parser.getAttributeValue(i);
892             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
893                 // just ignore attributes with non-default namespace (for example: xsi and xml)
894             } else {
895                 checkUnknownAttribute(parser, name, tagName, strict);
896             }
897         }
898         Set<String> parsed = new HashSet<>();
899         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
900             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
901             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
902             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
903             Map<Object, InputLocation> locations = null;
904             switch (childName) {
905                 case "pluginManagement": {
906                     pluginConfiguration.pluginManagement(parsePluginManagement(parser, strict, source));
907                     break;
908                 }
909                 case "plugins": {
910                     List<Plugin> plugins = new ArrayList<>();
911                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
912                         if ("plugin".equals(parser.getLocalName())) {
913                             plugins.add(parsePlugin(parser, strict, source));
914                         } else {
915                             checkUnknownElement(parser, strict);
916                         }
917                     }
918                     pluginConfiguration.plugins(plugins);
919                     break;
920                 }
921                 default: {
922                     checkUnknownElement(parser, strict);
923                     break;
924                 }
925             }
926             if (addLocationInformation) {
927                 pluginConfiguration.location(childName, new InputLocation(line, column, source, locations));
928             }
929         }
930         return pluginConfiguration.build();
931     }
932 
933     private BuildBase parseBuildBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
934         String tagName = parser.getLocalName();
935         BuildBase.Builder buildBase = BuildBase.newBuilder(true);
936         if (addLocationInformation) {
937             buildBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
938         }
939         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
940             String name = parser.getAttributeLocalName(i);
941             String ns = parser.getAttributeNamespace(i);
942             String value = parser.getAttributeValue(i);
943             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
944                 // just ignore attributes with non-default namespace (for example: xsi and xml)
945             } else {
946                 checkUnknownAttribute(parser, name, tagName, strict);
947             }
948         }
949         Set<String> parsed = new HashSet<>();
950         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
951             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
952             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
953             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
954             Map<Object, InputLocation> locations = null;
955             switch (childName) {
956                 case "defaultGoal": {
957                     buildBase.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
958                     break;
959                 }
960                 case "resources": {
961                     List<Resource> resources = new ArrayList<>();
962                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
963                         if ("resource".equals(parser.getLocalName())) {
964                             resources.add(parseResource(parser, strict, source));
965                         } else {
966                             checkUnknownElement(parser, strict);
967                         }
968                     }
969                     buildBase.resources(resources);
970                     break;
971                 }
972                 case "testResources": {
973                     List<Resource> testResources = new ArrayList<>();
974                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
975                         if ("testResource".equals(parser.getLocalName())) {
976                             testResources.add(parseResource(parser, strict, source));
977                         } else {
978                             checkUnknownElement(parser, strict);
979                         }
980                     }
981                     buildBase.testResources(testResources);
982                     break;
983                 }
984                 case "directory": {
985                     buildBase.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
986                     break;
987                 }
988                 case "finalName": {
989                     buildBase.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
990                     break;
991                 }
992                 case "filters": {
993                     List<String> filters = new ArrayList<>();
994                     locations = new HashMap<>();
995                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
996                         if ("filter".equals(parser.getLocalName())) {
997                             if (addLocationInformation) {
998                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
999                             }
1000                             filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
1001                         } else {
1002                             checkUnknownElement(parser, strict);
1003                         }
1004                     }
1005                     buildBase.filters(filters);
1006                     break;
1007                 }
1008                 case "pluginManagement": {
1009                     buildBase.pluginManagement(parsePluginManagement(parser, strict, source));
1010                     break;
1011                 }
1012                 case "plugins": {
1013                     List<Plugin> plugins = new ArrayList<>();
1014                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1015                         if ("plugin".equals(parser.getLocalName())) {
1016                             plugins.add(parsePlugin(parser, strict, source));
1017                         } else {
1018                             checkUnknownElement(parser, strict);
1019                         }
1020                     }
1021                     buildBase.plugins(plugins);
1022                     break;
1023                 }
1024                 default: {
1025                     checkUnknownElement(parser, strict);
1026                     break;
1027                 }
1028             }
1029             if (addLocationInformation) {
1030                 buildBase.location(childName, new InputLocation(line, column, source, locations));
1031             }
1032         }
1033         return buildBase.build();
1034     }
1035 
1036     private Build parseBuild(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1037         String tagName = parser.getLocalName();
1038         Build.Builder build = Build.newBuilder(true);
1039         if (addLocationInformation) {
1040             build.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1041         }
1042         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1043             String name = parser.getAttributeLocalName(i);
1044             String ns = parser.getAttributeNamespace(i);
1045             String value = parser.getAttributeValue(i);
1046             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1047                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1048             } else {
1049                 checkUnknownAttribute(parser, name, tagName, strict);
1050             }
1051         }
1052         Set<String> parsed = new HashSet<>();
1053         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1054             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1055             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1056             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1057             Map<Object, InputLocation> locations = null;
1058             switch (childName) {
1059                 case "sourceDirectory": {
1060                     build.sourceDirectory(interpolatedTrimmed(nextText(parser, strict), "sourceDirectory"));
1061                     break;
1062                 }
1063                 case "scriptSourceDirectory": {
1064                     build.scriptSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "scriptSourceDirectory"));
1065                     break;
1066                 }
1067                 case "testSourceDirectory": {
1068                     build.testSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "testSourceDirectory"));
1069                     break;
1070                 }
1071                 case "outputDirectory": {
1072                     build.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
1073                     break;
1074                 }
1075                 case "testOutputDirectory": {
1076                     build.testOutputDirectory(interpolatedTrimmed(nextText(parser, strict), "testOutputDirectory"));
1077                     break;
1078                 }
1079                 case "extensions": {
1080                     List<Extension> extensions = new ArrayList<>();
1081                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1082                         if ("extension".equals(parser.getLocalName())) {
1083                             extensions.add(parseExtension(parser, strict, source));
1084                         } else {
1085                             checkUnknownElement(parser, strict);
1086                         }
1087                     }
1088                     build.extensions(extensions);
1089                     break;
1090                 }
1091                 case "defaultGoal": {
1092                     build.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
1093                     break;
1094                 }
1095                 case "resources": {
1096                     List<Resource> resources = new ArrayList<>();
1097                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1098                         if ("resource".equals(parser.getLocalName())) {
1099                             resources.add(parseResource(parser, strict, source));
1100                         } else {
1101                             checkUnknownElement(parser, strict);
1102                         }
1103                     }
1104                     build.resources(resources);
1105                     break;
1106                 }
1107                 case "testResources": {
1108                     List<Resource> testResources = new ArrayList<>();
1109                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1110                         if ("testResource".equals(parser.getLocalName())) {
1111                             testResources.add(parseResource(parser, strict, source));
1112                         } else {
1113                             checkUnknownElement(parser, strict);
1114                         }
1115                     }
1116                     build.testResources(testResources);
1117                     break;
1118                 }
1119                 case "directory": {
1120                     build.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
1121                     break;
1122                 }
1123                 case "finalName": {
1124                     build.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
1125                     break;
1126                 }
1127                 case "filters": {
1128                     List<String> filters = new ArrayList<>();
1129                     locations = new HashMap<>();
1130                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1131                         if ("filter".equals(parser.getLocalName())) {
1132                             if (addLocationInformation) {
1133                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1134                             }
1135                             filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
1136                         } else {
1137                             checkUnknownElement(parser, strict);
1138                         }
1139                     }
1140                     build.filters(filters);
1141                     break;
1142                 }
1143                 case "pluginManagement": {
1144                     build.pluginManagement(parsePluginManagement(parser, strict, source));
1145                     break;
1146                 }
1147                 case "plugins": {
1148                     List<Plugin> plugins = new ArrayList<>();
1149                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1150                         if ("plugin".equals(parser.getLocalName())) {
1151                             plugins.add(parsePlugin(parser, strict, source));
1152                         } else {
1153                             checkUnknownElement(parser, strict);
1154                         }
1155                     }
1156                     build.plugins(plugins);
1157                     break;
1158                 }
1159                 default: {
1160                     checkUnknownElement(parser, strict);
1161                     break;
1162                 }
1163             }
1164             if (addLocationInformation) {
1165                 build.location(childName, new InputLocation(line, column, source, locations));
1166             }
1167         }
1168         return build.build();
1169     }
1170 
1171     private CiManagement parseCiManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1172         String tagName = parser.getLocalName();
1173         CiManagement.Builder ciManagement = CiManagement.newBuilder(true);
1174         if (addLocationInformation) {
1175             ciManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1176         }
1177         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1178             String name = parser.getAttributeLocalName(i);
1179             String ns = parser.getAttributeNamespace(i);
1180             String value = parser.getAttributeValue(i);
1181             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1182                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1183             } else {
1184                 checkUnknownAttribute(parser, name, tagName, strict);
1185             }
1186         }
1187         Set<String> parsed = new HashSet<>();
1188         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1189             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1190             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1191             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1192             Map<Object, InputLocation> locations = null;
1193             switch (childName) {
1194                 case "system": {
1195                     ciManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
1196                     break;
1197                 }
1198                 case "url": {
1199                     ciManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1200                     break;
1201                 }
1202                 case "notifiers": {
1203                     List<Notifier> notifiers = new ArrayList<>();
1204                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1205                         if ("notifier".equals(parser.getLocalName())) {
1206                             notifiers.add(parseNotifier(parser, strict, source));
1207                         } else {
1208                             checkUnknownElement(parser, strict);
1209                         }
1210                     }
1211                     ciManagement.notifiers(notifiers);
1212                     break;
1213                 }
1214                 default: {
1215                     checkUnknownElement(parser, strict);
1216                     break;
1217                 }
1218             }
1219             if (addLocationInformation) {
1220                 ciManagement.location(childName, new InputLocation(line, column, source, locations));
1221             }
1222         }
1223         return ciManagement.build();
1224     }
1225 
1226     private Notifier parseNotifier(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1227         String tagName = parser.getLocalName();
1228         Notifier.Builder notifier = Notifier.newBuilder(true);
1229         if (addLocationInformation) {
1230             notifier.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1231         }
1232         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1233             String name = parser.getAttributeLocalName(i);
1234             String ns = parser.getAttributeNamespace(i);
1235             String value = parser.getAttributeValue(i);
1236             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1237                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1238             } else {
1239                 checkUnknownAttribute(parser, name, tagName, strict);
1240             }
1241         }
1242         Set<String> parsed = new HashSet<>();
1243         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1244             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1245             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1246             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1247             Map<Object, InputLocation> locations = null;
1248             switch (childName) {
1249                 case "type": {
1250                     notifier.type(interpolatedTrimmed(nextText(parser, strict), "type"));
1251                     break;
1252                 }
1253                 case "sendOnError": {
1254                     notifier.sendOnError(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnError"), "sendOnError", parser, true));
1255                     break;
1256                 }
1257                 case "sendOnFailure": {
1258                     notifier.sendOnFailure(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnFailure"), "sendOnFailure", parser, true));
1259                     break;
1260                 }
1261                 case "sendOnSuccess": {
1262                     notifier.sendOnSuccess(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnSuccess"), "sendOnSuccess", parser, true));
1263                     break;
1264                 }
1265                 case "sendOnWarning": {
1266                     notifier.sendOnWarning(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnWarning"), "sendOnWarning", parser, true));
1267                     break;
1268                 }
1269                 case "address": {
1270                     notifier.address(interpolatedTrimmed(nextText(parser, strict), "address"));
1271                     break;
1272                 }
1273                 case "configuration": {
1274                     Map<String, String> configuration = new LinkedHashMap<>();
1275                     locations = new HashMap<>();
1276                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1277                         String key = parser.getLocalName();
1278                         String value = nextText(parser, strict).trim();
1279                         if (addLocationInformation) {
1280                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1281                         }
1282                         configuration.put(key, value);
1283                     }
1284                     notifier.configuration(configuration);
1285                     break;
1286                 }
1287                 default: {
1288                     checkUnknownElement(parser, strict);
1289                     break;
1290                 }
1291             }
1292             if (addLocationInformation) {
1293                 notifier.location(childName, new InputLocation(line, column, source, locations));
1294             }
1295         }
1296         return notifier.build();
1297     }
1298 
1299     private Contributor parseContributor(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1300         String tagName = parser.getLocalName();
1301         Contributor.Builder contributor = Contributor.newBuilder(true);
1302         if (addLocationInformation) {
1303             contributor.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1304         }
1305         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1306             String name = parser.getAttributeLocalName(i);
1307             String ns = parser.getAttributeNamespace(i);
1308             String value = parser.getAttributeValue(i);
1309             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1310                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1311             } else {
1312                 checkUnknownAttribute(parser, name, tagName, strict);
1313             }
1314         }
1315         Set<String> parsed = new HashSet<>();
1316         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1317             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1318             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1319             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1320             Map<Object, InputLocation> locations = null;
1321             switch (childName) {
1322                 case "name": {
1323                     contributor.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1324                     break;
1325                 }
1326                 case "email": {
1327                     contributor.email(interpolatedTrimmed(nextText(parser, strict), "email"));
1328                     break;
1329                 }
1330                 case "url": {
1331                     contributor.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1332                     break;
1333                 }
1334                 case "organization": {
1335                     contributor.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
1336                     break;
1337                 }
1338                 case "organizationUrl": {
1339                     contributor.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
1340                     break;
1341                 }
1342                 case "roles": {
1343                     List<String> roles = new ArrayList<>();
1344                     locations = new HashMap<>();
1345                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1346                         if ("role".equals(parser.getLocalName())) {
1347                             if (addLocationInformation) {
1348                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1349                             }
1350                             roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
1351                         } else {
1352                             checkUnknownElement(parser, strict);
1353                         }
1354                     }
1355                     contributor.roles(roles);
1356                     break;
1357                 }
1358                 case "timezone": {
1359                     contributor.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
1360                     break;
1361                 }
1362                 case "properties": {
1363                     Map<String, String> properties = new LinkedHashMap<>();
1364                     locations = new HashMap<>();
1365                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1366                         String key = parser.getLocalName();
1367                         String value = nextText(parser, strict).trim();
1368                         if (addLocationInformation) {
1369                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1370                         }
1371                         properties.put(key, value);
1372                     }
1373                     contributor.properties(properties);
1374                     break;
1375                 }
1376                 default: {
1377                     checkUnknownElement(parser, strict);
1378                     break;
1379                 }
1380             }
1381             if (addLocationInformation) {
1382                 contributor.location(childName, new InputLocation(line, column, source, locations));
1383             }
1384         }
1385         return contributor.build();
1386     }
1387 
1388     private Dependency parseDependency(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1389         String tagName = parser.getLocalName();
1390         Dependency.Builder dependency = Dependency.newBuilder(true);
1391         if (addLocationInformation) {
1392             dependency.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1393         }
1394         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1395             String name = parser.getAttributeLocalName(i);
1396             String ns = parser.getAttributeNamespace(i);
1397             String value = parser.getAttributeValue(i);
1398             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1399                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1400             } else {
1401                 checkUnknownAttribute(parser, name, tagName, strict);
1402             }
1403         }
1404         Set<String> parsed = new HashSet<>();
1405         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1406             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1407             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1408             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1409             Map<Object, InputLocation> locations = null;
1410             switch (childName) {
1411                 case "groupId": {
1412                     dependency.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1413                     break;
1414                 }
1415                 case "artifactId": {
1416                     dependency.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1417                     break;
1418                 }
1419                 case "version": {
1420                     dependency.version(interpolatedTrimmed(nextText(parser, strict), "version"));
1421                     break;
1422                 }
1423                 case "type": {
1424                     dependency.type(interpolatedTrimmed(nextText(parser, strict), "type"));
1425                     break;
1426                 }
1427                 case "classifier": {
1428                     dependency.classifier(interpolatedTrimmed(nextText(parser, strict), "classifier"));
1429                     break;
1430                 }
1431                 case "scope": {
1432                     dependency.scope(interpolatedTrimmed(nextText(parser, strict), "scope"));
1433                     break;
1434                 }
1435                 case "systemPath": {
1436                     dependency.systemPath(interpolatedTrimmed(nextText(parser, strict), "systemPath"));
1437                     break;
1438                 }
1439                 case "exclusions": {
1440                     List<Exclusion> exclusions = new ArrayList<>();
1441                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1442                         if ("exclusion".equals(parser.getLocalName())) {
1443                             exclusions.add(parseExclusion(parser, strict, source));
1444                         } else {
1445                             checkUnknownElement(parser, strict);
1446                         }
1447                     }
1448                     dependency.exclusions(exclusions);
1449                     break;
1450                 }
1451                 case "optional": {
1452                     dependency.optional(interpolatedTrimmed(nextText(parser, strict), "optional"));
1453                     break;
1454                 }
1455                 default: {
1456                     checkUnknownElement(parser, strict);
1457                     break;
1458                 }
1459             }
1460             if (addLocationInformation) {
1461                 dependency.location(childName, new InputLocation(line, column, source, locations));
1462             }
1463         }
1464         return dependency.build();
1465     }
1466 
1467     private Developer parseDeveloper(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1468         String tagName = parser.getLocalName();
1469         Developer.Builder developer = Developer.newBuilder(true);
1470         if (addLocationInformation) {
1471             developer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1472         }
1473         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1474             String name = parser.getAttributeLocalName(i);
1475             String ns = parser.getAttributeNamespace(i);
1476             String value = parser.getAttributeValue(i);
1477             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1478                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1479             } else {
1480                 checkUnknownAttribute(parser, name, tagName, strict);
1481             }
1482         }
1483         Set<String> parsed = new HashSet<>();
1484         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1485             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1486             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1487             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1488             Map<Object, InputLocation> locations = null;
1489             switch (childName) {
1490                 case "id": {
1491                     developer.id(interpolatedTrimmed(nextText(parser, strict), "id"));
1492                     break;
1493                 }
1494                 case "name": {
1495                     developer.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1496                     break;
1497                 }
1498                 case "email": {
1499                     developer.email(interpolatedTrimmed(nextText(parser, strict), "email"));
1500                     break;
1501                 }
1502                 case "url": {
1503                     developer.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1504                     break;
1505                 }
1506                 case "organization": {
1507                     developer.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
1508                     break;
1509                 }
1510                 case "organizationUrl": {
1511                     developer.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
1512                     break;
1513                 }
1514                 case "roles": {
1515                     List<String> roles = new ArrayList<>();
1516                     locations = new HashMap<>();
1517                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1518                         if ("role".equals(parser.getLocalName())) {
1519                             if (addLocationInformation) {
1520                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1521                             }
1522                             roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
1523                         } else {
1524                             checkUnknownElement(parser, strict);
1525                         }
1526                     }
1527                     developer.roles(roles);
1528                     break;
1529                 }
1530                 case "timezone": {
1531                     developer.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
1532                     break;
1533                 }
1534                 case "properties": {
1535                     Map<String, String> properties = new LinkedHashMap<>();
1536                     locations = new HashMap<>();
1537                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1538                         String key = parser.getLocalName();
1539                         String value = nextText(parser, strict).trim();
1540                         if (addLocationInformation) {
1541                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1542                         }
1543                         properties.put(key, value);
1544                     }
1545                     developer.properties(properties);
1546                     break;
1547                 }
1548                 default: {
1549                     checkUnknownElement(parser, strict);
1550                     break;
1551                 }
1552             }
1553             if (addLocationInformation) {
1554                 developer.location(childName, new InputLocation(line, column, source, locations));
1555             }
1556         }
1557         return developer.build();
1558     }
1559 
1560     private Exclusion parseExclusion(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1561         String tagName = parser.getLocalName();
1562         Exclusion.Builder exclusion = Exclusion.newBuilder(true);
1563         if (addLocationInformation) {
1564             exclusion.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1565         }
1566         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1567             String name = parser.getAttributeLocalName(i);
1568             String ns = parser.getAttributeNamespace(i);
1569             String value = parser.getAttributeValue(i);
1570             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1571                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1572             } else {
1573                 checkUnknownAttribute(parser, name, tagName, strict);
1574             }
1575         }
1576         Set<String> parsed = new HashSet<>();
1577         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1578             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1579             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1580             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1581             Map<Object, InputLocation> locations = null;
1582             switch (childName) {
1583                 case "groupId": {
1584                     exclusion.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1585                     break;
1586                 }
1587                 case "artifactId": {
1588                     exclusion.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1589                     break;
1590                 }
1591                 default: {
1592                     checkUnknownElement(parser, strict);
1593                     break;
1594                 }
1595             }
1596             if (addLocationInformation) {
1597                 exclusion.location(childName, new InputLocation(line, column, source, locations));
1598             }
1599         }
1600         return exclusion.build();
1601     }
1602 
1603     private IssueManagement parseIssueManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1604         String tagName = parser.getLocalName();
1605         IssueManagement.Builder issueManagement = IssueManagement.newBuilder(true);
1606         if (addLocationInformation) {
1607             issueManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1608         }
1609         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1610             String name = parser.getAttributeLocalName(i);
1611             String ns = parser.getAttributeNamespace(i);
1612             String value = parser.getAttributeValue(i);
1613             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1614                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1615             } else {
1616                 checkUnknownAttribute(parser, name, tagName, strict);
1617             }
1618         }
1619         Set<String> parsed = new HashSet<>();
1620         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1621             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1622             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1623             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1624             Map<Object, InputLocation> locations = null;
1625             switch (childName) {
1626                 case "system": {
1627                     issueManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
1628                     break;
1629                 }
1630                 case "url": {
1631                     issueManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1632                     break;
1633                 }
1634                 default: {
1635                     checkUnknownElement(parser, strict);
1636                     break;
1637                 }
1638             }
1639             if (addLocationInformation) {
1640                 issueManagement.location(childName, new InputLocation(line, column, source, locations));
1641             }
1642         }
1643         return issueManagement.build();
1644     }
1645 
1646     private DistributionManagement parseDistributionManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1647         String tagName = parser.getLocalName();
1648         DistributionManagement.Builder distributionManagement = DistributionManagement.newBuilder(true);
1649         if (addLocationInformation) {
1650             distributionManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1651         }
1652         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1653             String name = parser.getAttributeLocalName(i);
1654             String ns = parser.getAttributeNamespace(i);
1655             String value = parser.getAttributeValue(i);
1656             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1657                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1658             } else {
1659                 checkUnknownAttribute(parser, name, tagName, strict);
1660             }
1661         }
1662         Set<String> parsed = new HashSet<>();
1663         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1664             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1665             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1666             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1667             Map<Object, InputLocation> locations = null;
1668             switch (childName) {
1669                 case "repository": {
1670                     distributionManagement.repository(parseDeploymentRepository(parser, strict, source));
1671                     break;
1672                 }
1673                 case "snapshotRepository": {
1674                     distributionManagement.snapshotRepository(parseDeploymentRepository(parser, strict, source));
1675                     break;
1676                 }
1677                 case "site": {
1678                     distributionManagement.site(parseSite(parser, strict, source));
1679                     break;
1680                 }
1681                 case "downloadUrl": {
1682                     distributionManagement.downloadUrl(interpolatedTrimmed(nextText(parser, strict), "downloadUrl"));
1683                     break;
1684                 }
1685                 case "relocation": {
1686                     distributionManagement.relocation(parseRelocation(parser, strict, source));
1687                     break;
1688                 }
1689                 case "status": {
1690                     distributionManagement.status(interpolatedTrimmed(nextText(parser, strict), "status"));
1691                     break;
1692                 }
1693                 default: {
1694                     checkUnknownElement(parser, strict);
1695                     break;
1696                 }
1697             }
1698             if (addLocationInformation) {
1699                 distributionManagement.location(childName, new InputLocation(line, column, source, locations));
1700             }
1701         }
1702         return distributionManagement.build();
1703     }
1704 
1705     private License parseLicense(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1706         String tagName = parser.getLocalName();
1707         License.Builder license = License.newBuilder(true);
1708         if (addLocationInformation) {
1709             license.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1710         }
1711         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1712             String name = parser.getAttributeLocalName(i);
1713             String ns = parser.getAttributeNamespace(i);
1714             String value = parser.getAttributeValue(i);
1715             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1716                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1717             } else {
1718                 checkUnknownAttribute(parser, name, tagName, strict);
1719             }
1720         }
1721         Set<String> parsed = new HashSet<>();
1722         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1723             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1724             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1725             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1726             Map<Object, InputLocation> locations = null;
1727             switch (childName) {
1728                 case "name": {
1729                     license.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1730                     break;
1731                 }
1732                 case "url": {
1733                     license.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1734                     break;
1735                 }
1736                 case "distribution": {
1737                     license.distribution(interpolatedTrimmed(nextText(parser, strict), "distribution"));
1738                     break;
1739                 }
1740                 case "comments": {
1741                     license.comments(interpolatedTrimmed(nextText(parser, strict), "comments"));
1742                     break;
1743                 }
1744                 default: {
1745                     checkUnknownElement(parser, strict);
1746                     break;
1747                 }
1748             }
1749             if (addLocationInformation) {
1750                 license.location(childName, new InputLocation(line, column, source, locations));
1751             }
1752         }
1753         return license.build();
1754     }
1755 
1756     private MailingList parseMailingList(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1757         String tagName = parser.getLocalName();
1758         MailingList.Builder mailingList = MailingList.newBuilder(true);
1759         if (addLocationInformation) {
1760             mailingList.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1761         }
1762         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1763             String name = parser.getAttributeLocalName(i);
1764             String ns = parser.getAttributeNamespace(i);
1765             String value = parser.getAttributeValue(i);
1766             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1767                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1768             } else {
1769                 checkUnknownAttribute(parser, name, tagName, strict);
1770             }
1771         }
1772         Set<String> parsed = new HashSet<>();
1773         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1774             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1775             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1776             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1777             Map<Object, InputLocation> locations = null;
1778             switch (childName) {
1779                 case "name": {
1780                     mailingList.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1781                     break;
1782                 }
1783                 case "subscribe": {
1784                     mailingList.subscribe(interpolatedTrimmed(nextText(parser, strict), "subscribe"));
1785                     break;
1786                 }
1787                 case "unsubscribe": {
1788                     mailingList.unsubscribe(interpolatedTrimmed(nextText(parser, strict), "unsubscribe"));
1789                     break;
1790                 }
1791                 case "post": {
1792                     mailingList.post(interpolatedTrimmed(nextText(parser, strict), "post"));
1793                     break;
1794                 }
1795                 case "archive": {
1796                     mailingList.archive(interpolatedTrimmed(nextText(parser, strict), "archive"));
1797                     break;
1798                 }
1799                 case "otherArchives": {
1800                     List<String> otherArchives = new ArrayList<>();
1801                     locations = new HashMap<>();
1802                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1803                         if ("otherArchive".equals(parser.getLocalName())) {
1804                             if (addLocationInformation) {
1805                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1806                             }
1807                             otherArchives.add(interpolatedTrimmed(nextText(parser, strict), "otherArchives"));
1808                         } else {
1809                             checkUnknownElement(parser, strict);
1810                         }
1811                     }
1812                     mailingList.otherArchives(otherArchives);
1813                     break;
1814                 }
1815                 default: {
1816                     checkUnknownElement(parser, strict);
1817                     break;
1818                 }
1819             }
1820             if (addLocationInformation) {
1821                 mailingList.location(childName, new InputLocation(line, column, source, locations));
1822             }
1823         }
1824         return mailingList.build();
1825     }
1826 
1827     private Organization parseOrganization(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1828         String tagName = parser.getLocalName();
1829         Organization.Builder organization = Organization.newBuilder(true);
1830         if (addLocationInformation) {
1831             organization.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1832         }
1833         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1834             String name = parser.getAttributeLocalName(i);
1835             String ns = parser.getAttributeNamespace(i);
1836             String value = parser.getAttributeValue(i);
1837             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1838                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1839             } else {
1840                 checkUnknownAttribute(parser, name, tagName, strict);
1841             }
1842         }
1843         Set<String> parsed = new HashSet<>();
1844         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1845             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1846             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1847             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1848             Map<Object, InputLocation> locations = null;
1849             switch (childName) {
1850                 case "name": {
1851                     organization.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1852                     break;
1853                 }
1854                 case "url": {
1855                     organization.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1856                     break;
1857                 }
1858                 default: {
1859                     checkUnknownElement(parser, strict);
1860                     break;
1861                 }
1862             }
1863             if (addLocationInformation) {
1864                 organization.location(childName, new InputLocation(line, column, source, locations));
1865             }
1866         }
1867         return organization.build();
1868     }
1869 
1870     private PatternSet parsePatternSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1871         String tagName = parser.getLocalName();
1872         PatternSet.Builder patternSet = PatternSet.newBuilder(true);
1873         if (addLocationInformation) {
1874             patternSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1875         }
1876         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1877             String name = parser.getAttributeLocalName(i);
1878             String ns = parser.getAttributeNamespace(i);
1879             String value = parser.getAttributeValue(i);
1880             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1881                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1882             } else {
1883                 checkUnknownAttribute(parser, name, tagName, strict);
1884             }
1885         }
1886         Set<String> parsed = new HashSet<>();
1887         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1888             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1889             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1890             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1891             Map<Object, InputLocation> locations = null;
1892             switch (childName) {
1893                 case "includes": {
1894                     List<String> includes = new ArrayList<>();
1895                     locations = new HashMap<>();
1896                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1897                         if ("include".equals(parser.getLocalName())) {
1898                             if (addLocationInformation) {
1899                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1900                             }
1901                             includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
1902                         } else {
1903                             checkUnknownElement(parser, strict);
1904                         }
1905                     }
1906                     patternSet.includes(includes);
1907                     break;
1908                 }
1909                 case "excludes": {
1910                     List<String> excludes = new ArrayList<>();
1911                     locations = new HashMap<>();
1912                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1913                         if ("exclude".equals(parser.getLocalName())) {
1914                             if (addLocationInformation) {
1915                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1916                             }
1917                             excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
1918                         } else {
1919                             checkUnknownElement(parser, strict);
1920                         }
1921                     }
1922                     patternSet.excludes(excludes);
1923                     break;
1924                 }
1925                 default: {
1926                     checkUnknownElement(parser, strict);
1927                     break;
1928                 }
1929             }
1930             if (addLocationInformation) {
1931                 patternSet.location(childName, new InputLocation(line, column, source, locations));
1932             }
1933         }
1934         return patternSet.build();
1935     }
1936 
1937     private Parent parseParent(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1938         String tagName = parser.getLocalName();
1939         Parent.Builder parent = Parent.newBuilder(true);
1940         if (addLocationInformation) {
1941             parent.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1942         }
1943         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1944             String name = parser.getAttributeLocalName(i);
1945             String ns = parser.getAttributeNamespace(i);
1946             String value = parser.getAttributeValue(i);
1947             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1948                 // just ignore attributes with non-default namespace (for example: xsi and xml)
1949             } else {
1950                 checkUnknownAttribute(parser, name, tagName, strict);
1951             }
1952         }
1953         Set<String> parsed = new HashSet<>();
1954         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1955             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1956             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1957             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1958             Map<Object, InputLocation> locations = null;
1959             switch (childName) {
1960                 case "groupId": {
1961                     parent.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1962                     break;
1963                 }
1964                 case "artifactId": {
1965                     parent.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1966                     break;
1967                 }
1968                 case "version": {
1969                     parent.version(interpolatedTrimmed(nextText(parser, strict), "version"));
1970                     break;
1971                 }
1972                 case "relativePath": {
1973                     parent.relativePath(interpolatedTrimmed(nextText(parser, strict), "relativePath"));
1974                     break;
1975                 }
1976                 default: {
1977                     checkUnknownElement(parser, strict);
1978                     break;
1979                 }
1980             }
1981             if (addLocationInformation) {
1982                 parent.location(childName, new InputLocation(line, column, source, locations));
1983             }
1984         }
1985         return parent.build();
1986     }
1987 
1988     private Scm parseScm(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1989         String tagName = parser.getLocalName();
1990         Scm.Builder scm = Scm.newBuilder(true);
1991         if (addLocationInformation) {
1992             scm.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1993         }
1994         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1995             String name = parser.getAttributeLocalName(i);
1996             String ns = parser.getAttributeNamespace(i);
1997             String value = parser.getAttributeValue(i);
1998             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1999                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2000             } else if ("child.scm.connection.inherit.append.path".equals(name)) {
2001                 if (addLocationInformation) {
2002                     scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2003                 }
2004                 scm.childScmConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.connection.inherit.append.path"));
2005             } else if ("child.scm.developerConnection.inherit.append.path".equals(name)) {
2006                 if (addLocationInformation) {
2007                     scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2008                 }
2009                 scm.childScmDeveloperConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.developerConnection.inherit.append.path"));
2010             } else if ("child.scm.url.inherit.append.path".equals(name)) {
2011                 if (addLocationInformation) {
2012                     scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2013                 }
2014                 scm.childScmUrlInheritAppendPath(interpolatedTrimmed(value, "child.scm.url.inherit.append.path"));
2015             } else {
2016                 checkUnknownAttribute(parser, name, tagName, strict);
2017             }
2018         }
2019         Set<String> parsed = new HashSet<>();
2020         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2021             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2022             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2023             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2024             Map<Object, InputLocation> locations = null;
2025             switch (childName) {
2026                 case "connection": {
2027                     scm.connection(interpolatedTrimmed(nextText(parser, strict), "connection"));
2028                     break;
2029                 }
2030                 case "developerConnection": {
2031                     scm.developerConnection(interpolatedTrimmed(nextText(parser, strict), "developerConnection"));
2032                     break;
2033                 }
2034                 case "tag": {
2035                     scm.tag(interpolatedTrimmed(nextText(parser, strict), "tag"));
2036                     break;
2037                 }
2038                 case "url": {
2039                     scm.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2040                     break;
2041                 }
2042                 default: {
2043                     checkUnknownElement(parser, strict);
2044                     break;
2045                 }
2046             }
2047             if (addLocationInformation) {
2048                 scm.location(childName, new InputLocation(line, column, source, locations));
2049             }
2050         }
2051         return scm.build();
2052     }
2053 
2054     private FileSet parseFileSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2055         String tagName = parser.getLocalName();
2056         FileSet.Builder fileSet = FileSet.newBuilder(true);
2057         if (addLocationInformation) {
2058             fileSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2059         }
2060         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2061             String name = parser.getAttributeLocalName(i);
2062             String ns = parser.getAttributeNamespace(i);
2063             String value = parser.getAttributeValue(i);
2064             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2065                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2066             } else {
2067                 checkUnknownAttribute(parser, name, tagName, strict);
2068             }
2069         }
2070         Set<String> parsed = new HashSet<>();
2071         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2072             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2073             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2074             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2075             Map<Object, InputLocation> locations = null;
2076             switch (childName) {
2077                 case "directory": {
2078                     fileSet.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
2079                     break;
2080                 }
2081                 case "includes": {
2082                     List<String> includes = new ArrayList<>();
2083                     locations = new HashMap<>();
2084                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2085                         if ("include".equals(parser.getLocalName())) {
2086                             if (addLocationInformation) {
2087                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2088                             }
2089                             includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
2090                         } else {
2091                             checkUnknownElement(parser, strict);
2092                         }
2093                     }
2094                     fileSet.includes(includes);
2095                     break;
2096                 }
2097                 case "excludes": {
2098                     List<String> excludes = new ArrayList<>();
2099                     locations = new HashMap<>();
2100                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2101                         if ("exclude".equals(parser.getLocalName())) {
2102                             if (addLocationInformation) {
2103                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2104                             }
2105                             excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
2106                         } else {
2107                             checkUnknownElement(parser, strict);
2108                         }
2109                     }
2110                     fileSet.excludes(excludes);
2111                     break;
2112                 }
2113                 default: {
2114                     checkUnknownElement(parser, strict);
2115                     break;
2116                 }
2117             }
2118             if (addLocationInformation) {
2119                 fileSet.location(childName, new InputLocation(line, column, source, locations));
2120             }
2121         }
2122         return fileSet.build();
2123     }
2124 
2125     private Resource parseResource(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2126         String tagName = parser.getLocalName();
2127         Resource.Builder resource = Resource.newBuilder(true);
2128         if (addLocationInformation) {
2129             resource.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2130         }
2131         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2132             String name = parser.getAttributeLocalName(i);
2133             String ns = parser.getAttributeNamespace(i);
2134             String value = parser.getAttributeValue(i);
2135             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2136                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2137             } else {
2138                 checkUnknownAttribute(parser, name, tagName, strict);
2139             }
2140         }
2141         Set<String> parsed = new HashSet<>();
2142         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2143             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2144             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2145             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2146             Map<Object, InputLocation> locations = null;
2147             switch (childName) {
2148                 case "targetPath": {
2149                     resource.targetPath(interpolatedTrimmed(nextText(parser, strict), "targetPath"));
2150                     break;
2151                 }
2152                 case "filtering": {
2153                     resource.filtering(interpolatedTrimmed(nextText(parser, strict), "filtering"));
2154                     break;
2155                 }
2156                 case "directory": {
2157                     resource.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
2158                     break;
2159                 }
2160                 case "includes": {
2161                     List<String> includes = new ArrayList<>();
2162                     locations = new HashMap<>();
2163                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2164                         if ("include".equals(parser.getLocalName())) {
2165                             if (addLocationInformation) {
2166                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2167                             }
2168                             includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
2169                         } else {
2170                             checkUnknownElement(parser, strict);
2171                         }
2172                     }
2173                     resource.includes(includes);
2174                     break;
2175                 }
2176                 case "excludes": {
2177                     List<String> excludes = new ArrayList<>();
2178                     locations = new HashMap<>();
2179                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2180                         if ("exclude".equals(parser.getLocalName())) {
2181                             if (addLocationInformation) {
2182                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2183                             }
2184                             excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
2185                         } else {
2186                             checkUnknownElement(parser, strict);
2187                         }
2188                     }
2189                     resource.excludes(excludes);
2190                     break;
2191                 }
2192                 default: {
2193                     checkUnknownElement(parser, strict);
2194                     break;
2195                 }
2196             }
2197             if (addLocationInformation) {
2198                 resource.location(childName, new InputLocation(line, column, source, locations));
2199             }
2200         }
2201         return resource.build();
2202     }
2203 
2204     private RepositoryBase parseRepositoryBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2205         String tagName = parser.getLocalName();
2206         RepositoryBase.Builder repositoryBase = RepositoryBase.newBuilder(true);
2207         if (addLocationInformation) {
2208             repositoryBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2209         }
2210         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2211             String name = parser.getAttributeLocalName(i);
2212             String ns = parser.getAttributeNamespace(i);
2213             String value = parser.getAttributeValue(i);
2214             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2215                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2216             } else {
2217                 checkUnknownAttribute(parser, name, tagName, strict);
2218             }
2219         }
2220         Set<String> parsed = new HashSet<>();
2221         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2222             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2223             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2224             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2225             Map<Object, InputLocation> locations = null;
2226             switch (childName) {
2227                 case "id": {
2228                     repositoryBase.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2229                     break;
2230                 }
2231                 case "name": {
2232                     repositoryBase.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2233                     break;
2234                 }
2235                 case "url": {
2236                     repositoryBase.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2237                     break;
2238                 }
2239                 case "layout": {
2240                     repositoryBase.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2241                     break;
2242                 }
2243                 default: {
2244                     checkUnknownElement(parser, strict);
2245                     break;
2246                 }
2247             }
2248             if (addLocationInformation) {
2249                 repositoryBase.location(childName, new InputLocation(line, column, source, locations));
2250             }
2251         }
2252         return repositoryBase.build();
2253     }
2254 
2255     private Repository parseRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2256         String tagName = parser.getLocalName();
2257         Repository.Builder repository = Repository.newBuilder(true);
2258         if (addLocationInformation) {
2259             repository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2260         }
2261         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2262             String name = parser.getAttributeLocalName(i);
2263             String ns = parser.getAttributeNamespace(i);
2264             String value = parser.getAttributeValue(i);
2265             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2266                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2267             } else {
2268                 checkUnknownAttribute(parser, name, tagName, strict);
2269             }
2270         }
2271         Set<String> parsed = new HashSet<>();
2272         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2273             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2274             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2275             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2276             Map<Object, InputLocation> locations = null;
2277             switch (childName) {
2278                 case "releases": {
2279                     repository.releases(parseRepositoryPolicy(parser, strict, source));
2280                     break;
2281                 }
2282                 case "snapshots": {
2283                     repository.snapshots(parseRepositoryPolicy(parser, strict, source));
2284                     break;
2285                 }
2286                 case "id": {
2287                     repository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2288                     break;
2289                 }
2290                 case "name": {
2291                     repository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2292                     break;
2293                 }
2294                 case "url": {
2295                     repository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2296                     break;
2297                 }
2298                 case "layout": {
2299                     repository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2300                     break;
2301                 }
2302                 default: {
2303                     checkUnknownElement(parser, strict);
2304                     break;
2305                 }
2306             }
2307             if (addLocationInformation) {
2308                 repository.location(childName, new InputLocation(line, column, source, locations));
2309             }
2310         }
2311         return repository.build();
2312     }
2313 
2314     private DeploymentRepository parseDeploymentRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2315         String tagName = parser.getLocalName();
2316         DeploymentRepository.Builder deploymentRepository = DeploymentRepository.newBuilder(true);
2317         if (addLocationInformation) {
2318             deploymentRepository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2319         }
2320         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2321             String name = parser.getAttributeLocalName(i);
2322             String ns = parser.getAttributeNamespace(i);
2323             String value = parser.getAttributeValue(i);
2324             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2325                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2326             } else {
2327                 checkUnknownAttribute(parser, name, tagName, strict);
2328             }
2329         }
2330         Set<String> parsed = new HashSet<>();
2331         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2332             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2333             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2334             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2335             Map<Object, InputLocation> locations = null;
2336             switch (childName) {
2337                 case "uniqueVersion": {
2338                     deploymentRepository.uniqueVersion(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "uniqueVersion"), "uniqueVersion", parser, true));
2339                     break;
2340                 }
2341                 case "releases": {
2342                     deploymentRepository.releases(parseRepositoryPolicy(parser, strict, source));
2343                     break;
2344                 }
2345                 case "snapshots": {
2346                     deploymentRepository.snapshots(parseRepositoryPolicy(parser, strict, source));
2347                     break;
2348                 }
2349                 case "id": {
2350                     deploymentRepository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2351                     break;
2352                 }
2353                 case "name": {
2354                     deploymentRepository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2355                     break;
2356                 }
2357                 case "url": {
2358                     deploymentRepository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2359                     break;
2360                 }
2361                 case "layout": {
2362                     deploymentRepository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2363                     break;
2364                 }
2365                 default: {
2366                     checkUnknownElement(parser, strict);
2367                     break;
2368                 }
2369             }
2370             if (addLocationInformation) {
2371                 deploymentRepository.location(childName, new InputLocation(line, column, source, locations));
2372             }
2373         }
2374         return deploymentRepository.build();
2375     }
2376 
2377     private RepositoryPolicy parseRepositoryPolicy(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2378         String tagName = parser.getLocalName();
2379         RepositoryPolicy.Builder repositoryPolicy = RepositoryPolicy.newBuilder(true);
2380         if (addLocationInformation) {
2381             repositoryPolicy.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2382         }
2383         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2384             String name = parser.getAttributeLocalName(i);
2385             String ns = parser.getAttributeNamespace(i);
2386             String value = parser.getAttributeValue(i);
2387             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2388                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2389             } else {
2390                 checkUnknownAttribute(parser, name, tagName, strict);
2391             }
2392         }
2393         Set<String> parsed = new HashSet<>();
2394         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2395             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2396             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2397             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2398             Map<Object, InputLocation> locations = null;
2399             switch (childName) {
2400                 case "enabled": {
2401                     repositoryPolicy.enabled(interpolatedTrimmed(nextText(parser, strict), "enabled"));
2402                     break;
2403                 }
2404                 case "updatePolicy": {
2405                     repositoryPolicy.updatePolicy(interpolatedTrimmed(nextText(parser, strict), "updatePolicy"));
2406                     break;
2407                 }
2408                 case "checksumPolicy": {
2409                     repositoryPolicy.checksumPolicy(interpolatedTrimmed(nextText(parser, strict), "checksumPolicy"));
2410                     break;
2411                 }
2412                 default: {
2413                     checkUnknownElement(parser, strict);
2414                     break;
2415                 }
2416             }
2417             if (addLocationInformation) {
2418                 repositoryPolicy.location(childName, new InputLocation(line, column, source, locations));
2419             }
2420         }
2421         return repositoryPolicy.build();
2422     }
2423 
2424     private Site parseSite(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2425         String tagName = parser.getLocalName();
2426         Site.Builder site = Site.newBuilder(true);
2427         if (addLocationInformation) {
2428             site.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2429         }
2430         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2431             String name = parser.getAttributeLocalName(i);
2432             String ns = parser.getAttributeNamespace(i);
2433             String value = parser.getAttributeValue(i);
2434             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2435                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2436             } else if ("child.site.url.inherit.append.path".equals(name)) {
2437                 if (addLocationInformation) {
2438                     site.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2439                 }
2440                 site.childSiteUrlInheritAppendPath(interpolatedTrimmed(value, "child.site.url.inherit.append.path"));
2441             } else {
2442                 checkUnknownAttribute(parser, name, tagName, strict);
2443             }
2444         }
2445         Set<String> parsed = new HashSet<>();
2446         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2447             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2448             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2449             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2450             Map<Object, InputLocation> locations = null;
2451             switch (childName) {
2452                 case "id": {
2453                     site.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2454                     break;
2455                 }
2456                 case "name": {
2457                     site.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2458                     break;
2459                 }
2460                 case "url": {
2461                     site.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2462                     break;
2463                 }
2464                 default: {
2465                     checkUnknownElement(parser, strict);
2466                     break;
2467                 }
2468             }
2469             if (addLocationInformation) {
2470                 site.location(childName, new InputLocation(line, column, source, locations));
2471             }
2472         }
2473         return site.build();
2474     }
2475 
2476     private ConfigurationContainer parseConfigurationContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2477         String tagName = parser.getLocalName();
2478         ConfigurationContainer.Builder configurationContainer = ConfigurationContainer.newBuilder(true);
2479         if (addLocationInformation) {
2480             configurationContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2481         }
2482         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2483             String name = parser.getAttributeLocalName(i);
2484             String ns = parser.getAttributeNamespace(i);
2485             String value = parser.getAttributeValue(i);
2486             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2487                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2488             } else {
2489                 checkUnknownAttribute(parser, name, tagName, strict);
2490             }
2491         }
2492         Set<String> parsed = new HashSet<>();
2493         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2494             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2495             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2496             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2497             Map<Object, InputLocation> locations = null;
2498             switch (childName) {
2499                 case "inherited": {
2500                     configurationContainer.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2501                     break;
2502                 }
2503                 case "configuration": {
2504                     configurationContainer.configuration(buildXmlNode(parser, source));
2505                     break;
2506                 }
2507                 default: {
2508                     checkUnknownElement(parser, strict);
2509                     break;
2510                 }
2511             }
2512             if (addLocationInformation) {
2513                 configurationContainer.location(childName, new InputLocation(line, column, source, locations));
2514             }
2515         }
2516         return configurationContainer.build();
2517     }
2518 
2519     private Plugin parsePlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2520         String tagName = parser.getLocalName();
2521         Plugin.Builder plugin = Plugin.newBuilder(true);
2522         if (addLocationInformation) {
2523             plugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2524         }
2525         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2526             String name = parser.getAttributeLocalName(i);
2527             String ns = parser.getAttributeNamespace(i);
2528             String value = parser.getAttributeValue(i);
2529             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2530                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2531             } else {
2532                 checkUnknownAttribute(parser, name, tagName, strict);
2533             }
2534         }
2535         Set<String> parsed = new HashSet<>();
2536         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2537             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2538             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2539             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2540             Map<Object, InputLocation> locations = null;
2541             switch (childName) {
2542                 case "groupId": {
2543                     plugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
2544                     break;
2545                 }
2546                 case "artifactId": {
2547                     plugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
2548                     break;
2549                 }
2550                 case "version": {
2551                     plugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
2552                     break;
2553                 }
2554                 case "extensions": {
2555                     plugin.extensions(interpolatedTrimmed(nextText(parser, strict), "extensions"));
2556                     break;
2557                 }
2558                 case "executions": {
2559                     List<PluginExecution> executions = new ArrayList<>();
2560                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2561                         if ("execution".equals(parser.getLocalName())) {
2562                             executions.add(parsePluginExecution(parser, strict, source));
2563                         } else {
2564                             checkUnknownElement(parser, strict);
2565                         }
2566                     }
2567                     plugin.executions(executions);
2568                     break;
2569                 }
2570                 case "dependencies": {
2571                     List<Dependency> dependencies = new ArrayList<>();
2572                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2573                         if ("dependency".equals(parser.getLocalName())) {
2574                             dependencies.add(parseDependency(parser, strict, source));
2575                         } else {
2576                             checkUnknownElement(parser, strict);
2577                         }
2578                     }
2579                     plugin.dependencies(dependencies);
2580                     break;
2581                 }
2582                 case "inherited": {
2583                     plugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2584                     break;
2585                 }
2586                 case "configuration": {
2587                     plugin.configuration(buildXmlNode(parser, source));
2588                     break;
2589                 }
2590                 default: {
2591                     checkUnknownElement(parser, strict);
2592                     break;
2593                 }
2594             }
2595             if (addLocationInformation) {
2596                 plugin.location(childName, new InputLocation(line, column, source, locations));
2597             }
2598         }
2599         return plugin.build();
2600     }
2601 
2602     private PluginExecution parsePluginExecution(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2603         String tagName = parser.getLocalName();
2604         PluginExecution.Builder pluginExecution = PluginExecution.newBuilder(true);
2605         if (addLocationInformation) {
2606             pluginExecution.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2607         }
2608         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2609             String name = parser.getAttributeLocalName(i);
2610             String ns = parser.getAttributeNamespace(i);
2611             String value = parser.getAttributeValue(i);
2612             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2613                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2614             } else {
2615                 checkUnknownAttribute(parser, name, tagName, strict);
2616             }
2617         }
2618         Set<String> parsed = new HashSet<>();
2619         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2620             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2621             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2622             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2623             Map<Object, InputLocation> locations = null;
2624             switch (childName) {
2625                 case "id": {
2626                     pluginExecution.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2627                     break;
2628                 }
2629                 case "phase": {
2630                     pluginExecution.phase(interpolatedTrimmed(nextText(parser, strict), "phase"));
2631                     break;
2632                 }
2633                 case "priority": {
2634                     pluginExecution.priority(getIntegerValue(interpolatedTrimmed(nextText(parser, strict), "priority"), "priority", parser, strict, 0));
2635                     break;
2636                 }
2637                 case "goals": {
2638                     List<String> goals = new ArrayList<>();
2639                     locations = new HashMap<>();
2640                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2641                         if ("goal".equals(parser.getLocalName())) {
2642                             if (addLocationInformation) {
2643                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2644                             }
2645                             goals.add(interpolatedTrimmed(nextText(parser, strict), "goals"));
2646                         } else {
2647                             checkUnknownElement(parser, strict);
2648                         }
2649                     }
2650                     pluginExecution.goals(goals);
2651                     break;
2652                 }
2653                 case "inherited": {
2654                     pluginExecution.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2655                     break;
2656                 }
2657                 case "configuration": {
2658                     pluginExecution.configuration(buildXmlNode(parser, source));
2659                     break;
2660                 }
2661                 default: {
2662                     checkUnknownElement(parser, strict);
2663                     break;
2664                 }
2665             }
2666             if (addLocationInformation) {
2667                 pluginExecution.location(childName, new InputLocation(line, column, source, locations));
2668             }
2669         }
2670         return pluginExecution.build();
2671     }
2672 
2673     private DependencyManagement parseDependencyManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2674         String tagName = parser.getLocalName();
2675         DependencyManagement.Builder dependencyManagement = DependencyManagement.newBuilder(true);
2676         if (addLocationInformation) {
2677             dependencyManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2678         }
2679         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2680             String name = parser.getAttributeLocalName(i);
2681             String ns = parser.getAttributeNamespace(i);
2682             String value = parser.getAttributeValue(i);
2683             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2684                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2685             } else {
2686                 checkUnknownAttribute(parser, name, tagName, strict);
2687             }
2688         }
2689         Set<String> parsed = new HashSet<>();
2690         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2691             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2692             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2693             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2694             Map<Object, InputLocation> locations = null;
2695             switch (childName) {
2696                 case "dependencies": {
2697                     List<Dependency> dependencies = new ArrayList<>();
2698                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2699                         if ("dependency".equals(parser.getLocalName())) {
2700                             dependencies.add(parseDependency(parser, strict, source));
2701                         } else {
2702                             checkUnknownElement(parser, strict);
2703                         }
2704                     }
2705                     dependencyManagement.dependencies(dependencies);
2706                     break;
2707                 }
2708                 default: {
2709                     checkUnknownElement(parser, strict);
2710                     break;
2711                 }
2712             }
2713             if (addLocationInformation) {
2714                 dependencyManagement.location(childName, new InputLocation(line, column, source, locations));
2715             }
2716         }
2717         return dependencyManagement.build();
2718     }
2719 
2720     private PluginManagement parsePluginManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2721         String tagName = parser.getLocalName();
2722         PluginManagement.Builder pluginManagement = PluginManagement.newBuilder(true);
2723         if (addLocationInformation) {
2724             pluginManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2725         }
2726         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2727             String name = parser.getAttributeLocalName(i);
2728             String ns = parser.getAttributeNamespace(i);
2729             String value = parser.getAttributeValue(i);
2730             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2731                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2732             } else {
2733                 checkUnknownAttribute(parser, name, tagName, strict);
2734             }
2735         }
2736         Set<String> parsed = new HashSet<>();
2737         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2738             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2739             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2740             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2741             Map<Object, InputLocation> locations = null;
2742             switch (childName) {
2743                 case "plugins": {
2744                     List<Plugin> plugins = new ArrayList<>();
2745                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2746                         if ("plugin".equals(parser.getLocalName())) {
2747                             plugins.add(parsePlugin(parser, strict, source));
2748                         } else {
2749                             checkUnknownElement(parser, strict);
2750                         }
2751                     }
2752                     pluginManagement.plugins(plugins);
2753                     break;
2754                 }
2755                 default: {
2756                     checkUnknownElement(parser, strict);
2757                     break;
2758                 }
2759             }
2760             if (addLocationInformation) {
2761                 pluginManagement.location(childName, new InputLocation(line, column, source, locations));
2762             }
2763         }
2764         return pluginManagement.build();
2765     }
2766 
2767     private Reporting parseReporting(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2768         String tagName = parser.getLocalName();
2769         Reporting.Builder reporting = Reporting.newBuilder(true);
2770         if (addLocationInformation) {
2771             reporting.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2772         }
2773         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2774             String name = parser.getAttributeLocalName(i);
2775             String ns = parser.getAttributeNamespace(i);
2776             String value = parser.getAttributeValue(i);
2777             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2778                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2779             } else {
2780                 checkUnknownAttribute(parser, name, tagName, strict);
2781             }
2782         }
2783         Set<String> parsed = new HashSet<>();
2784         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2785             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2786             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2787             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2788             Map<Object, InputLocation> locations = null;
2789             switch (childName) {
2790                 case "excludeDefaults": {
2791                     reporting.excludeDefaults(interpolatedTrimmed(nextText(parser, strict), "excludeDefaults"));
2792                     break;
2793                 }
2794                 case "outputDirectory": {
2795                     reporting.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
2796                     break;
2797                 }
2798                 case "plugins": {
2799                     List<ReportPlugin> plugins = new ArrayList<>();
2800                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2801                         if ("plugin".equals(parser.getLocalName())) {
2802                             plugins.add(parseReportPlugin(parser, strict, source));
2803                         } else {
2804                             checkUnknownElement(parser, strict);
2805                         }
2806                     }
2807                     reporting.plugins(plugins);
2808                     break;
2809                 }
2810                 default: {
2811                     checkUnknownElement(parser, strict);
2812                     break;
2813                 }
2814             }
2815             if (addLocationInformation) {
2816                 reporting.location(childName, new InputLocation(line, column, source, locations));
2817             }
2818         }
2819         return reporting.build();
2820     }
2821 
2822     private Profile parseProfile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2823         String tagName = parser.getLocalName();
2824         Profile.Builder profile = Profile.newBuilder(true);
2825         if (addLocationInformation) {
2826             profile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2827         }
2828         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2829             String name = parser.getAttributeLocalName(i);
2830             String ns = parser.getAttributeNamespace(i);
2831             String value = parser.getAttributeValue(i);
2832             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2833                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2834             } else {
2835                 checkUnknownAttribute(parser, name, tagName, strict);
2836             }
2837         }
2838         Set<String> parsed = new HashSet<>();
2839         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2840             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2841             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2842             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2843             Map<Object, InputLocation> locations = null;
2844             switch (childName) {
2845                 case "id": {
2846                     profile.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2847                     break;
2848                 }
2849                 case "activation": {
2850                     profile.activation(parseActivation(parser, strict, source));
2851                     break;
2852                 }
2853                 case "build": {
2854                     profile.build(parseBuildBase(parser, strict, source));
2855                     break;
2856                 }
2857                 case "modules": {
2858                     List<String> modules = new ArrayList<>();
2859                     locations = new HashMap<>();
2860                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2861                         if ("module".equals(parser.getLocalName())) {
2862                             if (addLocationInformation) {
2863                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2864                             }
2865                             modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
2866                         } else {
2867                             checkUnknownElement(parser, strict);
2868                         }
2869                     }
2870                     profile.modules(modules);
2871                     break;
2872                 }
2873                 case "distributionManagement": {
2874                     profile.distributionManagement(parseDistributionManagement(parser, strict, source));
2875                     break;
2876                 }
2877                 case "properties": {
2878                     Map<String, String> properties = new LinkedHashMap<>();
2879                     locations = new HashMap<>();
2880                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2881                         String key = parser.getLocalName();
2882                         String value = nextText(parser, strict).trim();
2883                         if (addLocationInformation) {
2884                             locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2885                         }
2886                         properties.put(key, value);
2887                     }
2888                     profile.properties(properties);
2889                     break;
2890                 }
2891                 case "dependencyManagement": {
2892                     profile.dependencyManagement(parseDependencyManagement(parser, strict, source));
2893                     break;
2894                 }
2895                 case "dependencies": {
2896                     List<Dependency> dependencies = new ArrayList<>();
2897                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2898                         if ("dependency".equals(parser.getLocalName())) {
2899                             dependencies.add(parseDependency(parser, strict, source));
2900                         } else {
2901                             checkUnknownElement(parser, strict);
2902                         }
2903                     }
2904                     profile.dependencies(dependencies);
2905                     break;
2906                 }
2907                 case "repositories": {
2908                     List<Repository> repositories = new ArrayList<>();
2909                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2910                         if ("repository".equals(parser.getLocalName())) {
2911                             repositories.add(parseRepository(parser, strict, source));
2912                         } else {
2913                             checkUnknownElement(parser, strict);
2914                         }
2915                     }
2916                     profile.repositories(repositories);
2917                     break;
2918                 }
2919                 case "pluginRepositories": {
2920                     List<Repository> pluginRepositories = new ArrayList<>();
2921                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2922                         if ("pluginRepository".equals(parser.getLocalName())) {
2923                             pluginRepositories.add(parseRepository(parser, strict, source));
2924                         } else {
2925                             checkUnknownElement(parser, strict);
2926                         }
2927                     }
2928                     profile.pluginRepositories(pluginRepositories);
2929                     break;
2930                 }
2931                 case "reporting": {
2932                     profile.reporting(parseReporting(parser, strict, source));
2933                     break;
2934                 }
2935                 default: {
2936                     checkUnknownElement(parser, strict);
2937                     break;
2938                 }
2939             }
2940             if (addLocationInformation) {
2941                 profile.location(childName, new InputLocation(line, column, source, locations));
2942             }
2943         }
2944         return profile.build();
2945     }
2946 
2947     private Activation parseActivation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2948         String tagName = parser.getLocalName();
2949         Activation.Builder activation = Activation.newBuilder(true);
2950         if (addLocationInformation) {
2951             activation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2952         }
2953         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2954             String name = parser.getAttributeLocalName(i);
2955             String ns = parser.getAttributeNamespace(i);
2956             String value = parser.getAttributeValue(i);
2957             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2958                 // just ignore attributes with non-default namespace (for example: xsi and xml)
2959             } else {
2960                 checkUnknownAttribute(parser, name, tagName, strict);
2961             }
2962         }
2963         Set<String> parsed = new HashSet<>();
2964         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2965             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2966             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2967             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2968             Map<Object, InputLocation> locations = null;
2969             switch (childName) {
2970                 case "activeByDefault": {
2971                     activation.activeByDefault(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "activeByDefault"), "activeByDefault", parser, false));
2972                     break;
2973                 }
2974                 case "jdk": {
2975                     activation.jdk(interpolatedTrimmed(nextText(parser, strict), "jdk"));
2976                     break;
2977                 }
2978                 case "os": {
2979                     activation.os(parseActivationOS(parser, strict, source));
2980                     break;
2981                 }
2982                 case "property": {
2983                     activation.property(parseActivationProperty(parser, strict, source));
2984                     break;
2985                 }
2986                 case "file": {
2987                     activation.file(parseActivationFile(parser, strict, source));
2988                     break;
2989                 }
2990                 default: {
2991                     checkUnknownElement(parser, strict);
2992                     break;
2993                 }
2994             }
2995             if (addLocationInformation) {
2996                 activation.location(childName, new InputLocation(line, column, source, locations));
2997             }
2998         }
2999         return activation.build();
3000     }
3001 
3002     private ActivationProperty parseActivationProperty(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3003         String tagName = parser.getLocalName();
3004         ActivationProperty.Builder activationProperty = ActivationProperty.newBuilder(true);
3005         if (addLocationInformation) {
3006             activationProperty.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3007         }
3008         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3009             String name = parser.getAttributeLocalName(i);
3010             String ns = parser.getAttributeNamespace(i);
3011             String value = parser.getAttributeValue(i);
3012             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3013                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3014             } else {
3015                 checkUnknownAttribute(parser, name, tagName, strict);
3016             }
3017         }
3018         Set<String> parsed = new HashSet<>();
3019         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3020             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3021             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3022             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3023             Map<Object, InputLocation> locations = null;
3024             switch (childName) {
3025                 case "name": {
3026                     activationProperty.name(interpolatedTrimmed(nextText(parser, strict), "name"));
3027                     break;
3028                 }
3029                 case "value": {
3030                     activationProperty.value(interpolatedTrimmed(nextText(parser, strict), "value"));
3031                     break;
3032                 }
3033                 default: {
3034                     checkUnknownElement(parser, strict);
3035                     break;
3036                 }
3037             }
3038             if (addLocationInformation) {
3039                 activationProperty.location(childName, new InputLocation(line, column, source, locations));
3040             }
3041         }
3042         return activationProperty.build();
3043     }
3044 
3045     private ActivationOS parseActivationOS(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3046         String tagName = parser.getLocalName();
3047         ActivationOS.Builder activationOS = ActivationOS.newBuilder(true);
3048         if (addLocationInformation) {
3049             activationOS.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3050         }
3051         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3052             String name = parser.getAttributeLocalName(i);
3053             String ns = parser.getAttributeNamespace(i);
3054             String value = parser.getAttributeValue(i);
3055             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3056                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3057             } else {
3058                 checkUnknownAttribute(parser, name, tagName, strict);
3059             }
3060         }
3061         Set<String> parsed = new HashSet<>();
3062         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3063             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3064             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3065             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3066             Map<Object, InputLocation> locations = null;
3067             switch (childName) {
3068                 case "name": {
3069                     activationOS.name(interpolatedTrimmed(nextText(parser, strict), "name"));
3070                     break;
3071                 }
3072                 case "family": {
3073                     activationOS.family(interpolatedTrimmed(nextText(parser, strict), "family"));
3074                     break;
3075                 }
3076                 case "arch": {
3077                     activationOS.arch(interpolatedTrimmed(nextText(parser, strict), "arch"));
3078                     break;
3079                 }
3080                 case "version": {
3081                     activationOS.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3082                     break;
3083                 }
3084                 default: {
3085                     checkUnknownElement(parser, strict);
3086                     break;
3087                 }
3088             }
3089             if (addLocationInformation) {
3090                 activationOS.location(childName, new InputLocation(line, column, source, locations));
3091             }
3092         }
3093         return activationOS.build();
3094     }
3095 
3096     private ActivationFile parseActivationFile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3097         String tagName = parser.getLocalName();
3098         ActivationFile.Builder activationFile = ActivationFile.newBuilder(true);
3099         if (addLocationInformation) {
3100             activationFile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3101         }
3102         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3103             String name = parser.getAttributeLocalName(i);
3104             String ns = parser.getAttributeNamespace(i);
3105             String value = parser.getAttributeValue(i);
3106             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3107                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3108             } else {
3109                 checkUnknownAttribute(parser, name, tagName, strict);
3110             }
3111         }
3112         Set<String> parsed = new HashSet<>();
3113         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3114             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3115             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3116             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3117             Map<Object, InputLocation> locations = null;
3118             switch (childName) {
3119                 case "missing": {
3120                     activationFile.missing(interpolatedTrimmed(nextText(parser, strict), "missing"));
3121                     break;
3122                 }
3123                 case "exists": {
3124                     activationFile.exists(interpolatedTrimmed(nextText(parser, strict), "exists"));
3125                     break;
3126                 }
3127                 default: {
3128                     checkUnknownElement(parser, strict);
3129                     break;
3130                 }
3131             }
3132             if (addLocationInformation) {
3133                 activationFile.location(childName, new InputLocation(line, column, source, locations));
3134             }
3135         }
3136         return activationFile.build();
3137     }
3138 
3139     private ReportPlugin parseReportPlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3140         String tagName = parser.getLocalName();
3141         ReportPlugin.Builder reportPlugin = ReportPlugin.newBuilder(true);
3142         if (addLocationInformation) {
3143             reportPlugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3144         }
3145         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3146             String name = parser.getAttributeLocalName(i);
3147             String ns = parser.getAttributeNamespace(i);
3148             String value = parser.getAttributeValue(i);
3149             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3150                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3151             } else {
3152                 checkUnknownAttribute(parser, name, tagName, strict);
3153             }
3154         }
3155         Set<String> parsed = new HashSet<>();
3156         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3157             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3158             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3159             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3160             Map<Object, InputLocation> locations = null;
3161             switch (childName) {
3162                 case "groupId": {
3163                     reportPlugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3164                     break;
3165                 }
3166                 case "artifactId": {
3167                     reportPlugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3168                     break;
3169                 }
3170                 case "version": {
3171                     reportPlugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3172                     break;
3173                 }
3174                 case "reportSets": {
3175                     List<ReportSet> reportSets = new ArrayList<>();
3176                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
3177                         if ("reportSet".equals(parser.getLocalName())) {
3178                             reportSets.add(parseReportSet(parser, strict, source));
3179                         } else {
3180                             checkUnknownElement(parser, strict);
3181                         }
3182                     }
3183                     reportPlugin.reportSets(reportSets);
3184                     break;
3185                 }
3186                 case "inherited": {
3187                     reportPlugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
3188                     break;
3189                 }
3190                 case "configuration": {
3191                     reportPlugin.configuration(buildXmlNode(parser, source));
3192                     break;
3193                 }
3194                 default: {
3195                     checkUnknownElement(parser, strict);
3196                     break;
3197                 }
3198             }
3199             if (addLocationInformation) {
3200                 reportPlugin.location(childName, new InputLocation(line, column, source, locations));
3201             }
3202         }
3203         return reportPlugin.build();
3204     }
3205 
3206     private ReportSet parseReportSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3207         String tagName = parser.getLocalName();
3208         ReportSet.Builder reportSet = ReportSet.newBuilder(true);
3209         if (addLocationInformation) {
3210             reportSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3211         }
3212         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3213             String name = parser.getAttributeLocalName(i);
3214             String ns = parser.getAttributeNamespace(i);
3215             String value = parser.getAttributeValue(i);
3216             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3217                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3218             } else {
3219                 checkUnknownAttribute(parser, name, tagName, strict);
3220             }
3221         }
3222         Set<String> parsed = new HashSet<>();
3223         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3224             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3225             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3226             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3227             Map<Object, InputLocation> locations = null;
3228             switch (childName) {
3229                 case "id": {
3230                     reportSet.id(interpolatedTrimmed(nextText(parser, strict), "id"));
3231                     break;
3232                 }
3233                 case "reports": {
3234                     List<String> reports = new ArrayList<>();
3235                     locations = new HashMap<>();
3236                     while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
3237                         if ("report".equals(parser.getLocalName())) {
3238                             if (addLocationInformation) {
3239                                 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3240                             }
3241                             reports.add(interpolatedTrimmed(nextText(parser, strict), "reports"));
3242                         } else {
3243                             checkUnknownElement(parser, strict);
3244                         }
3245                     }
3246                     reportSet.reports(reports);
3247                     break;
3248                 }
3249                 case "inherited": {
3250                     reportSet.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
3251                     break;
3252                 }
3253                 case "configuration": {
3254                     reportSet.configuration(buildXmlNode(parser, source));
3255                     break;
3256                 }
3257                 default: {
3258                     checkUnknownElement(parser, strict);
3259                     break;
3260                 }
3261             }
3262             if (addLocationInformation) {
3263                 reportSet.location(childName, new InputLocation(line, column, source, locations));
3264             }
3265         }
3266         return reportSet.build();
3267     }
3268 
3269     private Prerequisites parsePrerequisites(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3270         String tagName = parser.getLocalName();
3271         Prerequisites.Builder prerequisites = Prerequisites.newBuilder(true);
3272         if (addLocationInformation) {
3273             prerequisites.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3274         }
3275         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3276             String name = parser.getAttributeLocalName(i);
3277             String ns = parser.getAttributeNamespace(i);
3278             String value = parser.getAttributeValue(i);
3279             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3280                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3281             } else {
3282                 checkUnknownAttribute(parser, name, tagName, strict);
3283             }
3284         }
3285         Set<String> parsed = new HashSet<>();
3286         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3287             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3288             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3289             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3290             Map<Object, InputLocation> locations = null;
3291             switch (childName) {
3292                 case "maven": {
3293                     prerequisites.maven(interpolatedTrimmed(nextText(parser, strict), "maven"));
3294                     break;
3295                 }
3296                 default: {
3297                     checkUnknownElement(parser, strict);
3298                     break;
3299                 }
3300             }
3301             if (addLocationInformation) {
3302                 prerequisites.location(childName, new InputLocation(line, column, source, locations));
3303             }
3304         }
3305         return prerequisites.build();
3306     }
3307 
3308     private Relocation parseRelocation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3309         String tagName = parser.getLocalName();
3310         Relocation.Builder relocation = Relocation.newBuilder(true);
3311         if (addLocationInformation) {
3312             relocation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3313         }
3314         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3315             String name = parser.getAttributeLocalName(i);
3316             String ns = parser.getAttributeNamespace(i);
3317             String value = parser.getAttributeValue(i);
3318             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3319                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3320             } else {
3321                 checkUnknownAttribute(parser, name, tagName, strict);
3322             }
3323         }
3324         Set<String> parsed = new HashSet<>();
3325         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3326             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3327             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3328             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3329             Map<Object, InputLocation> locations = null;
3330             switch (childName) {
3331                 case "groupId": {
3332                     relocation.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3333                     break;
3334                 }
3335                 case "artifactId": {
3336                     relocation.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3337                     break;
3338                 }
3339                 case "version": {
3340                     relocation.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3341                     break;
3342                 }
3343                 case "message": {
3344                     relocation.message(interpolatedTrimmed(nextText(parser, strict), "message"));
3345                     break;
3346                 }
3347                 default: {
3348                     checkUnknownElement(parser, strict);
3349                     break;
3350                 }
3351             }
3352             if (addLocationInformation) {
3353                 relocation.location(childName, new InputLocation(line, column, source, locations));
3354             }
3355         }
3356         return relocation.build();
3357     }
3358 
3359     private Extension parseExtension(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3360         String tagName = parser.getLocalName();
3361         Extension.Builder extension = Extension.newBuilder(true);
3362         if (addLocationInformation) {
3363             extension.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3364         }
3365         for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3366             String name = parser.getAttributeLocalName(i);
3367             String ns = parser.getAttributeNamespace(i);
3368             String value = parser.getAttributeValue(i);
3369             if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3370                 // just ignore attributes with non-default namespace (for example: xsi and xml)
3371             } else {
3372                 checkUnknownAttribute(parser, name, tagName, strict);
3373             }
3374         }
3375         Set<String> parsed = new HashSet<>();
3376         while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3377             String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3378             int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3379             int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3380             Map<Object, InputLocation> locations = null;
3381             switch (childName) {
3382                 case "groupId": {
3383                     extension.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3384                     break;
3385                 }
3386                 case "artifactId": {
3387                     extension.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3388                     break;
3389                 }
3390                 case "version": {
3391                     extension.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3392                     break;
3393                 }
3394                 case "configuration": {
3395                     extension.configuration(buildXmlNode(parser, source));
3396                     break;
3397                 }
3398                 default: {
3399                     checkUnknownElement(parser, strict);
3400                     break;
3401                 }
3402             }
3403             if (addLocationInformation) {
3404                 extension.location(childName, new InputLocation(line, column, source, locations));
3405             }
3406         }
3407         return extension.build();
3408     }
3409 
3410 
3411     private String checkDuplicate(String tagName, XMLStreamReader parser, Set<String> parsed) throws XMLStreamException {
3412         switch (tagName) {
3413         case "organisation":
3414             tagName = "organization";
3415             break;
3416         case "organisationUrl":
3417             tagName = "organizationUrl";
3418             break;
3419         }
3420         return tagName;
3421     }
3422 
3423     /**
3424      * Method checkUnknownAttribute.
3425      *
3426      * @param parser a parser object.
3427      * @param strict a strict object.
3428      * @param tagName a tagName object.
3429      * @param attribute a attribute object.
3430      * @throws XMLStreamException XMLStreamException if
3431      * any.
3432      * @throws IOException IOException if any.
3433      */
3434     private void checkUnknownAttribute(XMLStreamReader parser, String attribute, String tagName, boolean strict) throws XMLStreamException {
3435         // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
3436         if (strict) {
3437             throw new XMLStreamException("Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser.getLocation(), null);
3438         }
3439     } //-- void checkUnknownAttribute(XMLStreamReader, String, String, boolean)
3440 
3441     /**
3442      * Method checkUnknownElement.
3443      *
3444      * @param parser a parser object.
3445      * @param strict a strict object.
3446      * @throws XMLStreamException XMLStreamException if
3447      * any.
3448      * @throws IOException IOException if any.
3449      */
3450     private void checkUnknownElement(XMLStreamReader parser, boolean strict) throws XMLStreamException {
3451         if (strict) {
3452             throw new XMLStreamException("Unrecognised tag: '" + parser.getName() + "'", parser.getLocation(), null);
3453         }
3454 
3455         for (int unrecognizedTagCount = 1; unrecognizedTagCount > 0;) {
3456             int eventType = nextTag(parser);
3457             if (eventType == XMLStreamReader.START_ELEMENT) {
3458                 unrecognizedTagCount++;
3459             } else if (eventType == XMLStreamReader.END_ELEMENT) {
3460                 unrecognizedTagCount--;
3461             }
3462         }
3463     } //-- void checkUnknownElement(XMLStreamReader, boolean)
3464 
3465     /**
3466      * Method getTrimmedValue.
3467      *
3468      * @param s a s object.
3469      * @return String
3470      */
3471     private String getTrimmedValue(String s) {
3472         if (s != null) {
3473             s = s.trim();
3474         }
3475         return s;
3476     } //-- String getTrimmedValue(String)
3477 
3478     /**
3479      * Method interpolatedTrimmed.
3480      *
3481      * @param value a value object.
3482      * @param context a context object.
3483      * @return String
3484      */
3485     private String interpolatedTrimmed(String value, String context) {
3486         return getTrimmedValue(contentTransformer.transform(value, context));
3487     } //-- String interpolatedTrimmed(String, String)
3488 
3489     /**
3490      * Method nextTag.
3491      *
3492      * @param parser a parser object.
3493      * @throws IOException IOException if any.
3494      * @throws XMLStreamException XMLStreamException if
3495      * any.
3496      * @return int
3497      */
3498     private int nextTag(XMLStreamReader parser) throws XMLStreamException {
3499         while (true) {
3500             int next = parser.next();
3501             switch (next) {
3502                 case XMLStreamReader.SPACE:
3503                 case XMLStreamReader.COMMENT:
3504                 case XMLStreamReader.PROCESSING_INSTRUCTION:
3505                 case XMLStreamReader.CDATA:
3506                 case XMLStreamReader.CHARACTERS:
3507                     continue;
3508                 case XMLStreamReader.START_ELEMENT:
3509                 case XMLStreamReader.END_ELEMENT:
3510                     return next;
3511             }
3512         }
3513     } //-- int nextTag(XMLStreamReader)
3514 
3515     private String nextText(XMLStreamReader parser, boolean strict) throws XMLStreamException {
3516         int eventType = parser.getEventType();
3517         if (eventType != XMLStreamReader.START_ELEMENT) {
3518             throw new XMLStreamException("parser must be on START_ELEMENT to read next text", parser.getLocation(), null);
3519         }
3520         eventType = parser.next();
3521         StringBuilder result = new StringBuilder();
3522         while (true) {
3523             if (eventType == XMLStreamReader.CHARACTERS || eventType == XMLStreamReader.CDATA) {
3524                 result.append(parser.getText());
3525             } else if (eventType == XMLStreamReader.ENTITY_REFERENCE) {
3526                 String val = null;
3527                 if (strict) {
3528                     throw new XMLStreamException("Entities are not supported in strict mode", parser.getLocation(), null);
3529                 } else if (addDefaultEntities) {
3530                     val = DEFAULT_ENTITIES.get(parser.getLocalName());
3531                 }
3532                 if (val != null) {
3533                     result.append(val);
3534                 } else {
3535                     result.append("&").append(parser.getLocalName()).append(";");
3536                 }
3537             } else if (eventType != XMLStreamReader.COMMENT) {
3538                 break;
3539             }
3540             eventType = parser.next();
3541         }
3542         if (eventType != XMLStreamReader.END_ELEMENT) {
3543             throw new XMLStreamException(
3544                 "TEXT must be immediately followed by END_ELEMENT and not " + eventType /*TODO: TYPES[eventType]*/, parser.getLocation(), null);
3545         }
3546         return result.toString();
3547     }
3548 
3549     private XmlNode buildXmlNode(XMLStreamReader parser, InputSource source) throws XMLStreamException {
3550         return XmlNodeBuilder.build(parser,
3551                 addLocationInformation
3552                         ? p -> new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source)
3553                         : null);
3554     }
3555 
3556     /**
3557      * Method getBooleanValue.
3558      *
3559      * @param s a s object.
3560      * @param defaultValue a defaultValue object.
3561      * @param parser a parser object.
3562      * @param attribute a attribute object.
3563      * @throws XMLStreamException XMLStreamException if
3564      * any.
3565      * @return boolean
3566      */
3567     private boolean getBooleanValue(String s, String attribute, XMLStreamReader parser, boolean defaultValue) throws XMLStreamException {
3568         if (s != null && s.length() != 0) {
3569             return Boolean.valueOf(s).booleanValue();
3570         }
3571         return defaultValue;
3572     } //-- boolean getBooleanValue(String, String, XMLStreamReader, String)
3573 
3574     /**
3575      * Method getIntegerValue.
3576      *
3577      * @param s a s object.
3578      * @param strict a strict object.
3579      * @param parser a parser object.
3580      * @param attribute a attribute object.
3581      * @throws XMLStreamException XMLStreamException if
3582      * any.
3583      * @return int
3584      */
3585     private int getIntegerValue(String s, String attribute, XMLStreamReader parser, boolean strict, int defaultValue) throws XMLStreamException {
3586         if (s != null) {
3587             try {
3588                 return Integer.valueOf(s).intValue();
3589             } catch (NumberFormatException nfe) {
3590                 if (strict) {
3591                     throw new XMLStreamException("Unable to parse element '" + attribute + "', must be an integer", parser.getLocation(), nfe);
3592                 }
3593             }
3594         }
3595         return defaultValue;
3596     } //-- int getIntegerValue(String, String, XMLStreamReader, boolean)
3597 
3598     public static interface ContentTransformer {
3599         /**
3600          * Interpolate the value read from the xpp3 document
3601          * @param source The source value
3602          * @param fieldName A description of the field being interpolated. The implementation may use this to
3603          *                           log stuff.
3604          * @return The interpolated value.
3605          */
3606         String transform(String source, String fieldName);
3607     }
3608 
3609 }