Interface XmlFileBuilder

  • All Known Implementing Classes:

    public interface XmlFileBuilder
    This interface intends to remove hard-bindings to a specific xml api. Implementations of this interface will: 1. optionally load a file 2. insert some elements into the current document 3. write the file to disk
    • Method Detail

      • setFile

        void setFile​(String path)
        sets the name of the file we will read and write.
        path - - where the xml file will be read from or written to.
      • setNamespaces

        void setNamespaces​(Map<String,​String> namespaces)
        assign prefix to namespace mappings used for xpath and other xml operations. Leave alone, or set to null, if you have no namespaces.
        namespaces - - key is prefix value is url
      • loadFile

        Document loadFile()
        load the current xml file into a Document.
        loaded file, represented as a Document.
      • insertElementsUnderXPath

        void insertElementsUnderXPath​(String elementsToParse,
                                      String xpath)
        this will parse one or more elements from elementToParse and insert them under the xpath. note: elementsToParse may not be well formed, but only in one way. The elements may be missing a parent. Example: the following is acceptable by this method elementsToParse = <child1 /> <child2 /> xpath = //parent In this case, both elements child1 and child2 would be placed under the first match for parent. s
        elementsToParse - String containing one or more elements in textual format
        xpath - where to place the above elements.
      • insertElementUnderXPath

        void insertElementUnderXPath​(Element elementToInsert,
                                     String xpath)
        This will take element from elementToInsert and insert it under the xpath.
        elementToInsert - Element to insert
        xpath - where to place the above element.
      • writeFile

        void writeFile()
        write the current xml to disk.