diff options
author | buraq <buraq@epfl.ch> | 2003-11-26 09:04:20 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2003-11-26 09:04:20 +0000 |
commit | 0c15dac9e9985317de7f259da0e3ab90927aa32b (patch) | |
tree | 420aa2b9815c7aba4134c2105269bec948cf181b /sources | |
parent | c8f278f400e9313eecb8a61ea055730ead5fdcb3 (diff) | |
download | scala-0c15dac9e9985317de7f259da0e3ab90927aa32b.tar.gz scala-0c15dac9e9985317de7f259da0e3ab90927aa32b.tar.bz2 scala-0c15dac9e9985317de7f259da0e3ab90927aa32b.zip |
adapted to new xml nodes
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/dtd2scala/DeclToScala.scala | 110 | ||||
-rw-r--r-- | sources/scala/tools/dtd2scala/template/ObjectTemplate.scala.xml | 6 |
2 files changed, 56 insertions, 60 deletions
diff --git a/sources/scala/tools/dtd2scala/DeclToScala.scala b/sources/scala/tools/dtd2scala/DeclToScala.scala index 048e1bfa58..55fbdf1619 100644 --- a/sources/scala/tools/dtd2scala/DeclToScala.scala +++ b/sources/scala/tools/dtd2scala/DeclToScala.scala @@ -28,70 +28,68 @@ class DeclToScala(fOut:PrintWriter, var curAttribs: Map[String,AttrDecl] = null ; /* of current elem */ def write:Unit = { - def writeNode( n:Node ):Unit = { - n.label match { - case "template" => { - lookup.update("objectName", objectName); - lookup.update("compressDefault", compress.toString()); - n.children.elements.foreach { n => writeNode(n) } - } - case "elementBinding" => { - for( val decl <- elemMap.values.elements ) { - fOut.println(); - printIndent(); - lookup += "elementName" -> decl.name; - lookup += "elementContainsText" -> decl.containsText.toString(); - lookup += "elementContentModel" -> decl.contentModel; - curAttribs = decl.attribs; - n.children.elements.foreach{ n => writeNode( n ) } + def writeNode( x:Node ):Unit = x match { + case Text(text) => + fOut.print( text ); + case n:AttributedNode => + n.label match { + case "template" => { + lookup.update("objectName", objectName); + lookup.update("compressDefault", compress.toString()); + n.children.elements.foreach { n => writeNode(n) } + } + case "elementBinding" => { + for( val decl <- elemMap.values.elements ) { + fOut.println(); + printIndent(); + lookup += "elementName" -> decl.name; + lookup += "elementContainsText" -> decl.containsText.toString(); + lookup += "elementContentModel" -> decl.contentModel; + curAttribs = decl.attribs; + n.children.elements.foreach{ n => writeNode( n ) } + } + curAttribs = null; + lookup -= "elementName"; + lookup -= "elementContainsText"; } - curAttribs = null; - lookup -= "elementName"; - lookup -= "elementContainsText"; - } - case "attributeAssign" => { - for( val aDecl <- curAttribs.keys.elements ) { - lookup += "attributeName" -> aDecl; - n.children.elements.foreach{ n => writeNode( n ) } + case "attributeAssign" => { + for( val aDecl <- curAttribs.keys.elements ) { + lookup += "attributeName" -> aDecl; + n.children.elements.foreach{ n => writeNode( n ) } + } + lookup -= "attributeName"; } - lookup -= "attributeName"; - } - case "attributeBinding" => { - for( val aDecl <- curAttribs.keys.elements ) { - lookup += "attributeName" -> aDecl; - //Console.println("attributeName is "+aDecl+" = "+lookup("attributeName")); - n.children.elements.foreach{ n => writeNode( n ) } + case "attributeBinding" => { + for( val aDecl <- curAttribs.keys.elements ) { + lookup += "attributeName" -> aDecl; + n.children.elements.foreach{ n => writeNode( n ) } + } + lookup -= "attributeName"; } - lookup -= "attributeName"; - } - case "ccstring" => { - //Console.println("ccstring ref=\""+n.attributes("ref")+"\""); - fOut.print( cookedCap( lookup( n.attributes("ref") ) )); - } - case "cstring" => { - //Console.println("ccstring ref=\""+n.attributes("ref")+"\""); - fOut.print( cooked( lookup( n.attributes("ref") ) )); - } - case "string" => { - //Console.println("string ref=\""+n.attributes("ref")+"\""); - fOut.print( lookup( n.attributes("ref") ) ); - } - case "qstring" => { - //Console.println("qstring ref=\""+n.attributes("ref")+"\""); + case "ccstring" => { + fOut.print( cookedCap( lookup( n("ref").get ) )); + } + case "cstring" => { + fOut.print( cooked( lookup( n("ref").get ) )); + } + case "string" => { + fOut.print( lookup( n("ref").get ) ); + } + case "qstring" => { - fOut.print("\""); - fOut.print( lookup( n.attributes("ref") ) ); - fOut.print("\""); + fOut.print("\""); + fOut.print( lookup( n("ref").get ) ); + fOut.print("\""); + } + case "br" => { fOut.println(); printIndent() } + case "inc" => fIndent = fIndent + IND_STEP + case "dec" => fIndent = fIndent - IND_STEP + case _ => error("what shall I do with a \""+n.label+"\" node ?") } - case "br" => { fOut.println(); printIndent() } - case "inc" => fIndent = fIndent + IND_STEP - case "dec" => fIndent = fIndent - IND_STEP - case "#PCDATA" => fOut.print( n.asInstanceOf[Text].text ) - case _ => error("what shall I do with a \""+n.label+"\" node ?") - } } + writeNode( tmpl ) } } diff --git a/sources/scala/tools/dtd2scala/template/ObjectTemplate.scala.xml b/sources/scala/tools/dtd2scala/template/ObjectTemplate.scala.xml index 2be3636760..f676893dc6 100644 --- a/sources/scala/tools/dtd2scala/template/ObjectTemplate.scala.xml +++ b/sources/scala/tools/dtd2scala/template/ObjectTemplate.scala.xml @@ -39,14 +39,12 @@ import scala.collection.mutable.HashMap ;<br/> override def attributes : Map[String,String] = attrs; <br/> <attributeAssign> override val &cAttributeName; = attrs.get(&qAttributeName;); <br/> + val attribHashCode: int = attrs.hashCode() ;<br/> </attributeAssign> };<dec/><br/> - case class &ccElementName;( ch:Node* ) extends scala.xml.Node {<inc/><br/> + case class &ccElementName;( ch:Node* ) extends scala.xml.AttributedNode {<inc/><br/> def label = &qElementName;; <br/> def children = ch;<br/> - /* these methods are overridden at parse time */<br/> - def attributes : Map[String,String] = new HashMap[String,String](); <br/> - val attribHashCode: int = 0 ;<br/> <attributeBinding> val &cAttributeName; : scala.Option[String] = scala.None; /* overridden at parse time */ |