summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2004-08-19 15:50:59 +0000
committerburaq <buraq@epfl.ch>2004-08-19 15:50:59 +0000
commit32013363bce62466c5b18111c34d50ba698a6b06 (patch)
tree5732fd64f390fd431c3c11882be0f700fdba080b /sources
parent8621368703cc56040efaeefad83f22d95f118543 (diff)
downloadscala-32013363bce62466c5b18111c34d50ba698a6b06.tar.gz
scala-32013363bce62466c5b18111c34d50ba698a6b06.tar.bz2
scala-32013363bce62466c5b18111c34d50ba698a6b06.zip
added documentation, method to fix namespace of...
added documentation, method to fix namespace of attribute sequence.
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/xml/AttributeSeq.scala27
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/scala/xml/AttributeSeq.scala b/sources/scala/xml/AttributeSeq.scala
index a47605eafa..bb74a053d7 100644
--- a/sources/scala/xml/AttributeSeq.scala
+++ b/sources/scala/xml/AttributeSeq.scala
@@ -16,6 +16,9 @@ import scala.collection.immutable.TreeSet ;
object AttributeSeq {
final val Empty = new AttributeSeq { final def sortedSeq = new TreeSet[Attribute] }
+ /** construct an attribute sequence from a map
+ * @param as a map from Pair(uri,key) to value
+ */
final def fromMap(as:Map[Pair[String,String],String]) = {
AttributeSeq.fromAttrs( {
for( val a <- as.keys.toList )
@@ -23,6 +26,11 @@ object AttributeSeq {
}:_* )
}
+ /** construct from a map, fixing namespaces to ns
+ * each Attribute with an empty namespace will get the namespace ns.
+ * @param ns the namespace to use instead of the empty one
+ * @param as a map from Pair(uri,key) to value
+ */
final def fromMap(ns:String, as:Map[Pair[String,String],String]) = {
AttributeSeq.fromAttrs( {
for( val a <- as.keys.toList )
@@ -36,6 +44,9 @@ object AttributeSeq {
}
}:_*)
}
+ /** construct from sequence of Attribute.
+ * @param as any sequence of attributes a1,a2,...
+ */
final def fromAttrs(as: Attribute*) = {
var ts = new TreeSet[Attribute];
for( val a <- as ) {
@@ -45,6 +56,22 @@ object AttributeSeq {
}
new AttributeSeq { final def sortedSeq = ts };
}
+
+ /** construct from sequence of Attribute, fixing namespaces to ns
+ * Each Attribute with an empty namespace will get the namespace ns.
+ * @param ns the namespace to use instead of the empty one
+ * @param as any sequence of attributes a1,a2,...
+ */
+ final def fromAttrs(ns:String, as: Attribute*) = {
+ var ts = new TreeSet[Attribute];
+ for( val a <- as ) {
+ if( a.key != "xmlns" ) {
+ val url = if( a.namespace.length() == 0) ns else a.namespace;
+ ts = ts + Attribute(url,a.key,a.value) ;
+ }
+ }
+ new AttributeSeq { final def sortedSeq = ts };
+ }
}
/** Sorted linear list of XML attributes.