public static void update(final Ivy ivy, URL srcURL, File destFile, final Map resolvedRevisions, final String status, final String revision, final Date pubdate, final Namespace ns, final boolean replaceInclude)
public static void update(URL srcURL, File destFile, final Map resolvedRevisions, final String status, final String revision, final Date pubdate)
    public static void update(final Ivy ivy, URL srcURL, File destFile, final Map resolvedRevisions, final String status,             final String revision, final Date pubdate, final Namespace ns, final boolean replaceInclude)                                 throws IOException, SAXException {        if (destFile.getParentFile() != null) {            destFile.getParentFile().mkdirs();        }        FileOutputStream fos = null;        try {            fos = new FileOutputStream(destFile);            final PrintWriter out = new PrintWriter(fos);            copyHeader(srcURL, out);                        XMLHelper.parse(srcURL, null, new DefaultHandler() {                // never print *ln* cause \n is found in copied characters stream                // nor do we need do handle indentation, original one is maintained except for attributes                                private String _organisation = null;                private String _defaultConfMapping = null; // defaultConfMapping of imported configurations, if any                private String _justOpen = null; // used to know if the last open tag was empty, to adjust termination with /> instead of ></qName>                private Stack _context = new Stack();                public void startElement(String uri, String localName,                        String qName, Attributes attributes)                        throws SAXException {                    if (_justOpen != null) {                        out.print(">");                    }                    _context.push(qName);                    if ("info".equals(qName)) {                        _organisation = substitute(ivy, attributes.getValue("organisation"));                        out.print("<info organisation=\""+_organisation                                				+"\" module=\""+substitute(ivy, attributes.getValue("module"))+"\"");                        if (revision != null) {                            out.print(" revision=\""+revision+"\"");                        } else if (attributes.getValue("revision") != null) {                            out.print(" revision=\""+substitute(ivy, attributes.getValue("revision"))+"\"");                        }                        if (status != null) {                            out.print(" status=\""+status+"\"");                        } else {                            out.print(" status=\""+substitute(ivy, attributes.getValue("status"))+"\"");                        }                        if (pubdate != null) {                            out.print(" publication=\""+Ivy.DATE_FORMAT.format(pubdate)+"\"");                        } else if (attributes.getValue("publication") != null) {                            out.print(" publication=\""+substitute(ivy, attributes.getValue("publication"))+"\"");                        }                        if (attributes.getValue("namespace") != null) {                            out.print(" namespace=\""+substitute(ivy, attributes.getValue("namespace"))+"\"");                        }                    } else if (replaceInclude && "include".equals(qName) && _context.contains("configurations")) {                        try {                            URL url;                            String fileName = substitute(ivy, attributes.getValue("file"));                            if (fileName == null) {                                String urlStr = substitute(ivy, attributes.getValue("url"));                                url = new URL(urlStr);                            } else {                                url = new File(fileName).toURL();                            }                                 XMLHelper.parse(url, null, new DefaultHandler() {                                boolean _first = true;                                public void startElement(String uri, String localName,                                        String qName, Attributes attributes)                                        throws SAXException {                                    if ("configurations".equals(qName)) {                                        String defaultconf = substitute(ivy, attributes.getValue("defaultconfmapping"));                                        if (defaultconf != null) {                                            _defaultConfMapping = defaultconf;                                        }                                    } else if ("conf".equals(qName)) {                                        // copy                                        if (!_first) {                                            out.print("/>\n\t\t");                                        } else {                                            _first = false;                                        }                                        out.print("<"+qName);                                        for (int i=0; i<attributes.getLength(); i++) {                                            out.print(" "+attributes.getQName(i)+"=\""+substitute(ivy, attributes.getValue(i))+"\"");                                        }                                    }                                }                            });                        } catch (Exception e) {                            Message.warn("exception occured while importing configurations: "+e.getMessage());                            throw new SAXException(e);                        }                    } else if ("dependency".equals(qName)) {                        out.print("<dependency");                        String org = substitute(ivy, attributes.getValue("org"));                        org = org == null ? _organisation : org;                        String module = substitute(ivy, attributes.getValue("name"));                        String revision = substitute(ivy, attributes.getValue("rev"));                        ModuleRevisionId localMid = ModuleRevisionId.newInstance(org, module, revision);                        ModuleRevisionId systemMid = ns == null ?                                 localMid :                                 ns.getToSystemTransformer().transform(localMid);                                                for (int i=0; i<attributes.getLength(); i++) {                            String attName = attributes.getQName(i);                            if ("rev".equals(attName)) {                                String rev = (String)resolvedRevisions.get(systemMid);                                if (rev != null) {                                    out.print(" rev=\""+rev+"\"");                                } else {                                    out.print(" rev=\""+systemMid.getRevision()+"\"");                                }                            } else if ("org".equals(attName)) {                                out.print(" org=\""+systemMid.getOrganisation()+"\"");                            } else if ("name".equals(attName)) {                                out.print(" name=\""+systemMid.getName()+"\"");                            } else {                                out.print(" "+attName+"=\""+substitute(ivy, attributes.getValue(attName))+"\"");                            }                        }                    } else if ("dependencies".equals(qName)) {                        // copy                        out.print("<"+qName);                        for (int i=0; i<attributes.getLength(); i++) {                            out.print(" "+attributes.getQName(i)+"=\""+substitute(ivy, attributes.getValue(i))+"\"");                        }                        // add default conf mapping if needed                        if (_defaultConfMapping != null && attributes.getValue("defaultconfmapping") == null) {                            out.print(" defaultconfmapping=\""+_defaultConfMapping+"\"");                        }                    } else {                        // copy                        out.print("<"+qName);                        for (int i=0; i<attributes.getLength(); i++) {                            out.print(" "+attributes.getQName(i)+"=\""+substitute(ivy, attributes.getValue(i))+"\"");                        }                    }                    _justOpen = qName;//                    indent.append("\t");                }                private String substitute(Ivy ivy, String value) {                    return ivy == null ? value : ivy.substitute(value);                }                public void characters(char[] ch, int start, int length)                        throws SAXException {                    if (_justOpen != null) {                        out.print(">");                         _justOpen = null;                    }                    for (int i = start; i < start + length; i++) {                        out.print(ch[i]);                    }                }                public void endElement(String uri, String localName,                        String qName) throws SAXException {                    if (qName.equals(_justOpen)) {                        out.print("/>");                    } else {                        out.print("</"+qName+">");                    }                    _justOpen = null;                    _context.pop();                }                public void endDocument() throws SAXException {                    out.print(LINE_SEPARATOR);                    out.flush();                    out.close();                }                                public void warning(SAXParseException e) throws SAXException {                    throw e;                }                public void error(SAXParseException e) throws SAXException {                    throw e;                }                public void fatalError(SAXParseException e) throws SAXException {                    throw e;                }            }, new LexicalHandler() {				public void endCDATA() throws SAXException {				}				public void endDTD() throws SAXException {				}				public void startCDATA() throws SAXException {				}				public void comment(char[] ch, int start, int length) throws SAXException {					StringBuffer comment = new StringBuffer();					comment.append(ch, start, length);					out.print("<!--");					out.print(comment.toString());					out.print("-->");				}				public void endEntity(String name) throws SAXException {				}				public void startEntity(String name) throws SAXException {				}				public void startDTD(String name, String publicId, String systemId) throws SAXException {				}            });        } catch (IOException ex) {            throw ex;        } catch (ParserConfigurationException e) {            IllegalStateException ise = new IllegalStateException("impossible to update "+srcURL+": parser problem");            ise.initCause(e);            throw ise;        } finally {            if (fos != null) {                try {                    fos.close();                } catch (IOException e) {                }            }        }    }