Package com.isomorphic.xml

# Class XML

java.lang.Object
com.isomorphic.base.Base
com.isomorphic.xml.XML

All Implemented Interfaces:
  `com.isomorphic.base.IAutoConfigurable`

public class XML extends com.isomorphic.base.Base
Provides programmatic access to the SmartClient XML processor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `recordToXML(String tagName, Map record, DataSource ds, Writer out)`
  Takes a Map and serializes it into XML based on the declarations in the DataSource similar to the client-side API Datasource.xmlSerialize().
  `static void`
  `recordToXML(String tagName, Map record, Writer out)`
  Takes a Map and serializes it into XML.
  `static void`
  `recordToXML(String tagName, Map record, Writer out, boolean useAttributes, DSRequest dsRequest)`
  Takes a Map and serializes it into XML based on the declarations in the DataSource similar to the client-side API Datasource.xmlSerialize().
  `static void`
  `recordToXML(String tagName, Map record, Writer out, DSRequest dsRequest)`
  Takes a Map and serializes it into XML.
  `static ValidationContext`
  `toJS(Reader reader, Locale locale, Writer out)`
  Converts XML read from the provided Reader to JavaScript and writes it to the supplied Writer.
  `static ValidationContext`
  `toJS(String xml, Writer out)`
  Converts an XML string to JavaScript and writes it to the supplied Writer.
  `static ValidationContext`
  `toJS(String xml, Locale locale, Writer out)`
  Converts an XML string to JavaScript, using the passed-in Locale to resolve any `<fmt:message>` i18n tags, and writes it to the supplied Writer.
  `static ValidationContext`
  `toJS(Element element, Writer out)`
  Converts XML from the passed Element object to JavaScript and writes it to the supplied Writer.

- ## Method Details

  - ### toJS

    public static ValidationContext toJS(String xml, Writer out) throws Exception
    Converts an XML string to JavaScript and writes it to the supplied Writer.

    XML.toJS(String) and XML.toJS(Reader) use the XML->JS translation supported by JSTranslater.toJS(), including translation of XML to live SmartClient components. These are convenience methods that assume the inbound String or Reader contains XML.

    Parameters:
      `xml` - xml string
      `out` - writer where the generated JS output should be written
    Throws:
      `Exception`
    See Also:
      - `JSTranslater.toJS(Object, Writer)`

  - ### toJS

    public static ValidationContext toJS(String xml, Locale locale, Writer out) throws Exception
    Converts an XML string to JavaScript, using the passed-in Locale to resolve any `<fmt:message>` i18n tags, and writes it to the supplied Writer.

    XML.toJS(String) and XML.toJS(Reader) use the XML->JS translation supported by JSTranslater.toJS(), including translation of XML to live SmartClient components. These are convenience methods that assume the inbound String or Reader contains XML.

    Parameters:
      `xml` - xml string
      `locale` - Locale object to use for resolving i18n tags in the supplied XML
      `out` - writer where the generated JS output should be written
    Throws:
      `Exception`
    See Also:
      - `JSTranslater.toJS(Object, Writer)`

  - ### toJS

    public static ValidationContext toJS(Reader reader, Locale locale, Writer out) throws Exception
    Converts XML read from the provided Reader to JavaScript and writes it to the supplied Writer.
    Parameters:
      `reader` - reader containing xml
      `locale` - Locale to use when resolving any i18n tags in the supplied XML
      `out` - writer where the generated JS output should be written
    Throws:
      `Exception`

  - ### toJS

    public static ValidationContext toJS(Element element, Writer out) throws Exception
    Converts XML from the passed Element object to JavaScript and writes it to the supplied Writer.
    Parameters:
      `element` - xml element to be converted
      `out` - writer where the generated JS output should be written
    Throws:
      `Exception`

  - ### recordToXML

    public static void recordToXML(String tagName, Map record, Writer out) throws Exception
    Takes a Map and serializes it into XML. Each key/value pair becomes an XML attribute, and any value that is not an atomic type - such as a string, number or date - is output via a recursive call to this method.
    Parameters:
      `tagName` - The XML tag to generate
      `record` - The Map to render as XML
      `out` - Writer to output the XML to
    Throws:
      `Exception`

  - ### recordToXML

    public static void recordToXML(String tagName, Map record, Writer out, DSRequest dsRequest) throws Exception
    Takes a Map and serializes it into XML. Each key/value pair becomes an XML attribute, and any value that is not an atomic type - such as a string, number or date - is output via a recursive call to this method.
    Parameters:
      `tagName` - The XML tag to generate
      `record` - The Map to render as XML
      `out` - Writer to output the XML to
      `dsRequest` - A DSRequest to use as context for the serialization. Pass as null if not appropriate
    Throws:
      `Exception`

  - ### recordToXML

    public static void recordToXML(String tagName, Map record, DataSource ds, Writer out) throws Exception
    Takes a Map and serializes it into XML based on the declarations in the DataSource similar to the client-side API Datasource.xmlSerialize(). Each key/value pair becomes an XML attribute, and any value that is not an atomic type - such as a string, number or date - is output via a recursive call to this method.
    Parameters:
      `tagName` - The XML tag to generate
      `record` - The Map to render as XML
      `ds` - DataSource to use as template for the serialization.
      `out` - Writer to output the XML to
    Throws:
      `Exception`

  - ### recordToXML

    public static void recordToXML(String tagName, Map record, Writer out, boolean useAttributes, DSRequest dsRequest) throws Exception
    Takes a Map and serializes it into XML based on the declarations in the DataSource similar to the client-side API Datasource.xmlSerialize(). Unlike the other recordToXML signatures, this one provides a way to control whether each key/value pair becomes an XML attribute (useAttributes=true) or an XML element (useAttributes=false). Behaves identically otherwise.
    Parameters:
      `tagName` - The XML tag to generate
      `record` - The Map to render as XML
      `out` - Writer to output the XML to
      `useAttributes` - If true, output name/value pairs as XML attributes. XML elements otherwise.
      `dsRequest` - A DSRequest to use as context for the serialization, if appropriate. Null values are permitted.
    Throws:
      `Exception`