public void startElement()

in src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java [281:419]


        public void startElement(String uri, String localName, String qName, Attributes attributes)
                throws SAXException {
            inHeader = false;
            endIndent();
            if (justOpen != null) {
                write(">");
            }

            flushMergedElementsBefore(qName);

            // according to ivy.xsd, all <dependency> elements must occur before
            // the <exclude>, <override> or <conflict> elements
            if (options.isMerge()
                    && ("exclude".equals(localName) || "override".equals(localName) || "conflict"
                            .equals(localName)) && "ivy-module/dependencies".equals(getContext())) {
                ModuleDescriptor merged = options.getMergedDescriptor();
                writeInheritedDependencies(merged);
                out.println();
                out.print(getIndent());
            }

            context.push(qName);

            String path = getContext();
            if ("info".equals(qName)) {
                infoStarted(attributes);
            } else if (replaceInclude && "include".equals(qName)
                    && context.contains("configurations")) {
                // TODO, in the case of !replaceInclude, we should still replace the relative path
                // by an absolute path.
                includeStarted(attributes);
            } else if ("ivy-module/info/extends".equals(path)) {
                if (options.isMerge()) {
                    ModuleDescriptor mergedDescriptor = options.getMergedDescriptor();
                    for (ExtendsDescriptor inheritedDescriptor : mergedDescriptor.getInheritedDescriptors()) {
                        ModuleDescriptor rprid = inheritedDescriptor.getParentMd();
                        if (rprid instanceof DefaultModuleDescriptor) {
                            DefaultModuleDescriptor defaultModuleDescriptor = (DefaultModuleDescriptor) rprid;
                            if (defaultModuleDescriptor.getDefaultConf() != null) {
                                defaultConf = defaultModuleDescriptor.getDefaultConf();
                            }
                            if (defaultModuleDescriptor.getDefaultConfMapping() != null) {
                                defaultConfMapping = defaultModuleDescriptor.getDefaultConfMapping();
                            }
                            if (defaultModuleDescriptor.isMappingOverride()) {
                                confMappingOverride = Boolean.TRUE;
                            }
                        }
                    }
                }
                startExtends(attributes);
            } else if ("ivy-module/dependencies/dependency".equals(path)) {
                startElementInDependency(attributes);
            } else if ("ivy-module/configurations/conf".equals(path)) {
                startElementInConfigurationsConf(qName, attributes);
            } else if ("dependencies".equals(qName) || "configurations".equals(qName)) {
                startElementWithConfAttributes(qName, attributes);
            } else if ("ivy-module/publications/artifact/conf".equals(path)
                    || "ivy-module/dependencies/dependency/conf".equals(path)
                    || "ivy-module/dependencies/dependency/artifact/conf".equals(path)) {
                buffers.push(new ExtendedBuffer(getContext()));
                confAttributeBuffers.peek().setDefaultPrint(false);
                String confName = substitute(settings, attributes.getValue("name"));
                if (!confs.contains(confName)) {
                    confAttributeBuffers.peek().setPrint(true);
                    buffers.peek().setPrint(true);
                    write("<" + qName);
                    for (int i = 0; i < attributes.getLength(); i++) {
                        write(" " + attributes.getQName(i) + "=\""
                                + substitute(settings, attributes.getValue(i)) + "\"");
                    }
                }
            } else if ("ivy-module/publications/artifact".equals(path)) {
                ExtendedBuffer buffer = new ExtendedBuffer(getContext());
                buffers.push(buffer);
                confAttributeBuffers.push(buffer);
                write("<" + qName);
                buffer.setDefaultPrint(attributes.getValue("conf") == null
                        && (newDefaultConf == null || !newDefaultConf.isEmpty()));
                for (int i = 0; i < attributes.getLength(); i++) {
                    String attName = attributes.getQName(i);
                    if ("conf".equals(attName)) {
                        String confName = substitute(settings, attributes.getValue("conf"));
                        String newConf = removeConfigurationsFromList(confName);
                        if (!newConf.isEmpty()) {
                            write(" " + attName + "=\"" + newConf + "\"");
                            buffers.peek().setPrint(true);
                        }
                    } else {
                        write(" " + attName + "=\""
                                + substitute(settings, attributes.getValue(i)) + "\"");
                    }
                }
            } else if ("ivy-module/dependencies/dependency/artifact".equals(path)) {
                ExtendedBuffer buffer = new ExtendedBuffer(getContext());
                buffers.push(buffer);
                confAttributeBuffers.push(buffer);
                write("<" + qName);
                buffer.setDefaultPrint(attributes.getValue("conf") == null);
                for (int i = 0; i < attributes.getLength(); i++) {
                    String attName = attributes.getQName(i);
                    if ("conf".equals(attName)) {
                        String confName = substitute(settings, attributes.getValue("conf"));
                        String newConf = removeConfigurationsFromList(confName);
                        if (!newConf.isEmpty()) {
                            write(" " + attName + "=\"" + newConf + "\"");
                            buffers.peek().setPrint(true);
                        }
                    } else {
                        write(" " + attName + "=\""
                                + substitute(settings, attributes.getValue(i)) + "\"");
                    }
                }
            } else if ("ivy-module/publications".equals(path)) {
                startPublications(attributes);
            } else {
                if (options.isMerge() && path.startsWith("ivy-module/info")) {
                    ModuleDescriptor merged = options.getMergedDescriptor();
                    if (path.equals("ivy-module/info/description")) {
                        // if the descriptor already contains a description, don't bother printing
                        // the merged version.
                        hasDescription = true;
                    } else if (!INFO_ELEMENTS.contains(qName)) {
                        // according to the XSD, we should write description after all of the other
                        // standard <info> elements but before any extended elements.
                        writeInheritedDescription(merged);
                    }
                }

                // copy
                write("<" + qName);
                for (int i = 0; i < attributes.getLength(); i++) {
                    write(" " + attributes.getQName(i) + "=\""
                            + substitute(settings, attributes.getValue(i)) + "\"");
                }
            }
            justOpen = qName;
            // indent.append("\t");
        }