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 : java.lang.String, sb : StringBuilder) : StringBuilder
Appends "s" and escapes and " i s with \"
def appendQuoted (s : java.lang.String, sb : StringBuilder) : StringBuilder
Appends "s" if string s does not contain ", 's' otherwise.
def appendQuoted (s : java.lang.String) : java.lang.String
def checkAttributeValue (value : java.lang.String) : java.lang.String
Returns null if the value is a correct attribute value, error message if it isn't.
def collectNamespaces (nodes : Seq[Node]) : Set[java.lang.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[java.lang.String]) : Unit
Adds all namespaces in node to set.
final def escape (text : java.lang.String, s : StringBuilder) : StringBuilder
Appends escaped string to s.
final def escape (text : java.lang.String) : java.lang.String
Escapes the characters < > & and " from string.
def getName (s : java.lang.String, index : Int) : java.lang.String
def hashCode (pre : java.lang.String, label : java.lang.String, attribHashCode : Int, scpeHash : Int, children : Seq[Node]) : Int
Returns a hashcode for the given constituents of a node
implicit def implicitSbToString (sb : StringBuilder) : java.lang.String
def parseAttributeValue (value : java.lang.String) : Seq[Node]
new
def parseCharRef (ch : () => Char, nextch : () => Unit, reportSyntaxError : (java.lang.String) => Unit) : java.lang.String
     CharRef ::= "&#" '0'..'9' {'0'..'9'} ";"
               | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";"
   
final def prefix (name : java.lang.String) : Option[java.lang.String]
Returns prefix of qualified name if any.
def sequenceToXML (children : Seq[Node], pscope : NamespaceBinding, sb : StringBuilder, stripComments : Boolean) : Unit
def sort (n : Node) : Node
returns the node with its attribute list sorted alphabetically (prefixes are ignored)
def sort (md : MetaData) : MetaData
returns a sorted attribute list
def toXML (x : Node, pscope : NamespaceBinding, sb : StringBuilder, stripComments : Boolean, decodeEntities : Boolean, preserveWhitespace : Boolean, minimizeTags : Boolean) : StringBuilder
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 : java.lang.String, s : StringBuilder) : StringBuilder
Appends unescaped string to s, amp becomes & lt becomes < etc..
Methods inherited from TokenTests
isSpace, isSpace, isAlpha, isAlphaDigit, 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
Object Summary
object Escapes extends AnyRef
Method Details
implicit def implicitSbToString(sb : StringBuilder) : java.lang.String

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)

final def escape(text : java.lang.String) : java.lang.String
Escapes the characters < > & and " from string.
Parameters
text - ...
Returns
...

final def escape(text : java.lang.String, s : StringBuilder) : StringBuilder
Appends escaped string to s.
Parameters
text - ...
s - ...
Returns
...

final def unescape(ref : java.lang.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[java.lang.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[java.lang.String]) : Unit
Adds all namespaces in node to set.
Parameters
n - ...
set - ...

def toXML(x : Node, pscope : NamespaceBinding, sb : StringBuilder, stripComments : Boolean, decodeEntities : Boolean, preserveWhitespace : Boolean, minimizeTags : Boolean) : StringBuilder

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

final def prefix(name : java.lang.String) : Option[java.lang.String]
Returns prefix of qualified name if any.
Parameters
name - ...
Returns
...

def hashCode(pre : java.lang.String, label : java.lang.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 appendQuoted(s : java.lang.String) : java.lang.String

def appendQuoted(s : java.lang.String, sb : StringBuilder) : StringBuilder
Appends "s" if string s does not contain ", 's' otherwise.
Parameters
s - ...
sb - ...
Returns
...

def appendEscapedQuoted(s : java.lang.String, sb : StringBuilder) : StringBuilder
Appends "s" and escapes and " i s with \"
Parameters
s - ...
sb - ...
Returns
...

def getName(s : java.lang.String, index : Int) : java.lang.String
Parameters
s - ...
index - ...
Returns
...

def checkAttributeValue(value : java.lang.String) : java.lang.String
Returns null if the value is a correct attribute value, error message if it isn't.
Parameters
value - ...
Returns
...

def parseAttributeValue(value : java.lang.String) : Seq[Node]
new
Parameters
value - ...
Returns
...

def parseCharRef(ch : () => Char, nextch : () => Unit, reportSyntaxError : (java.lang.String) => Unit) : java.lang.String
     CharRef ::= "&#" '0'..'9' {'0'..'9'} ";"
               | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";"
   

see [66]

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