scala.xml
object Utility

[source: `scala/xml/Utility.scala`]

`` `object` Utility
  `extends` TokenTests

  The `Utility` object provides utility functions for processing instances of bound and not bound XML classes, as well as escaping text nodes.

Author
  Burak Emir

Method Summary
`def` | appendEscapedQuoted (s : String, sb : StringBuilder) : StringBuilder Appends "s" and escapes and " i s with \"
`def` | appendQuoted (s : String, sb : StringBuilder) : StringBuilder Appends "s" if string `s` does not contain ", 's' otherwise.
`def` | checkAttributeValue (value : String) : String Returns `null` if the value is a correct attribute value, error message if it isn't.
`def` | collectNamespaces (nodes : Seq[Node]) : Set[String] Returns a set of all namespaces used in a sequence of nodes and all their descendants, including the empty namespaces.
`def` | collectNamespaces (n : Node, set : Set[String]) : Unit Adds all namespaces in node to set.
`final def` | escape (text : String, s : StringBuilder) : StringBuilder Appends escaped string to `s`.
`final def` | escape (text : String) : String Escapes the characters < > & and " from string.
`def` | getName (s : String, index : Int) : String
`def` | hashCode (pre : String, label : String, attribHashCode : Int, scpeHash : Int, children : Seq[Node]) : Int Returns a hashcode for the given constituents of a node
`def` | parseAttributeValue (value : String) : Seq[Node] new
`def` | parseCharRef (ch : () => Char, nextch : () => Unit, reportSyntaxError : (String) => Unit) : String
         CharRef ::= "&#" '0'..'9' {'0'..'9'} ";"
                   | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";"
see [66]
`final def` | prefix (name : String) : Option[String] Returns prefix of qualified name if any.
`def` | publicLiteralToString (s : String) : String
`def` | publicLiteralToString (sb : StringBuilder, s : String) : StringBuilder
`def` | sequenceToXML (children : Seq[Node], pscope : NamespaceBinding, sb : StringBuilder, stripComment : Boolean) : Unit
`def` | sort (md : MetaData) : MetaData returns a sorted attribute list
`def` | sort (n : Node) : Node returns the node with its attribute list sorted alphabetically (prefixes are ignored)
`def` | systemLiteralToString (sb : StringBuilder, s : String) : StringBuilder
`def` | systemLiteralToString (s : String) : String
`def` | toXML (n : Node, stripComment : Boolean) : String Return the string representation of a Node. uses namespace mapping from `defaultPrefixes(n)`.
`def` | toXML (x : Node, pscope : NamespaceBinding, sb : StringBuilder, stripComment : Boolean) : Unit Appends a tree to the given stringbuffer within given namespace scope.
`def` | toXML (n : Node) : String Returs the string representation of an XML node, with comments stripped the comments.
`def` | trim (x : Node) : Node trims an element - call this method, when you know that it is an element (and not a text node) so you know that it will not be trimmed away. With this assumption, the function can return a Node, rather than a Seq[Node]. If you don't know, call trimProper and account for the fact that you may get back an empty sequence of nodes precondition: node is not a text node (it might be trimmed)
`def` | trimProper (x : Node) : Seq[Node] trim a child of an element. Attribute values and Atom nodes that are not Text nodes are unaffected
`final def` | unescape (ref : String, s : StringBuilder) : StringBuilder Appends unescaped string to `s`, amp becomes & lt becomes < etc..
`def` | view (s : String) : Text

Methods inherited from TokenTests
isSpace, isSpace, isNameChar, isNameStart, isName, isPubIDChar, isValidIANAEncoding, checkSysID, checkPubID

Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Method Details

`` `def` trim(x : Node) : Node

  trims an element - call this method, when you know that it is an element (and not a text node) so you know that it will not be trimmed away. With this assumption, the function can return a Node, rather than a Seq[Node]. If you don't know, call trimProper and account for the fact that you may get back an empty sequence of nodes precondition: node is not a text node (it might be trimmed)

`` `def` trimProper(x : Node) : Seq[Node]

  trim a child of an element. Attribute values and Atom nodes that are not Text nodes are unaffected

`` `def` sort(md : MetaData) : MetaData

  returns a sorted attribute list

`` `def` sort(n : Node) : Node

  returns the node with its attribute list sorted alphabetically (prefixes are ignored)

@deprecated
`` `def` view(s : String) : Text

Deprecated
  a string might also be Atom(s) - define your own conversion

`final` `def` escape(text : String) : String

  Escapes the characters < > & and " from string.

Parameters
  `text -` ...
Returns
  ...

`final` `def` escape(text : String, s : StringBuilder) : StringBuilder

  Appends escaped string to `s`.

Parameters
  `text -` ...
  `s -` ...
Returns
  ...

`final` `def` unescape(ref : String, s : StringBuilder) : StringBuilder

  Appends unescaped string to `s`, amp becomes & lt becomes < etc..

Parameters
  `ref -` ...
  `s -` ...
Returns
  `null` if `ref` was not a predefined entity.

`` `def` collectNamespaces(nodes : Seq[Node]) : Set[String]

  Returns a set of all namespaces used in a sequence of nodes and all their descendants, including the empty namespaces.

Parameters
  `nodes -` ...
Returns
  ...

`` `def` collectNamespaces(n : Node, set : Set[String]) : Unit

  Adds all namespaces in node to set.

Parameters
  `n -` ...
  `set -` ...

`` `def` toXML(n : Node) : String

  Returs the string representation of an XML node, with comments stripped the comments.

Parameters
  `n -` the XML node
Returns
  the string representation of node `n`.
See Also
  "toXML(Node, Boolean)"

`` `def` toXML(n : Node, stripComment : Boolean) : String

  Return the string representation of a Node. uses namespace mapping from `defaultPrefixes(n)`.

Parameters
  `n -` the XML node
  `stripComment -` ...
Returns
  ...
Todo
  define a way to escape literal characters to &xx; references

`` `def` toXML(x : Node, pscope : NamespaceBinding, sb : StringBuilder, stripComment : Boolean) : Unit

  Appends a tree to the given stringbuffer within given namespace scope.

Parameters
  `n -` the node
  `pscope -` the parent scope
  `sb -` stringbuffer to append to
  `stripComment -` if true, strip comments

`` `def` sequenceToXML(children : Seq[Node], pscope : NamespaceBinding, sb : StringBuilder, stripComment : Boolean) : Unit

Parameters
  `children -` ...
  `pscope -` ...
  `sb -` ...
  `stripComment -` ...

`final` `def` prefix(name : String) : Option[String]

  Returns prefix of qualified name if any.

Parameters
  `name -` ...
Returns
  ...

`` `def` hashCode(pre : String, label : String, attribHashCode : Int, scpeHash : Int, children : Seq[Node]) : Int

  Returns a hashcode for the given constituents of a node

Parameters
  `uri -`
  `label -`
  `attribHashCode -`
  `children -`

`` `def` systemLiteralToString(s : String) : String

Parameters
  `s -` ...
Returns
  ...

`` `def` systemLiteralToString(sb : StringBuilder, s : String) : StringBuilder

Parameters
  `sb -` ...
  `s -` ...
Returns
  ...

`` `def` publicLiteralToString(s : String) : String

Parameters
  `s -` ...
Returns
  ...

`` `def` publicLiteralToString(sb : StringBuilder, s : String) : StringBuilder

Parameters
  `sb -` ...
  `s -` ...
Returns
  ...

`` `def` appendQuoted(s : String, sb : StringBuilder) : StringBuilder

  Appends "s" if string `s` does not contain ", 's' otherwise.

Parameters
  `s -` ...
  `sb -` ...
Returns
  ...

`` `def` appendEscapedQuoted(s : String, sb : StringBuilder) : StringBuilder

  Appends "s" and escapes and " i s with \"

Parameters
  `s -` ...
  `sb -` ...
Returns
  ...

`` `def` getName(s : String, index : Int) : String

Parameters
  `s -` ...
  `index -` ...
Returns
  ...

`` `def` checkAttributeValue(value : String) : String

  Returns `null` if the value is a correct attribute value, error message if it isn't.

Parameters
  `value -` ...
Returns
  ...

`` `def` parseAttributeValue(value : String) : Seq[Node]

  new

Parameters
  `value -` ...
Returns
  ...

`` `def` parseCharRef(ch : () => Char, nextch : () => Unit, reportSyntaxError : (String) => Unit) : String

           CharRef ::= "&#" '0'..'9' {'0'..'9'} ";"
                     | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";"

  see [66]

Parameters
  `ch -` ...
  `nextch -` ...
  `reportSyntaxError -` ...
Returns
  ...