/** * Adds a property to the composite parsed from the XML source. * * @param name the property name * @param source the XML source * @return the builder * @throws ModelBuilderException if an error reading the source occurs */ public CompositeBuilder property(String name, URL source) { checkState(); try { Document document = DOCUMENT_FACTORY.newDocumentBuilder().parse(source.openStream()); // all properties have a root <values> element, append the existing root to it. The existing root will be taken as a property <value>. Element oldRoot = document.getDocumentElement(); Element newRoot = document.createElement("values"); document.removeChild(oldRoot); document.appendChild(newRoot); newRoot.appendChild(oldRoot); Property property = new Property(name); property.setDefaultValue(document); composite.add(property); } catch (IOException | ParserConfigurationException | SAXException e) { throw new ModelBuilderException(e); } return this; }