Class XMLUtils

java.lang.Object
org.apache.cocoon.xml.XMLUtils
org.ametys.core.util.XMLUtils
All Implemented Interfaces:
LogEnabled, Component, Serviceable

public class XMLUtils extends XMLUtils implements Component, Serviceable, LogEnabled
Component with XML utils methods
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • getLogger

      protected Logger getLogger()
      Returns the Logger.
      Returns:
      the Logger.
    • setLogger

      public void setLogger(Logger logger)
      Description copied from interface: LogEnabled
      Called at creation time to provide a Logger.
      Specified by:
      setLogger in interface LogEnabled
      Parameters:
      logger - a Logger for messages.
    • createI18nElementIfNotNull

      public static void createI18nElementIfNotNull(ContentHandler contentHandler, String localName, I18nizable i18n) throws SAXException
      Create a start and endElement with a empty Namespace and without Attributes with the given I18nizable If the I18nizable is null, the element is not created
      Parameters:
      contentHandler - the ContentHandler that will receive the SAX events
      localName - The local name (without prefix)
      i18n - the I18nizable to SAX
      Throws:
      SAXException - if an error occurs during the SAX events generation
    • createElementIfNotNull

      public static void createElementIfNotNull(ContentHandler contentHandler, String localName, String stringValue) throws SAXException
      Create a start and endElement with a empty Namespace and without Attributes If the string value is null, the element is not created
      Parameters:
      contentHandler - the ContentHandler that will receive the SAX events
      localName - The local name (without prefix)
      stringValue - The content of the Element
      Throws:
      SAXException - if an error occurs during the SAX events generation
    • createElementIfNotNull

      public static void createElementIfNotNull(ContentHandler contentHandler, String localName, String stringValue, Attributes attributes) throws SAXException
      Create a start and endElement with a empty Namespace and without Attributes If the string value is null, the element is not created
      Parameters:
      contentHandler - the ContentHandler that will receive the SAX events
      localName - The local name (without prefix)
      stringValue - The content of the Element
      attributes - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
      Throws:
      SAXException - if an error occurs during the SAX events generation
    • toString

      Get a XML as a string and extract the text only
      Parameters:
      is - The inputstream of XML
      Returns:
      The text or null if the XML is not well formed