in scala/xml
object Utility

object Utility
extends Object
with ScalaObject

Utility functions for processing instances of bound and not bound XML classes, as well as escaping text nodes

Field Summary
final val noPrefixes: Map[String,String]
     A prefix mapping that maps the empty namespace to the empty prefix

Method Summary
final def appendEscapedQuoted(s: String, sb: StringBuffer): StringBuffer
     Appends "s" and escapes and " i s with \"
final def appendPrefixedName(ns: String, name: String, pmap: Map[String,String], sb: StringBuffer): Unit
     Appends prefixed name to given stringbuffer using namespace-to-prefix mapping pmap.
final def appendQuoted(s: String, sb: StringBuffer): StringBuffer
     Appends "s" if s does not contain ", 's' otherwise
final def attr2xml(ns: String, attrib: Iterator[Attribute], pmap: Map[String,String], sb: StringBuffer): Unit
     For a Node n, returns string representation of n.attributes
final def collectNamespaces(node: Node): Set[String]
     Returns a set of all namespaces appearing in a node and all its descendants, including the empty namespaces
final def collectNamespaces(nodes: Seq[Node]): Set[String]
     Returns a set of all namespaces appearing in a sequence of nodes and all their descendants, including the empty namespaces
final def defaultPrefixes(rootns: String, nset: Set[String]): Map[String,String]
     Returns a default prefix mapping for a set of namespaces.
final def defaultPrefixes(n: Node): Map[String,String]
final def defaultPrefixes(nodes: Seq[Node]): Map[String,String]
final def escape(text: String): String
final def hashCode(uname: UName, attribHashCode: Int, children: Seq[Node]): Int
     Returns a hashcode for the given constituents of a node
final def hashCode(uri: String, label: String, attribHashCode: Int, children: Seq[Node]): Int
     Returns a hashcode for the given constituents of a node
final def hashCode(uri: String, label: String, attribs: HashMap[Tuple2[String,String],String], children: Seq[Node]): Int
     Returns a hashcode for the given constituents of a node
final def publicLiteralToString(s: String): String
final def systemLiteralToString(s: String): String
final def toXML(n: Node): String
final def toXML(n: Node, stripComment: Boolean): String
     String representation of a Node.
final def toXML(x: Node, pmap: Map[String,String]): String
final def toXML(x: Node, pmap: Map[String,String], stripComment: Boolean): String
     Serializes a node with given namespace prefix mapping.
final def toXML(x: Node, pmap: Map[String,String], sb: StringBuffer): Unit
final def toXML(x: Node, pmap: Map[String,String], sb: StringBuffer, stripComment: Boolean): Unit
     serializes a tree to the given stringbuffer with the given namespace prefix mapping.
final def toXML1(x: Node, pmap: Map[String,String], sb: StringBuffer, stripComment: Boolean): Unit
     Serializes a non-root node to the given stringbuffer with the given namespace prefix mapping.
final def toXML1(x: Node, pmap: Map[String,String], sb: StringBuffer): Unit
final def view(s: String): Text

Field Detail

noPrefixes

  final val noPrefixes: Map[String,String]
A prefix mapping that maps the empty namespace to the empty prefix
Method Detail

view

  final def view(s: String): Text

escape

  final def escape(text: String): String

collectNamespaces

  final def collectNamespaces(node: Node): Set[String]
Returns a set of all namespaces appearing in a node and all its descendants, including the empty namespaces
Parameters:
node -

collectNamespaces

  final def collectNamespaces(nodes: Seq[Node]): Set[String]
Returns a set of all namespaces appearing in a sequence of nodes and all their descendants, including the empty namespaces
Parameters:
nodes -

defaultPrefixes

  final def defaultPrefixes(rootns: String, nset: Set[String]): Map[String,String]
Returns a default prefix mapping for a set of namespaces. the empty namespace is mapped to the empty prefix
Parameters:
rootns -
nset -

defaultPrefixes

  final def defaultPrefixes(n: Node): Map[String,String]
See Also:
"defaultPrefixes(String, mutable.Set[String])"

defaultPrefixes

  final def defaultPrefixes(nodes: Seq[Node]): Map[String,String]
See Also:
"defaultPrefixes(String, mutable.Set[String])"

toXML

  final def toXML(n: Node): String
See Also:
"toXML(Node, Boolean)"

toXML

  final def toXML(n: Node, stripComment: Boolean): String
String representation of a Node. uses namespace mapping from defaultPrefixes(n).
Parameters:
n -
stripComment -
Todo:
define a way to escape literal characters to &xx; references

toXML

  final def toXML(x: Node, pmap: Map[String,String]): String
See Also:
"toXML(Node, Map[String,String], Boolean)"

toXML

  final def toXML(x: Node, pmap: Map[String,String], stripComment: Boolean): String
Serializes a node with given namespace prefix mapping. The prefix mapping may not map the empty namespace "" to some non-empty prefix.
Parameters:
x - the node to serialize
pmap - a mapping from namespace URIs to prefixes
stripComment -

toXML

  final def toXML(x: Node, pmap: Map[String,String], sb: StringBuffer): Unit
See Also:
"toXML(Node, Map[String,String], StringBuffer, Boolean)"

toXML

  final def toXML(x: Node, pmap: Map[String,String], sb: StringBuffer, stripComment: Boolean): Unit
serializes a tree to the given stringbuffer with the given namespace prefix mapping. elements and attributes that have namespaces not in pmap are ignored
Parameters:
n - the root node
pmap - mapping namespaces to prefixes
sb - stringbuffer to append to
stripComment - if true, strip comments

toXML1

  final def toXML1(x: Node, pmap: Map[String,String], sb: StringBuffer, stripComment: Boolean): Unit
Serializes a non-root node to the given stringbuffer with the given namespace prefix mapping. use toXML to print the root node, which will have namespace declarations.
Parameters:
n - the non-root node
pmap - mapping namespaces to prefixes
sb - stringbuffer to append to
stripComment - if true, strip comments

toXML1

  final def toXML1(x: Node, pmap: Map[String,String], sb: StringBuffer): Unit
See Also:
"toXML1(Node, Map[String,String], StringBuffer, Boolean)"

attr2xml

  final def attr2xml(ns: String, attrib: Iterator[Attribute], pmap: Map[String,String], sb: StringBuffer): Unit
For a Node n, returns string representation of n.attributes
Parameters:
ns -
attrib -
pmap -
sb -

hashCode

  final def hashCode(uname: UName, attribHashCode: Int, children: Seq[Node]): Int
Returns a hashcode for the given constituents of a node
Parameters:
uname -
attribHashCode -
children -

hashCode

  final def hashCode(uri: String, label: String, attribHashCode: Int, children: Seq[Node]): Int
Returns a hashcode for the given constituents of a node
Parameters:
uri -
label -
attribHashCode -
children -

hashCode

  final def hashCode(uri: String, label: String, attribs: HashMap[Tuple2[String,String],String], children: Seq[Node]): Int
Returns a hashcode for the given constituents of a node
Parameters:
uri -
label -
attribs -
children -

systemLiteralToString

  final def systemLiteralToString(s: String): String

publicLiteralToString

  final def publicLiteralToString(s: String): String

appendPrefixedName

  final def appendPrefixedName(ns: String, name: String, pmap: Map[String,String], sb: StringBuffer): Unit
Appends prefixed name to given stringbuffer using namespace-to-prefix mapping pmap. precondition: pmap.contains(ns)
Parameters:
ns -
name -
pmap -
sb -

appendQuoted

  final def appendQuoted(s: String, sb: StringBuffer): StringBuffer
Appends "s" if s does not contain ", 's' otherwise
Parameters:
s -
sb -

appendEscapedQuoted

  final def appendEscapedQuoted(s: String, sb: StringBuffer): StringBuffer
Appends "s" and escapes and " i s with \"
Parameters:
s -
sb -