Class XMLwriter

java.lang.Object
org.ampere.base.xml.XMLwriter

public class XMLwriter extends Object
simple XML writer
Author:
herve
  • Field Details

  • Constructor Details

    • XMLwriter

      public XMLwriter(File file)
      Creates a new instance of XMLwriter
      Parameters:
      file - output file
  • Method Details

    • writeName

      protected void writeName(String name)
      Write a name with its possible name space
      Parameters:
      name - name to be written
    • writeTag

      public void writeTag(String tag, boolean closing)
      Write a simple tag, i.e. <tag>
      Parameters:
      tag - value of the tag to be written
    • writeHeader

      public void writeHeader(boolean standalone)
      write the header of the XML file
      Parameters:
      standalone - flag specifying that the XML file is standalone or not
    • writePublicDocType

      public void writePublicDocType(String type, String resource, String system)
      Write a public doctype with a DTD reference
      Parameters:
      type - document type
      resource - associated resource
      system - associated system
    • writeDoctype

      public void writeDoctype(String doctype)
    • writeRootElement

      public void writeRootElement(String name, String xsdFile)
    • openElement

      public void openElement(String name, boolean closed, boolean newline)
      Write a simple element
      Parameters:
      name - element name
      closed - flag specifying if the element tag has to be closed or not.
      newline - flag specifying if the writing is finished by a new line or not.
    • openElement

      public void openElement(String name, boolean closed)
      Write a simple element ended by a newline
      Parameters:
      name - element name
      closed - flag specifying if the element tag has to be closed or not.
    • openElement

      public void openElement(String name)
      Write a simple element
      Parameters:
      name - element name
    • closeMark

      public void closeMark(boolean newLine)
      Close an element, i.e. write the the mark ">"
      Parameters:
      newLine - flag specifying if a new line has to be printed or not
    • closeMark

      public void closeMark()
      Close an element, i.e. write the the mark ">" and then print a new line.
    • printElement

      public void printElement(String elementTag, String value)
      print a one line element with a string value
      Parameters:
      elementTag - tag of the element
      value - associated value
    • writenl

      public void writenl()
      Print a new line.
    • writeCDATA

      public void writeCDATA(String code)
      Write a simple content
      Parameters:
      code - data to be written
    • writeText

      public void writeText(String code)
      write a simple text
    • writeTextElement

      public void writeTextElement(String tag, String text)
      write a simple text as a tag
      Parameters:
      tag - associated tag
      text - input text
    • writeAttribute

      public void writeAttribute(String name, String value)
      write a string attribute
    • writeAttribute

      public void writeAttribute(String name, double value)
      Write a double attribute. The double format of the writer is used.
      Parameters:
      name - attribute name
      value - double value
    • writeAttribute

      public void writeAttribute(String name, int value)
      Write a integrer attribute
      Parameters:
      name - attribute name
      value - integer value
    • writeAttribute

      public void writeAttribute(String name, boolean value)
      write a boolean attribute
    • closeElement

      public void closeElement(String element, boolean newLine)
      Close an element, i.e. write in the XML document </element>
      Parameters:
      element - name of the element
      newLine - flag specifying is a new line is printed or not
    • closeElement

      public void closeElement(String element)
      Close an element, i.e. write in the XML document </element> and print a new line.
      Parameters:
      element - name of the element
    • closeDeclaration

      public void closeDeclaration(boolean newLine)
    • closeElement

      public void closeElement(boolean newLine)
      close an element
      Parameters:
      newLine - flag specifying if a new line has to be printed or not.
    • closeElement

      public void closeElement()
      close an element and print an new line.
    • close

      public void close()
      close the XML file
    • buildXMLtextValue

      public static String buildXMLtextValue(String input)
      build an XML text value by removing any special characters.
      Parameters:
      input - input string