Class XmlGen

java.lang.Object
org.opencastproject.oaipmh.util.XmlGen
Direct Known Subclasses:
OaiXmlGen

public abstract class XmlGen extends Object
DOM based XML generation environment. Implement create() to create the XML. Serialize to an output stream with generate(java.io.OutputStream). todo document the node creator functions
  • Field Details

    • nodeZero

      protected org.opencastproject.util.data.Function0<Node> nodeZero
      Lazy version of nodeZero().
    • mkText

      protected org.opencastproject.util.data.Function<String,Node> mkText
      Create a text node from a string.
  • Constructor Details

    • XmlGen

      public XmlGen(org.opencastproject.util.data.Option<String> defaultNamespace)
      Create a new environment.
  • Method Details

    • generate

      public void generate(OutputStream out)
      Generate the XML and write it to out.
    • generate

      public Document generate()
      Generate the document.
    • generateAsString

      public String generateAsString()
      Generate the document as a string.
    • create

      public abstract Element create()
      Implement this method to create the DOM. Use the various node creation functions for this purpose.
    • ns

      protected XmlGen.Namespace ns(String prefix, String namespace)
    • schemaLocation

      protected Node schemaLocation(String location)
    • $langNode

      protected Node $langNode(String language)
    • $a

      protected Node $a(String name, String value)
    • $aBlank

      protected Node $aBlank(String name, String value)
    • $aSome

      protected Node $aSome(String name, org.opencastproject.util.data.Option<String> value)
    • $e

      protected Element $e(String qname, org.opencastproject.util.data.Option<String> namespace, List<Node> nodes)
    • $e

      protected Element $e(String qname, org.opencastproject.util.data.Option<String> namespace, NodeList nodes)
      Create an element with the qualified name qname -- i.e. prefix:tagname -- in the namespace namespace with children nodes.
    • $e

      protected Element $e(String qname, org.opencastproject.util.data.Option<String> namespace, Node... nodes)
    • $e

      protected Element $e(String name, Node... nodes)
    • $e

      protected Element $e(String name, List<Node> nodes)
    • $e

      protected Element $e(String qname, String namespace, Node... nodes)
      Create an element with the qualified name qname -- i.e. prefix:tagname -- in the namespace namespace with children nodes.
    • $e

      protected Element $e(String qname, String namespace, List<Node> nodes)
    • $eTxtBlank

      protected Node $eTxtBlank(String name, String text)
    • $eTxt

      protected Node $eTxt(String name, String text)
    • $eTxt

      protected Node $eTxt(String qname, String namespace, String text)
    • $e

      protected Element $e(String name, List<XmlGen.Namespace> namespaces, Node... nodes)
    • $e

      protected Element $e(String name, List<XmlGen.Namespace> namespaces, NodeList nodes)
    • $e

      protected Element $e(String name, List<XmlGen.Namespace> namespaces, List<Node> nodes)
    • $e

      protected Element $e(String qname, String namespace, List<XmlGen.Namespace> namespaces, Node... nodes)
    • $e

      protected Element $e(String qname, String namespace, List<XmlGen.Namespace> namespaces, List<Node> nodes)
      Create a new DOM element.
      Parameters:
      qname - fully qualified tag name, e.g. "name" or "dc:title"
      namespace - namespace to which this tag belongs to
      namespaces - additional namespace declarations
      nodes - child nodes
    • $e

      protected Node $e(String name, org.opencastproject.util.data.Option<Node>... nodes)
      Conditional element. Only created if at least one subnode is present. Subnodes may be attributes, elements, text nodes, etc.
    • $txt

      protected Node $txt(String text)
    • $cdata

      protected Node $cdata(String text)
    • $txtBlank

      protected org.opencastproject.util.data.Option<Node> $txtBlank(String text)
      Text blank.
    • nodeZero

      protected Node nodeZero()
      The neutral element.