All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.maven.model.v4.MavenStaxReader Maven / Gradle / Ivy

// =================== DO NOT EDIT THIS FILE ====================
//  Generated by Modello Velocity from reader-stax.vm
//  template, any modifications will be overwritten.
// ==============================================================
package org.apache.maven.model.v4;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.api.annotations.Generated;
import org.apache.maven.api.model.InputSource;
import org.apache.maven.api.model.InputLocation;
import org.apache.maven.api.model.Model;
import org.apache.maven.api.model.ModelBase;
import org.apache.maven.api.model.PluginContainer;
import org.apache.maven.api.model.PluginConfiguration;
import org.apache.maven.api.model.BuildBase;
import org.apache.maven.api.model.Build;
import org.apache.maven.api.model.CiManagement;
import org.apache.maven.api.model.Notifier;
import org.apache.maven.api.model.Contributor;
import org.apache.maven.api.model.Dependency;
import org.apache.maven.api.model.Developer;
import org.apache.maven.api.model.Exclusion;
import org.apache.maven.api.model.IssueManagement;
import org.apache.maven.api.model.DistributionManagement;
import org.apache.maven.api.model.License;
import org.apache.maven.api.model.MailingList;
import org.apache.maven.api.model.Organization;
import org.apache.maven.api.model.PatternSet;
import org.apache.maven.api.model.Parent;
import org.apache.maven.api.model.Scm;
import org.apache.maven.api.model.FileSet;
import org.apache.maven.api.model.Resource;
import org.apache.maven.api.model.RepositoryBase;
import org.apache.maven.api.model.Repository;
import org.apache.maven.api.model.DeploymentRepository;
import org.apache.maven.api.model.RepositoryPolicy;
import org.apache.maven.api.model.Site;
import org.apache.maven.api.model.ConfigurationContainer;
import org.apache.maven.api.model.Plugin;
import org.apache.maven.api.model.PluginExecution;
import org.apache.maven.api.model.DependencyManagement;
import org.apache.maven.api.model.PluginManagement;
import org.apache.maven.api.model.Reporting;
import org.apache.maven.api.model.Profile;
import org.apache.maven.api.model.Activation;
import org.apache.maven.api.model.ActivationProperty;
import org.apache.maven.api.model.ActivationOS;
import org.apache.maven.api.model.ActivationFile;
import org.apache.maven.api.model.ReportPlugin;
import org.apache.maven.api.model.ReportSet;
import org.apache.maven.api.model.Prerequisites;
import org.apache.maven.api.model.Relocation;
import org.apache.maven.api.model.Extension;
import org.apache.maven.api.model.InputLocation;
import org.apache.maven.api.model.InputSource;
import org.apache.maven.internal.xml.XmlNodeBuilder;
import org.apache.maven.api.xml.XmlNode;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;

import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
import static javax.xml.XMLConstants.XML_NS_URI;

@Generated
public class MavenStaxReader {

    private static final Map DEFAULT_ENTITIES;
    static {
        Map entities = new HashMap<>();
        entities.put("nbsp", "\u00a0");
        entities.put("iexcl", "\u00a1");
        entities.put("cent", "\u00a2");
        entities.put("pound", "\u00a3");
        entities.put("curren", "\u00a4");
        entities.put("yen", "\u00a5");
        entities.put("brvbar", "\u00a6");
        entities.put("sect", "\u00a7");
        entities.put("uml", "\u00a8");
        entities.put("copy", "\u00a9");
        entities.put("ordf", "\u00aa");
        entities.put("laquo", "\u00ab");
        entities.put("not", "\u00ac");
        entities.put("shy", "\u00ad");
        entities.put("reg", "\u00ae");
        entities.put("macr", "\u00af");
        entities.put("deg", "\u00b0");
        entities.put("plusmn", "\u00b1");
        entities.put("sup2", "\u00b2");
        entities.put("sup3", "\u00b3");
        entities.put("acute", "\u00b4");
        entities.put("micro", "\u00b5");
        entities.put("para", "\u00b6");
        entities.put("middot", "\u00b7");
        entities.put("cedil", "\u00b8");
        entities.put("sup1", "\u00b9");
        entities.put("ordm", "\u00ba");
        entities.put("raquo", "\u00bb");
        entities.put("frac14", "\u00bc");
        entities.put("frac12", "\u00bd");
        entities.put("frac34", "\u00be");
        entities.put("iquest", "\u00bf");
        entities.put("Agrave", "\u00c0");
        entities.put("Aacute", "\u00c1");
        entities.put("Acirc", "\u00c2");
        entities.put("Atilde", "\u00c3");
        entities.put("Auml", "\u00c4");
        entities.put("Aring", "\u00c5");
        entities.put("AElig", "\u00c6");
        entities.put("Ccedil", "\u00c7");
        entities.put("Egrave", "\u00c8");
        entities.put("Eacute", "\u00c9");
        entities.put("Ecirc", "\u00ca");
        entities.put("Euml", "\u00cb");
        entities.put("Igrave", "\u00cc");
        entities.put("Iacute", "\u00cd");
        entities.put("Icirc", "\u00ce");
        entities.put("Iuml", "\u00cf");
        entities.put("ETH", "\u00d0");
        entities.put("Ntilde", "\u00d1");
        entities.put("Ograve", "\u00d2");
        entities.put("Oacute", "\u00d3");
        entities.put("Ocirc", "\u00d4");
        entities.put("Otilde", "\u00d5");
        entities.put("Ouml", "\u00d6");
        entities.put("times", "\u00d7");
        entities.put("Oslash", "\u00d8");
        entities.put("Ugrave", "\u00d9");
        entities.put("Uacute", "\u00da");
        entities.put("Ucirc", "\u00db");
        entities.put("Uuml", "\u00dc");
        entities.put("Yacute", "\u00dd");
        entities.put("THORN", "\u00de");
        entities.put("szlig", "\u00df");
        entities.put("agrave", "\u00e0");
        entities.put("aacute", "\u00e1");
        entities.put("acirc", "\u00e2");
        entities.put("atilde", "\u00e3");
        entities.put("auml", "\u00e4");
        entities.put("aring", "\u00e5");
        entities.put("aelig", "\u00e6");
        entities.put("ccedil", "\u00e7");
        entities.put("egrave", "\u00e8");
        entities.put("eacute", "\u00e9");
        entities.put("ecirc", "\u00ea");
        entities.put("euml", "\u00eb");
        entities.put("igrave", "\u00ec");
        entities.put("iacute", "\u00ed");
        entities.put("icirc", "\u00ee");
        entities.put("iuml", "\u00ef");
        entities.put("eth", "\u00f0");
        entities.put("ntilde", "\u00f1");
        entities.put("ograve", "\u00f2");
        entities.put("oacute", "\u00f3");
        entities.put("ocirc", "\u00f4");
        entities.put("otilde", "\u00f5");
        entities.put("ouml", "\u00f6");
        entities.put("divide", "\u00f7");
        entities.put("oslash", "\u00f8");
        entities.put("ugrave", "\u00f9");
        entities.put("uacute", "\u00fa");
        entities.put("ucirc", "\u00fb");
        entities.put("uuml", "\u00fc");
        entities.put("yacute", "\u00fd");
        entities.put("thorn", "\u00fe");
        entities.put("yuml", "\u00ff");

        // ----------------------------------------------------------------------
        // Special entities
        // ----------------------------------------------------------------------

        entities.put("OElig", "\u0152");
        entities.put("oelig", "\u0153");
        entities.put("Scaron", "\u0160");
        entities.put("scaron", "\u0161");
        entities.put("Yuml", "\u0178");
        entities.put("circ", "\u02c6");
        entities.put("tilde", "\u02dc");
        entities.put("ensp", "\u2002");
        entities.put("emsp", "\u2003");
        entities.put("thinsp", "\u2009");
        entities.put("zwnj", "\u200c");
        entities.put("zwj", "\u200d");
        entities.put("lrm", "\u200e");
        entities.put("rlm", "\u200f");
        entities.put("ndash", "\u2013");
        entities.put("mdash", "\u2014");
        entities.put("lsquo", "\u2018");
        entities.put("rsquo", "\u2019");
        entities.put("sbquo", "\u201a");
        entities.put("ldquo", "\u201c");
        entities.put("rdquo", "\u201d");
        entities.put("bdquo", "\u201e");
        entities.put("dagger", "\u2020");
        entities.put("Dagger", "\u2021");
        entities.put("permil", "\u2030");
        entities.put("lsaquo", "\u2039");
        entities.put("rsaquo", "\u203a");
        entities.put("euro", "\u20ac");

        // ----------------------------------------------------------------------
        // Symbol entities
        // ----------------------------------------------------------------------

        entities.put("fnof", "\u0192");
        entities.put("Alpha", "\u0391");
        entities.put("Beta", "\u0392");
        entities.put("Gamma", "\u0393");
        entities.put("Delta", "\u0394");
        entities.put("Epsilon", "\u0395");
        entities.put("Zeta", "\u0396");
        entities.put("Eta", "\u0397");
        entities.put("Theta", "\u0398");
        entities.put("Iota", "\u0399");
        entities.put("Kappa", "\u039a");
        entities.put("Lambda", "\u039b");
        entities.put("Mu", "\u039c");
        entities.put("Nu", "\u039d");
        entities.put("Xi", "\u039e");
        entities.put("Omicron", "\u039f");
        entities.put("Pi", "\u03a0");
        entities.put("Rho", "\u03a1");
        entities.put("Sigma", "\u03a3");
        entities.put("Tau", "\u03a4");
        entities.put("Upsilon", "\u03a5");
        entities.put("Phi", "\u03a6");
        entities.put("Chi", "\u03a7");
        entities.put("Psi", "\u03a8");
        entities.put("Omega", "\u03a9");
        entities.put("alpha", "\u03b1");
        entities.put("beta", "\u03b2");
        entities.put("gamma", "\u03b3");
        entities.put("delta", "\u03b4");
        entities.put("epsilon", "\u03b5");
        entities.put("zeta", "\u03b6");
        entities.put("eta", "\u03b7");
        entities.put("theta", "\u03b8");
        entities.put("iota", "\u03b9");
        entities.put("kappa", "\u03ba");
        entities.put("lambda", "\u03bb");
        entities.put("mu", "\u03bc");
        entities.put("nu", "\u03bd");
        entities.put("xi", "\u03be");
        entities.put("omicron", "\u03bf");
        entities.put("pi", "\u03c0");
        entities.put("rho", "\u03c1");
        entities.put("sigmaf", "\u03c2");
        entities.put("sigma", "\u03c3");
        entities.put("tau", "\u03c4");
        entities.put("upsilon", "\u03c5");
        entities.put("phi", "\u03c6");
        entities.put("chi", "\u03c7");
        entities.put("psi", "\u03c8");
        entities.put("omega", "\u03c9");
        entities.put("thetasym", "\u03d1");
        entities.put("upsih", "\u03d2");
        entities.put("piv", "\u03d6");
        entities.put("bull", "\u2022");
        entities.put("hellip", "\u2026");
        entities.put("prime", "\u2032");
        entities.put("Prime", "\u2033");
        entities.put("oline", "\u203e");
        entities.put("frasl", "\u2044");
        entities.put("weierp", "\u2118");
        entities.put("image", "\u2111");
        entities.put("real", "\u211c");
        entities.put("trade", "\u2122");
        entities.put("alefsym", "\u2135");
        entities.put("larr", "\u2190");
        entities.put("uarr", "\u2191");
        entities.put("rarr", "\u2192");
        entities.put("darr", "\u2193");
        entities.put("harr", "\u2194");
        entities.put("crarr", "\u21b5");
        entities.put("lArr", "\u21d0");
        entities.put("uArr", "\u21d1");
        entities.put("rArr", "\u21d2");
        entities.put("dArr", "\u21d3");
        entities.put("hArr", "\u21d4");
        entities.put("forall", "\u2200");
        entities.put("part", "\u2202");
        entities.put("exist", "\u2203");
        entities.put("empty", "\u2205");
        entities.put("nabla", "\u2207");
        entities.put("isin", "\u2208");
        entities.put("notin", "\u2209");
        entities.put("ni", "\u220b");
        entities.put("prod", "\u220f");
        entities.put("sum", "\u2211");
        entities.put("minus", "\u2212");
        entities.put("lowast", "\u2217");
        entities.put("radic", "\u221a");
        entities.put("prop", "\u221d");
        entities.put("infin", "\u221e");
        entities.put("ang", "\u2220");
        entities.put("and", "\u2227");
        entities.put("or", "\u2228");
        entities.put("cap", "\u2229");
        entities.put("cup", "\u222a");
        entities.put("int", "\u222b");
        entities.put("there4", "\u2234");
        entities.put("sim", "\u223c");
        entities.put("cong", "\u2245");
        entities.put("asymp", "\u2248");
        entities.put("ne", "\u2260");
        entities.put("equiv", "\u2261");
        entities.put("le", "\u2264");
        entities.put("ge", "\u2265");
        entities.put("sub", "\u2282");
        entities.put("sup", "\u2283");
        entities.put("nsub", "\u2284");
        entities.put("sube", "\u2286");
        entities.put("supe", "\u2287");
        entities.put("oplus", "\u2295");
        entities.put("otimes", "\u2297");
        entities.put("perp", "\u22a5");
        entities.put("sdot", "\u22c5");
        entities.put("lceil", "\u2308");
        entities.put("rceil", "\u2309");
        entities.put("lfloor", "\u230a");
        entities.put("rfloor", "\u230b");
        entities.put("lang", "\u2329");
        entities.put("rang", "\u232a");
        entities.put("loz", "\u25ca");
        entities.put("spades", "\u2660");
        entities.put("clubs", "\u2663");
        entities.put("hearts", "\u2665");
        entities.put("diams", "\u2666");
        DEFAULT_ENTITIES = Collections.unmodifiableMap(entities);
    }

    private boolean addDefaultEntities = true;
    private boolean addLocationInformation = true;

    private final ContentTransformer contentTransformer;

    public MavenStaxReader() {
        this((s, f) -> s);
    }

    public MavenStaxReader(ContentTransformer contentTransformer) {
        this.contentTransformer = contentTransformer;
    }

    /**
     * Returns the state of the "add default entities" flag.
     *
     * @return boolean
     */
    public boolean getAddDefaultEntities() {
        return addDefaultEntities;
    } //-- boolean getAddDefaultEntities()

    /**
     * Sets the state of the "add default entities" flag.
     *
     * @param addDefaultEntities a addDefaultEntities object.
     */
    public void setAddDefaultEntities(boolean addDefaultEntities) {
        this.addDefaultEntities = addDefaultEntities;
    } //-- void setAddDefaultEntities(boolean)

    /**
     * Returns the state of the "add location information" flag.
     *
     * @return boolean
     */
    public boolean getAddLocationInformation() {
        return addLocationInformation;
    } //-- boolean getAddLocationInformation()

    /**
     * Sets the state of the "add location information" flag.
     *
     * @param addLocationInformation a addLocationInformation object.
     */
    public void setAddLocationInformation(boolean addLocationInformation) {
        this.addLocationInformation = addLocationInformation;
    } //-- void setAddLocationInformation(boolean)

    public Model read(Reader reader) throws XMLStreamException {
        return read(reader, true, null);
    }

    /**
     * @param reader a reader object.
     * @param strict a strict object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return Model
     */
    public Model read(Reader reader, boolean strict, InputSource source) throws XMLStreamException {
        XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory();
        factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
        StreamSource streamSource = new StreamSource(reader, source != null ? source.getLocation() : null);
        XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
        return read(parser, strict, source);
    } //-- Model read(Reader, boolean)

    public Model read(InputStream in) throws XMLStreamException {
        return read(in, true, null);
    }

    /**
     * Method read.
     *
     * @param in a in object.
     * @param strict a strict object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return Model
     */
    public Model read(InputStream in, boolean strict, InputSource source) throws XMLStreamException {
        XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory();
        factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
        StreamSource streamSource = new StreamSource(in, source != null ? source.getLocation() : null);
        XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
        return read(parser, strict, source);
    } //-- Model read(InputStream, boolean)

    /**
     * Method read.
     *
     * @param parser a parser object.
     * @param strict a strict object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return Model
     */
    public Model read(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        Model model = null;
        int eventType = parser.getEventType();
        boolean parsed = false;
        while (eventType != XMLStreamReader.END_DOCUMENT) {
            if (eventType == XMLStreamReader.START_ELEMENT) {
                if (strict && ! "project".equals(parser.getLocalName())) {
                    throw new XMLStreamException("Expected root element 'project' but found '" + parser.getName() + "'", parser.getLocation(), null);
                } else if (parsed) {
                    // fallback, already expected a XMLStreamException due to invalid XML
                    throw new XMLStreamException("Duplicated tag: 'project'", parser.getLocation(), null);
                }
                model = parseModel(parser, strict, source);
                parsed = true;
            }
            eventType = parser.next();
        }
        if (parsed) {
            return model;
        }
        throw new XMLStreamException("Expected root element 'project' but found no element at all: invalid XML document", parser.getLocation(), null);
    } //-- Model read(XMLStreamReader, boolean)

    private Model parseModel(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Model.Builder model = Model.newBuilder(true);
        if (addLocationInformation) {
            model.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else if ("xmlns".equals(name)) {
                // ignore xmlns attribute in root class, which is a reserved attribute name
            } else if ("child.project.url.inherit.append.path".equals(name)) {
                if (addLocationInformation) {
                    model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                }
                model.childProjectUrlInheritAppendPath(interpolatedTrimmed(value, "child.project.url.inherit.append.path"));
            } else if ("root".equals(name)) {
                if (addLocationInformation) {
                    model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                }
                model.root(getBooleanValue(interpolatedTrimmed(value, "root"), "root", parser, false));
            } else if ("preserve.model.version".equals(name)) {
                if (addLocationInformation) {
                    model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                }
                model.preserveModelVersion(getBooleanValue(interpolatedTrimmed(value, "preserve.model.version"), "preserve.model.version", parser, false));
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "modelVersion": {
                    model.modelVersion(interpolatedTrimmed(nextText(parser, strict), "modelVersion"));
                    break;
                }
                case "parent": {
                    model.parent(parseParent(parser, strict, source));
                    break;
                }
                case "groupId": {
                    model.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    model.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                case "version": {
                    model.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                case "packaging": {
                    model.packaging(interpolatedTrimmed(nextText(parser, strict), "packaging"));
                    break;
                }
                case "name": {
                    model.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "description": {
                    model.description(interpolatedTrimmed(nextText(parser, strict), "description"));
                    break;
                }
                case "url": {
                    model.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "inceptionYear": {
                    model.inceptionYear(interpolatedTrimmed(nextText(parser, strict), "inceptionYear"));
                    break;
                }
                case "organization": {
                    model.organization(parseOrganization(parser, strict, source));
                    break;
                }
                case "licenses": {
                    List licenses = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("license".equals(parser.getLocalName())) {
                            licenses.add(parseLicense(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.licenses(licenses);
                    break;
                }
                case "developers": {
                    List developers = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("developer".equals(parser.getLocalName())) {
                            developers.add(parseDeveloper(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.developers(developers);
                    break;
                }
                case "contributors": {
                    List contributors = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("contributor".equals(parser.getLocalName())) {
                            contributors.add(parseContributor(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.contributors(contributors);
                    break;
                }
                case "mailingLists": {
                    List mailingLists = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("mailingList".equals(parser.getLocalName())) {
                            mailingLists.add(parseMailingList(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.mailingLists(mailingLists);
                    break;
                }
                case "prerequisites": {
                    model.prerequisites(parsePrerequisites(parser, strict, source));
                    break;
                }
                case "modules": {
                    List modules = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("module".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.modules(modules);
                    break;
                }
                case "scm": {
                    model.scm(parseScm(parser, strict, source));
                    break;
                }
                case "issueManagement": {
                    model.issueManagement(parseIssueManagement(parser, strict, source));
                    break;
                }
                case "ciManagement": {
                    model.ciManagement(parseCiManagement(parser, strict, source));
                    break;
                }
                case "distributionManagement": {
                    model.distributionManagement(parseDistributionManagement(parser, strict, source));
                    break;
                }
                case "properties": {
                    Map properties = new LinkedHashMap<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        String key = parser.getLocalName();
                        String value = nextText(parser, strict).trim();
                        if (addLocationInformation) {
                            locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                        }
                        properties.put(key, value);
                    }
                    model.properties(properties);
                    break;
                }
                case "dependencyManagement": {
                    model.dependencyManagement(parseDependencyManagement(parser, strict, source));
                    break;
                }
                case "dependencies": {
                    List dependencies = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("dependency".equals(parser.getLocalName())) {
                            dependencies.add(parseDependency(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.dependencies(dependencies);
                    break;
                }
                case "repositories": {
                    List repositories = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("repository".equals(parser.getLocalName())) {
                            repositories.add(parseRepository(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.repositories(repositories);
                    break;
                }
                case "pluginRepositories": {
                    List pluginRepositories = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("pluginRepository".equals(parser.getLocalName())) {
                            pluginRepositories.add(parseRepository(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.pluginRepositories(pluginRepositories);
                    break;
                }
                case "build": {
                    model.build(parseBuild(parser, strict, source));
                    break;
                }
                case "reporting": {
                    model.reporting(parseReporting(parser, strict, source));
                    break;
                }
                case "profiles": {
                    List profiles = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("profile".equals(parser.getLocalName())) {
                            profiles.add(parseProfile(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    model.profiles(profiles);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                model.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        model.namespaceUri(parser.getNamespaceURI());
        model.modelEncoding(parser.getEncoding());
        return model.build();
    }

    private ModelBase parseModelBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        ModelBase.Builder modelBase = ModelBase.newBuilder(true);
        if (addLocationInformation) {
            modelBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "modules": {
                    List modules = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("module".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    modelBase.modules(modules);
                    break;
                }
                case "distributionManagement": {
                    modelBase.distributionManagement(parseDistributionManagement(parser, strict, source));
                    break;
                }
                case "properties": {
                    Map properties = new LinkedHashMap<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        String key = parser.getLocalName();
                        String value = nextText(parser, strict).trim();
                        if (addLocationInformation) {
                            locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                        }
                        properties.put(key, value);
                    }
                    modelBase.properties(properties);
                    break;
                }
                case "dependencyManagement": {
                    modelBase.dependencyManagement(parseDependencyManagement(parser, strict, source));
                    break;
                }
                case "dependencies": {
                    List dependencies = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("dependency".equals(parser.getLocalName())) {
                            dependencies.add(parseDependency(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    modelBase.dependencies(dependencies);
                    break;
                }
                case "repositories": {
                    List repositories = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("repository".equals(parser.getLocalName())) {
                            repositories.add(parseRepository(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    modelBase.repositories(repositories);
                    break;
                }
                case "pluginRepositories": {
                    List pluginRepositories = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("pluginRepository".equals(parser.getLocalName())) {
                            pluginRepositories.add(parseRepository(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    modelBase.pluginRepositories(pluginRepositories);
                    break;
                }
                case "reporting": {
                    modelBase.reporting(parseReporting(parser, strict, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                modelBase.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return modelBase.build();
    }

    private PluginContainer parsePluginContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        PluginContainer.Builder pluginContainer = PluginContainer.newBuilder(true);
        if (addLocationInformation) {
            pluginContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "plugins": {
                    List plugins = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("plugin".equals(parser.getLocalName())) {
                            plugins.add(parsePlugin(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    pluginContainer.plugins(plugins);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                pluginContainer.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return pluginContainer.build();
    }

    private PluginConfiguration parsePluginConfiguration(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        PluginConfiguration.Builder pluginConfiguration = PluginConfiguration.newBuilder(true);
        if (addLocationInformation) {
            pluginConfiguration.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "pluginManagement": {
                    pluginConfiguration.pluginManagement(parsePluginManagement(parser, strict, source));
                    break;
                }
                case "plugins": {
                    List plugins = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("plugin".equals(parser.getLocalName())) {
                            plugins.add(parsePlugin(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    pluginConfiguration.plugins(plugins);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                pluginConfiguration.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return pluginConfiguration.build();
    }

    private BuildBase parseBuildBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        BuildBase.Builder buildBase = BuildBase.newBuilder(true);
        if (addLocationInformation) {
            buildBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "defaultGoal": {
                    buildBase.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
                    break;
                }
                case "resources": {
                    List resources = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("resource".equals(parser.getLocalName())) {
                            resources.add(parseResource(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    buildBase.resources(resources);
                    break;
                }
                case "testResources": {
                    List testResources = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("testResource".equals(parser.getLocalName())) {
                            testResources.add(parseResource(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    buildBase.testResources(testResources);
                    break;
                }
                case "directory": {
                    buildBase.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
                    break;
                }
                case "finalName": {
                    buildBase.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
                    break;
                }
                case "filters": {
                    List filters = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("filter".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    buildBase.filters(filters);
                    break;
                }
                case "pluginManagement": {
                    buildBase.pluginManagement(parsePluginManagement(parser, strict, source));
                    break;
                }
                case "plugins": {
                    List plugins = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("plugin".equals(parser.getLocalName())) {
                            plugins.add(parsePlugin(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    buildBase.plugins(plugins);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                buildBase.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return buildBase.build();
    }

    private Build parseBuild(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Build.Builder build = Build.newBuilder(true);
        if (addLocationInformation) {
            build.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "sourceDirectory": {
                    build.sourceDirectory(interpolatedTrimmed(nextText(parser, strict), "sourceDirectory"));
                    break;
                }
                case "scriptSourceDirectory": {
                    build.scriptSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "scriptSourceDirectory"));
                    break;
                }
                case "testSourceDirectory": {
                    build.testSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "testSourceDirectory"));
                    break;
                }
                case "outputDirectory": {
                    build.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
                    break;
                }
                case "testOutputDirectory": {
                    build.testOutputDirectory(interpolatedTrimmed(nextText(parser, strict), "testOutputDirectory"));
                    break;
                }
                case "extensions": {
                    List extensions = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("extension".equals(parser.getLocalName())) {
                            extensions.add(parseExtension(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    build.extensions(extensions);
                    break;
                }
                case "defaultGoal": {
                    build.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
                    break;
                }
                case "resources": {
                    List resources = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("resource".equals(parser.getLocalName())) {
                            resources.add(parseResource(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    build.resources(resources);
                    break;
                }
                case "testResources": {
                    List testResources = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("testResource".equals(parser.getLocalName())) {
                            testResources.add(parseResource(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    build.testResources(testResources);
                    break;
                }
                case "directory": {
                    build.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
                    break;
                }
                case "finalName": {
                    build.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
                    break;
                }
                case "filters": {
                    List filters = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("filter".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    build.filters(filters);
                    break;
                }
                case "pluginManagement": {
                    build.pluginManagement(parsePluginManagement(parser, strict, source));
                    break;
                }
                case "plugins": {
                    List plugins = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("plugin".equals(parser.getLocalName())) {
                            plugins.add(parsePlugin(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    build.plugins(plugins);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                build.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return build.build();
    }

    private CiManagement parseCiManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        CiManagement.Builder ciManagement = CiManagement.newBuilder(true);
        if (addLocationInformation) {
            ciManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "system": {
                    ciManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
                    break;
                }
                case "url": {
                    ciManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "notifiers": {
                    List notifiers = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("notifier".equals(parser.getLocalName())) {
                            notifiers.add(parseNotifier(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    ciManagement.notifiers(notifiers);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                ciManagement.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return ciManagement.build();
    }

    private Notifier parseNotifier(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Notifier.Builder notifier = Notifier.newBuilder(true);
        if (addLocationInformation) {
            notifier.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "type": {
                    notifier.type(interpolatedTrimmed(nextText(parser, strict), "type"));
                    break;
                }
                case "sendOnError": {
                    notifier.sendOnError(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnError"), "sendOnError", parser, true));
                    break;
                }
                case "sendOnFailure": {
                    notifier.sendOnFailure(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnFailure"), "sendOnFailure", parser, true));
                    break;
                }
                case "sendOnSuccess": {
                    notifier.sendOnSuccess(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnSuccess"), "sendOnSuccess", parser, true));
                    break;
                }
                case "sendOnWarning": {
                    notifier.sendOnWarning(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnWarning"), "sendOnWarning", parser, true));
                    break;
                }
                case "address": {
                    notifier.address(interpolatedTrimmed(nextText(parser, strict), "address"));
                    break;
                }
                case "configuration": {
                    Map configuration = new LinkedHashMap<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        String key = parser.getLocalName();
                        String value = nextText(parser, strict).trim();
                        if (addLocationInformation) {
                            locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                        }
                        configuration.put(key, value);
                    }
                    notifier.configuration(configuration);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                notifier.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return notifier.build();
    }

    private Contributor parseContributor(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Contributor.Builder contributor = Contributor.newBuilder(true);
        if (addLocationInformation) {
            contributor.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "name": {
                    contributor.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "email": {
                    contributor.email(interpolatedTrimmed(nextText(parser, strict), "email"));
                    break;
                }
                case "url": {
                    contributor.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "organization": {
                    contributor.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
                    break;
                }
                case "organizationUrl": {
                    contributor.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
                    break;
                }
                case "roles": {
                    List roles = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("role".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    contributor.roles(roles);
                    break;
                }
                case "timezone": {
                    contributor.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
                    break;
                }
                case "properties": {
                    Map properties = new LinkedHashMap<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        String key = parser.getLocalName();
                        String value = nextText(parser, strict).trim();
                        if (addLocationInformation) {
                            locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                        }
                        properties.put(key, value);
                    }
                    contributor.properties(properties);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                contributor.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return contributor.build();
    }

    private Dependency parseDependency(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Dependency.Builder dependency = Dependency.newBuilder(true);
        if (addLocationInformation) {
            dependency.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "groupId": {
                    dependency.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    dependency.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                case "version": {
                    dependency.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                case "type": {
                    dependency.type(interpolatedTrimmed(nextText(parser, strict), "type"));
                    break;
                }
                case "classifier": {
                    dependency.classifier(interpolatedTrimmed(nextText(parser, strict), "classifier"));
                    break;
                }
                case "scope": {
                    dependency.scope(interpolatedTrimmed(nextText(parser, strict), "scope"));
                    break;
                }
                case "systemPath": {
                    dependency.systemPath(interpolatedTrimmed(nextText(parser, strict), "systemPath"));
                    break;
                }
                case "exclusions": {
                    List exclusions = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("exclusion".equals(parser.getLocalName())) {
                            exclusions.add(parseExclusion(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    dependency.exclusions(exclusions);
                    break;
                }
                case "optional": {
                    dependency.optional(interpolatedTrimmed(nextText(parser, strict), "optional"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                dependency.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return dependency.build();
    }

    private Developer parseDeveloper(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Developer.Builder developer = Developer.newBuilder(true);
        if (addLocationInformation) {
            developer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "id": {
                    developer.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "name": {
                    developer.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "email": {
                    developer.email(interpolatedTrimmed(nextText(parser, strict), "email"));
                    break;
                }
                case "url": {
                    developer.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "organization": {
                    developer.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
                    break;
                }
                case "organizationUrl": {
                    developer.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
                    break;
                }
                case "roles": {
                    List roles = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("role".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    developer.roles(roles);
                    break;
                }
                case "timezone": {
                    developer.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
                    break;
                }
                case "properties": {
                    Map properties = new LinkedHashMap<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        String key = parser.getLocalName();
                        String value = nextText(parser, strict).trim();
                        if (addLocationInformation) {
                            locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                        }
                        properties.put(key, value);
                    }
                    developer.properties(properties);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                developer.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return developer.build();
    }

    private Exclusion parseExclusion(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Exclusion.Builder exclusion = Exclusion.newBuilder(true);
        if (addLocationInformation) {
            exclusion.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "groupId": {
                    exclusion.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    exclusion.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                exclusion.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return exclusion.build();
    }

    private IssueManagement parseIssueManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        IssueManagement.Builder issueManagement = IssueManagement.newBuilder(true);
        if (addLocationInformation) {
            issueManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "system": {
                    issueManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
                    break;
                }
                case "url": {
                    issueManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                issueManagement.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return issueManagement.build();
    }

    private DistributionManagement parseDistributionManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        DistributionManagement.Builder distributionManagement = DistributionManagement.newBuilder(true);
        if (addLocationInformation) {
            distributionManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "repository": {
                    distributionManagement.repository(parseDeploymentRepository(parser, strict, source));
                    break;
                }
                case "snapshotRepository": {
                    distributionManagement.snapshotRepository(parseDeploymentRepository(parser, strict, source));
                    break;
                }
                case "site": {
                    distributionManagement.site(parseSite(parser, strict, source));
                    break;
                }
                case "downloadUrl": {
                    distributionManagement.downloadUrl(interpolatedTrimmed(nextText(parser, strict), "downloadUrl"));
                    break;
                }
                case "relocation": {
                    distributionManagement.relocation(parseRelocation(parser, strict, source));
                    break;
                }
                case "status": {
                    distributionManagement.status(interpolatedTrimmed(nextText(parser, strict), "status"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                distributionManagement.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return distributionManagement.build();
    }

    private License parseLicense(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        License.Builder license = License.newBuilder(true);
        if (addLocationInformation) {
            license.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "name": {
                    license.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "url": {
                    license.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "distribution": {
                    license.distribution(interpolatedTrimmed(nextText(parser, strict), "distribution"));
                    break;
                }
                case "comments": {
                    license.comments(interpolatedTrimmed(nextText(parser, strict), "comments"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                license.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return license.build();
    }

    private MailingList parseMailingList(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        MailingList.Builder mailingList = MailingList.newBuilder(true);
        if (addLocationInformation) {
            mailingList.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "name": {
                    mailingList.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "subscribe": {
                    mailingList.subscribe(interpolatedTrimmed(nextText(parser, strict), "subscribe"));
                    break;
                }
                case "unsubscribe": {
                    mailingList.unsubscribe(interpolatedTrimmed(nextText(parser, strict), "unsubscribe"));
                    break;
                }
                case "post": {
                    mailingList.post(interpolatedTrimmed(nextText(parser, strict), "post"));
                    break;
                }
                case "archive": {
                    mailingList.archive(interpolatedTrimmed(nextText(parser, strict), "archive"));
                    break;
                }
                case "otherArchives": {
                    List otherArchives = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("otherArchive".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            otherArchives.add(interpolatedTrimmed(nextText(parser, strict), "otherArchives"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    mailingList.otherArchives(otherArchives);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                mailingList.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return mailingList.build();
    }

    private Organization parseOrganization(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Organization.Builder organization = Organization.newBuilder(true);
        if (addLocationInformation) {
            organization.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "name": {
                    organization.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "url": {
                    organization.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                organization.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return organization.build();
    }

    private PatternSet parsePatternSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        PatternSet.Builder patternSet = PatternSet.newBuilder(true);
        if (addLocationInformation) {
            patternSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "includes": {
                    List includes = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("include".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    patternSet.includes(includes);
                    break;
                }
                case "excludes": {
                    List excludes = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("exclude".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    patternSet.excludes(excludes);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                patternSet.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return patternSet.build();
    }

    private Parent parseParent(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Parent.Builder parent = Parent.newBuilder(true);
        if (addLocationInformation) {
            parent.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "groupId": {
                    parent.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    parent.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                case "version": {
                    parent.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                case "relativePath": {
                    parent.relativePath(interpolatedTrimmed(nextText(parser, strict), "relativePath"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                parent.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return parent.build();
    }

    private Scm parseScm(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Scm.Builder scm = Scm.newBuilder(true);
        if (addLocationInformation) {
            scm.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else if ("child.scm.connection.inherit.append.path".equals(name)) {
                if (addLocationInformation) {
                    scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                }
                scm.childScmConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.connection.inherit.append.path"));
            } else if ("child.scm.developerConnection.inherit.append.path".equals(name)) {
                if (addLocationInformation) {
                    scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                }
                scm.childScmDeveloperConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.developerConnection.inherit.append.path"));
            } else if ("child.scm.url.inherit.append.path".equals(name)) {
                if (addLocationInformation) {
                    scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                }
                scm.childScmUrlInheritAppendPath(interpolatedTrimmed(value, "child.scm.url.inherit.append.path"));
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "connection": {
                    scm.connection(interpolatedTrimmed(nextText(parser, strict), "connection"));
                    break;
                }
                case "developerConnection": {
                    scm.developerConnection(interpolatedTrimmed(nextText(parser, strict), "developerConnection"));
                    break;
                }
                case "tag": {
                    scm.tag(interpolatedTrimmed(nextText(parser, strict), "tag"));
                    break;
                }
                case "url": {
                    scm.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                scm.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return scm.build();
    }

    private FileSet parseFileSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        FileSet.Builder fileSet = FileSet.newBuilder(true);
        if (addLocationInformation) {
            fileSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "directory": {
                    fileSet.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
                    break;
                }
                case "includes": {
                    List includes = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("include".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    fileSet.includes(includes);
                    break;
                }
                case "excludes": {
                    List excludes = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("exclude".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    fileSet.excludes(excludes);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                fileSet.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return fileSet.build();
    }

    private Resource parseResource(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Resource.Builder resource = Resource.newBuilder(true);
        if (addLocationInformation) {
            resource.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "targetPath": {
                    resource.targetPath(interpolatedTrimmed(nextText(parser, strict), "targetPath"));
                    break;
                }
                case "filtering": {
                    resource.filtering(interpolatedTrimmed(nextText(parser, strict), "filtering"));
                    break;
                }
                case "directory": {
                    resource.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
                    break;
                }
                case "includes": {
                    List includes = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("include".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    resource.includes(includes);
                    break;
                }
                case "excludes": {
                    List excludes = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("exclude".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    resource.excludes(excludes);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                resource.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return resource.build();
    }

    private RepositoryBase parseRepositoryBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        RepositoryBase.Builder repositoryBase = RepositoryBase.newBuilder(true);
        if (addLocationInformation) {
            repositoryBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "id": {
                    repositoryBase.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "name": {
                    repositoryBase.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "url": {
                    repositoryBase.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "layout": {
                    repositoryBase.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                repositoryBase.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return repositoryBase.build();
    }

    private Repository parseRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Repository.Builder repository = Repository.newBuilder(true);
        if (addLocationInformation) {
            repository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "releases": {
                    repository.releases(parseRepositoryPolicy(parser, strict, source));
                    break;
                }
                case "snapshots": {
                    repository.snapshots(parseRepositoryPolicy(parser, strict, source));
                    break;
                }
                case "id": {
                    repository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "name": {
                    repository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "url": {
                    repository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "layout": {
                    repository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                repository.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return repository.build();
    }

    private DeploymentRepository parseDeploymentRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        DeploymentRepository.Builder deploymentRepository = DeploymentRepository.newBuilder(true);
        if (addLocationInformation) {
            deploymentRepository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "uniqueVersion": {
                    deploymentRepository.uniqueVersion(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "uniqueVersion"), "uniqueVersion", parser, true));
                    break;
                }
                case "releases": {
                    deploymentRepository.releases(parseRepositoryPolicy(parser, strict, source));
                    break;
                }
                case "snapshots": {
                    deploymentRepository.snapshots(parseRepositoryPolicy(parser, strict, source));
                    break;
                }
                case "id": {
                    deploymentRepository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "name": {
                    deploymentRepository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "url": {
                    deploymentRepository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                case "layout": {
                    deploymentRepository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                deploymentRepository.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return deploymentRepository.build();
    }

    private RepositoryPolicy parseRepositoryPolicy(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        RepositoryPolicy.Builder repositoryPolicy = RepositoryPolicy.newBuilder(true);
        if (addLocationInformation) {
            repositoryPolicy.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "enabled": {
                    repositoryPolicy.enabled(interpolatedTrimmed(nextText(parser, strict), "enabled"));
                    break;
                }
                case "updatePolicy": {
                    repositoryPolicy.updatePolicy(interpolatedTrimmed(nextText(parser, strict), "updatePolicy"));
                    break;
                }
                case "checksumPolicy": {
                    repositoryPolicy.checksumPolicy(interpolatedTrimmed(nextText(parser, strict), "checksumPolicy"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                repositoryPolicy.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return repositoryPolicy.build();
    }

    private Site parseSite(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Site.Builder site = Site.newBuilder(true);
        if (addLocationInformation) {
            site.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else if ("child.site.url.inherit.append.path".equals(name)) {
                if (addLocationInformation) {
                    site.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                }
                site.childSiteUrlInheritAppendPath(interpolatedTrimmed(value, "child.site.url.inherit.append.path"));
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "id": {
                    site.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "name": {
                    site.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "url": {
                    site.url(interpolatedTrimmed(nextText(parser, strict), "url"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                site.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return site.build();
    }

    private ConfigurationContainer parseConfigurationContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        ConfigurationContainer.Builder configurationContainer = ConfigurationContainer.newBuilder(true);
        if (addLocationInformation) {
            configurationContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "inherited": {
                    configurationContainer.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
                    break;
                }
                case "configuration": {
                    configurationContainer.configuration(buildXmlNode(parser, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                configurationContainer.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return configurationContainer.build();
    }

    private Plugin parsePlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Plugin.Builder plugin = Plugin.newBuilder(true);
        if (addLocationInformation) {
            plugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "groupId": {
                    plugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    plugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                case "version": {
                    plugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                case "extensions": {
                    plugin.extensions(interpolatedTrimmed(nextText(parser, strict), "extensions"));
                    break;
                }
                case "executions": {
                    List executions = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("execution".equals(parser.getLocalName())) {
                            executions.add(parsePluginExecution(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    plugin.executions(executions);
                    break;
                }
                case "dependencies": {
                    List dependencies = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("dependency".equals(parser.getLocalName())) {
                            dependencies.add(parseDependency(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    plugin.dependencies(dependencies);
                    break;
                }
                case "inherited": {
                    plugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
                    break;
                }
                case "configuration": {
                    plugin.configuration(buildXmlNode(parser, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                plugin.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return plugin.build();
    }

    private PluginExecution parsePluginExecution(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        PluginExecution.Builder pluginExecution = PluginExecution.newBuilder(true);
        if (addLocationInformation) {
            pluginExecution.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "id": {
                    pluginExecution.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "phase": {
                    pluginExecution.phase(interpolatedTrimmed(nextText(parser, strict), "phase"));
                    break;
                }
                case "priority": {
                    pluginExecution.priority(getIntegerValue(interpolatedTrimmed(nextText(parser, strict), "priority"), "priority", parser, strict, 0));
                    break;
                }
                case "goals": {
                    List goals = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("goal".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            goals.add(interpolatedTrimmed(nextText(parser, strict), "goals"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    pluginExecution.goals(goals);
                    break;
                }
                case "inherited": {
                    pluginExecution.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
                    break;
                }
                case "configuration": {
                    pluginExecution.configuration(buildXmlNode(parser, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                pluginExecution.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return pluginExecution.build();
    }

    private DependencyManagement parseDependencyManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        DependencyManagement.Builder dependencyManagement = DependencyManagement.newBuilder(true);
        if (addLocationInformation) {
            dependencyManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "dependencies": {
                    List dependencies = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("dependency".equals(parser.getLocalName())) {
                            dependencies.add(parseDependency(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    dependencyManagement.dependencies(dependencies);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                dependencyManagement.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return dependencyManagement.build();
    }

    private PluginManagement parsePluginManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        PluginManagement.Builder pluginManagement = PluginManagement.newBuilder(true);
        if (addLocationInformation) {
            pluginManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "plugins": {
                    List plugins = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("plugin".equals(parser.getLocalName())) {
                            plugins.add(parsePlugin(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    pluginManagement.plugins(plugins);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                pluginManagement.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return pluginManagement.build();
    }

    private Reporting parseReporting(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Reporting.Builder reporting = Reporting.newBuilder(true);
        if (addLocationInformation) {
            reporting.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "excludeDefaults": {
                    reporting.excludeDefaults(interpolatedTrimmed(nextText(parser, strict), "excludeDefaults"));
                    break;
                }
                case "outputDirectory": {
                    reporting.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
                    break;
                }
                case "plugins": {
                    List plugins = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("plugin".equals(parser.getLocalName())) {
                            plugins.add(parseReportPlugin(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    reporting.plugins(plugins);
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                reporting.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return reporting.build();
    }

    private Profile parseProfile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Profile.Builder profile = Profile.newBuilder(true);
        if (addLocationInformation) {
            profile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "id": {
                    profile.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "activation": {
                    profile.activation(parseActivation(parser, strict, source));
                    break;
                }
                case "build": {
                    profile.build(parseBuildBase(parser, strict, source));
                    break;
                }
                case "modules": {
                    List modules = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("module".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    profile.modules(modules);
                    break;
                }
                case "distributionManagement": {
                    profile.distributionManagement(parseDistributionManagement(parser, strict, source));
                    break;
                }
                case "properties": {
                    Map properties = new LinkedHashMap<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        String key = parser.getLocalName();
                        String value = nextText(parser, strict).trim();
                        if (addLocationInformation) {
                            locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                        }
                        properties.put(key, value);
                    }
                    profile.properties(properties);
                    break;
                }
                case "dependencyManagement": {
                    profile.dependencyManagement(parseDependencyManagement(parser, strict, source));
                    break;
                }
                case "dependencies": {
                    List dependencies = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("dependency".equals(parser.getLocalName())) {
                            dependencies.add(parseDependency(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    profile.dependencies(dependencies);
                    break;
                }
                case "repositories": {
                    List repositories = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("repository".equals(parser.getLocalName())) {
                            repositories.add(parseRepository(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    profile.repositories(repositories);
                    break;
                }
                case "pluginRepositories": {
                    List pluginRepositories = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("pluginRepository".equals(parser.getLocalName())) {
                            pluginRepositories.add(parseRepository(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    profile.pluginRepositories(pluginRepositories);
                    break;
                }
                case "reporting": {
                    profile.reporting(parseReporting(parser, strict, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                profile.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return profile.build();
    }

    private Activation parseActivation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Activation.Builder activation = Activation.newBuilder(true);
        if (addLocationInformation) {
            activation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "activeByDefault": {
                    activation.activeByDefault(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "activeByDefault"), "activeByDefault", parser, false));
                    break;
                }
                case "jdk": {
                    activation.jdk(interpolatedTrimmed(nextText(parser, strict), "jdk"));
                    break;
                }
                case "os": {
                    activation.os(parseActivationOS(parser, strict, source));
                    break;
                }
                case "property": {
                    activation.property(parseActivationProperty(parser, strict, source));
                    break;
                }
                case "file": {
                    activation.file(parseActivationFile(parser, strict, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                activation.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return activation.build();
    }

    private ActivationProperty parseActivationProperty(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        ActivationProperty.Builder activationProperty = ActivationProperty.newBuilder(true);
        if (addLocationInformation) {
            activationProperty.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "name": {
                    activationProperty.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "value": {
                    activationProperty.value(interpolatedTrimmed(nextText(parser, strict), "value"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                activationProperty.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return activationProperty.build();
    }

    private ActivationOS parseActivationOS(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        ActivationOS.Builder activationOS = ActivationOS.newBuilder(true);
        if (addLocationInformation) {
            activationOS.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "name": {
                    activationOS.name(interpolatedTrimmed(nextText(parser, strict), "name"));
                    break;
                }
                case "family": {
                    activationOS.family(interpolatedTrimmed(nextText(parser, strict), "family"));
                    break;
                }
                case "arch": {
                    activationOS.arch(interpolatedTrimmed(nextText(parser, strict), "arch"));
                    break;
                }
                case "version": {
                    activationOS.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                activationOS.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return activationOS.build();
    }

    private ActivationFile parseActivationFile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        ActivationFile.Builder activationFile = ActivationFile.newBuilder(true);
        if (addLocationInformation) {
            activationFile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "missing": {
                    activationFile.missing(interpolatedTrimmed(nextText(parser, strict), "missing"));
                    break;
                }
                case "exists": {
                    activationFile.exists(interpolatedTrimmed(nextText(parser, strict), "exists"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                activationFile.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return activationFile.build();
    }

    private ReportPlugin parseReportPlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        ReportPlugin.Builder reportPlugin = ReportPlugin.newBuilder(true);
        if (addLocationInformation) {
            reportPlugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "groupId": {
                    reportPlugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    reportPlugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                case "version": {
                    reportPlugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                case "reportSets": {
                    List reportSets = new ArrayList<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("reportSet".equals(parser.getLocalName())) {
                            reportSets.add(parseReportSet(parser, strict, source));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    reportPlugin.reportSets(reportSets);
                    break;
                }
                case "inherited": {
                    reportPlugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
                    break;
                }
                case "configuration": {
                    reportPlugin.configuration(buildXmlNode(parser, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                reportPlugin.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return reportPlugin.build();
    }

    private ReportSet parseReportSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        ReportSet.Builder reportSet = ReportSet.newBuilder(true);
        if (addLocationInformation) {
            reportSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "id": {
                    reportSet.id(interpolatedTrimmed(nextText(parser, strict), "id"));
                    break;
                }
                case "reports": {
                    List reports = new ArrayList<>();
                    locations = new HashMap<>();
                    while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
                        if ("report".equals(parser.getLocalName())) {
                            if (addLocationInformation) {
                                locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
                            }
                            reports.add(interpolatedTrimmed(nextText(parser, strict), "reports"));
                        } else {
                            checkUnknownElement(parser, strict);
                        }
                    }
                    reportSet.reports(reports);
                    break;
                }
                case "inherited": {
                    reportSet.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
                    break;
                }
                case "configuration": {
                    reportSet.configuration(buildXmlNode(parser, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                reportSet.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return reportSet.build();
    }

    private Prerequisites parsePrerequisites(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Prerequisites.Builder prerequisites = Prerequisites.newBuilder(true);
        if (addLocationInformation) {
            prerequisites.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "maven": {
                    prerequisites.maven(interpolatedTrimmed(nextText(parser, strict), "maven"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                prerequisites.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return prerequisites.build();
    }

    private Relocation parseRelocation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Relocation.Builder relocation = Relocation.newBuilder(true);
        if (addLocationInformation) {
            relocation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "groupId": {
                    relocation.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    relocation.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                case "version": {
                    relocation.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                case "message": {
                    relocation.message(interpolatedTrimmed(nextText(parser, strict), "message"));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                relocation.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return relocation.build();
    }

    private Extension parseExtension(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
        String tagName = parser.getLocalName();
        Extension.Builder extension = Extension.newBuilder(true);
        if (addLocationInformation) {
            extension.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
        }
        for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
            String name = parser.getAttributeLocalName(i);
            String ns = parser.getAttributeNamespace(i);
            String value = parser.getAttributeValue(i);
            if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
                // just ignore attributes with non-default namespace (for example: xsi and xml)
            } else {
                checkUnknownAttribute(parser, name, tagName, strict);
            }
        }
        Set parsed = new HashSet<>();
        while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
            String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
            int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
            int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
            Map locations = null;
            switch (childName) {
                case "groupId": {
                    extension.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
                    break;
                }
                case "artifactId": {
                    extension.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
                    break;
                }
                case "version": {
                    extension.version(interpolatedTrimmed(nextText(parser, strict), "version"));
                    break;
                }
                case "configuration": {
                    extension.configuration(buildXmlNode(parser, source));
                    break;
                }
                default: {
                    checkUnknownElement(parser, strict);
                    break;
                }
            }
            if (addLocationInformation) {
                extension.location(childName, new InputLocation(line, column, source, locations));
            }
        }
        return extension.build();
    }


    private String checkDuplicate(String tagName, XMLStreamReader parser, Set parsed) throws XMLStreamException {
        switch (tagName) {
        case "organisation":
            tagName = "organization";
            break;
        case "organisationUrl":
            tagName = "organizationUrl";
            break;
        }
        if (!parsed.add(tagName)) {
            throw new XMLStreamException("Duplicated tag: '" + tagName + "'", parser.getLocation(), null);
        }
        return tagName;
    }

    /**
     * Method checkUnknownAttribute.
     *
     * @param parser a parser object.
     * @param strict a strict object.
     * @param tagName a tagName object.
     * @param attribute a attribute object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @throws IOException IOException if any.
     */
    private void checkUnknownAttribute(XMLStreamReader parser, String attribute, String tagName, boolean strict) throws XMLStreamException {
        // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
        if (strict) {
            throw new XMLStreamException("Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser.getLocation(), null);
        }
    } //-- void checkUnknownAttribute(XMLStreamReader, String, String, boolean)

    /**
     * Method checkUnknownElement.
     *
     * @param parser a parser object.
     * @param strict a strict object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @throws IOException IOException if any.
     */
    private void checkUnknownElement(XMLStreamReader parser, boolean strict) throws XMLStreamException {
        if (strict) {
            throw new XMLStreamException("Unrecognised tag: '" + parser.getName() + "'", parser.getLocation(), null);
        }

        for (int unrecognizedTagCount = 1; unrecognizedTagCount > 0;) {
            int eventType = nextTag(parser);
            if (eventType == XMLStreamReader.START_ELEMENT) {
                unrecognizedTagCount++;
            } else if (eventType == XMLStreamReader.END_ELEMENT) {
                unrecognizedTagCount--;
            }
        }
    } //-- void checkUnknownElement(XMLStreamReader, boolean)

    /**
     * Method getTrimmedValue.
     *
     * @param s a s object.
     * @return String
     */
    private String getTrimmedValue(String s) {
        if (s != null) {
            s = s.trim();
        }
        return s;
    } //-- String getTrimmedValue(String)

    /**
     * Method interpolatedTrimmed.
     *
     * @param value a value object.
     * @param context a context object.
     * @return String
     */
    private String interpolatedTrimmed(String value, String context) {
        return getTrimmedValue(contentTransformer.transform(value, context));
    } //-- String interpolatedTrimmed(String, String)

    /**
     * Method nextTag.
     *
     * @param parser a parser object.
     * @throws IOException IOException if any.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return int
     */
    private int nextTag(XMLStreamReader parser) throws XMLStreamException {
        while (true) {
            int next = parser.next();
            switch (next) {
                case XMLStreamReader.SPACE:
                case XMLStreamReader.COMMENT:
                case XMLStreamReader.PROCESSING_INSTRUCTION:
                case XMLStreamReader.CDATA:
                case XMLStreamReader.CHARACTERS:
                    continue;
                case XMLStreamReader.START_ELEMENT:
                case XMLStreamReader.END_ELEMENT:
                    return next;
            }
        }
    } //-- int nextTag(XMLStreamReader)

    private String nextText(XMLStreamReader parser, boolean strict) throws XMLStreamException {
        int eventType = parser.getEventType();
        if (eventType != XMLStreamReader.START_ELEMENT) {
            throw new XMLStreamException("parser must be on START_ELEMENT to read next text", parser.getLocation(), null);
        }
        eventType = parser.next();
        StringBuilder result = new StringBuilder();
        while (true) {
            if (eventType == XMLStreamReader.CHARACTERS || eventType == XMLStreamReader.CDATA) {
                result.append(parser.getText());
            } else if (eventType == XMLStreamReader.ENTITY_REFERENCE) {
                String val = null;
                if (strict) {
                    throw new XMLStreamException("Entities are not supported in strict mode", parser.getLocation(), null);
                } else if (addDefaultEntities) {
                    val = DEFAULT_ENTITIES.get(parser.getLocalName());
                }
                if (val != null) {
                    result.append(val);
                } else {
                    result.append("&").append(parser.getLocalName()).append(";");
                }
            } else if (eventType != XMLStreamReader.COMMENT) {
                break;
            }
            eventType = parser.next();
        }
        if (eventType != XMLStreamReader.END_ELEMENT) {
            throw new XMLStreamException(
                "TEXT must be immediately followed by END_ELEMENT and not " + eventType /*TODO: TYPES[eventType]*/, parser.getLocation(), null);
        }
        return result.toString();
    }

    private XmlNode buildXmlNode(XMLStreamReader parser, InputSource source) throws XMLStreamException {
        return XmlNodeBuilder.build(parser,
                addLocationInformation
                        ? p -> new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source)
                        : null);
    }

    /**
     * Method getBooleanValue.
     *
     * @param s a s object.
     * @param defaultValue a defaultValue object.
     * @param parser a parser object.
     * @param attribute a attribute object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return boolean
     */
    private boolean getBooleanValue(String s, String attribute, XMLStreamReader parser, boolean defaultValue) throws XMLStreamException {
        if (s != null && s.length() != 0) {
            return Boolean.valueOf(s).booleanValue();
        }
        return defaultValue;
    } //-- boolean getBooleanValue(String, String, XMLStreamReader, String)

    /**
     * Method getIntegerValue.
     *
     * @param s a s object.
     * @param strict a strict object.
     * @param parser a parser object.
     * @param attribute a attribute object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return int
     */
    private int getIntegerValue(String s, String attribute, XMLStreamReader parser, boolean strict, int defaultValue) throws XMLStreamException {
        if (s != null) {
            try {
                return Integer.valueOf(s).intValue();
            } catch (NumberFormatException nfe) {
                if (strict) {
                    throw new XMLStreamException("Unable to parse element '" + attribute + "', must be an integer", parser.getLocation(), nfe);
                }
            }
        }
        return defaultValue;
    } //-- int getIntegerValue(String, String, XMLStreamReader, boolean)

    public static interface ContentTransformer {
        /**
         * Interpolate the value read from the xpp3 document
         * @param source The source value
         * @param fieldName A description of the field being interpolated. The implementation may use this to
         *                           log stuff.
         * @return The interpolated value.
         */
        String transform(String source, String fieldName);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy