Module ilusr.core

Class XmlGenerator


  • public class XmlGenerator
    extends Object
    Author:
    Jeff Riggle This class provides a simple wrapper around the xml document class. This allows the user to write data to a xml document and save it later.
    • Method Detail

      • document

        public void document​(Document document)
        Parameters:
        document - The new document to generate on.
      • document

        public Document document()
        Returns:
        The document associated with this generator.
      • addElementToRoot

        public void addElementToRoot​(Element value)
        Parameters:
        value - The element to add to the root of this document.
      • removeElementFromRoot

        public void removeElementFromRoot​(Element value)
        Parameters:
        value - The element to remove from the root of this document.
      • addChildToElement

        public void addChildToElement​(Element parent,
                                      Element child)
        Parameters:
        parent - The parent element.
        child - The element you would like to add to this parent.
      • removeChildFromElement

        public void removeChildFromElement​(Element parent,
                                           Element child)
        Parameters:
        parent - The parent element.
        child - The elment you would like to remove from this parent.
      • addAttributeToElement

        public void addAttributeToElement​(Element parent,
                                          String name,
                                          String value)
        Parameters:
        parent - The element you would like to add an attribute to.
        name - The name of the attribute
        value - The value of the attribute.
      • removeAttributeFromElement

        public void removeAttributeFromElement​(Element parent,
                                               String name)
        Parameters:
        parent - The element you would like to remove an attribute from.
        name - The name of the attribute you would like to remove.
      • addNodeToElement

        public Node addNodeToElement​(Element parent,
                                     String data)
        Parameters:
        parent - The element you would like to add this node data to.
        data - The data to insert into the node.
        Returns:
        The node that has been created.
      • removeNodeFromElement

        public void removeNodeFromElement​(Element parent,
                                          Node value)
        Parameters:
        parent - The element you would like to remove a node from.
        value - The node to remove.
      • createElement

        public Element createElement​(String id)
        Parameters:
        id - The String identifier for this element.
        Returns:
        The element that has been created.
      • saveToFile

        public void saveToFile​(String fileLocation)
                        throws TransformerException
        Parameters:
        fileLocation - The file location to save this xml, should include file name.
        Throws:
        TransformerException - When the generated xml cannot be transformed.