
package provide xotcl::rdf::recreatorVisitor 1.0
package require -exact xotcl::rdf::parser 1.0
package require -exact xotcl::xml::recreatorVisitor 1.0
package require XOTcl 1

namespace eval ::xotcl::rdf::recreatorVisitor {
    namespace import ::xotcl::*

    ##############################################################################
    #
    # a visitor that recreates an RDF representation from a
    # node tree
    #
    #############################################################################
    Class RDFRecreatorVisitor -superclass XMLRecreatorVisitor
    
    RDFRecreatorVisitor instproc appendLineFeed obj {
	if {[set parseType [$obj getRDFAttribute parseType]] != ""} {
	    if {$parseType ne "Resource"} {
		# we have parseType == Literal 
		# -> don't append "\n"
		return ""
	    } 
	}
	return "\n"
    }

    RDFRecreatorVisitor instproc visit objName {
	next
	my instvar result
	if {[$objName istype RDFResource]} {
	    foreach t [$objName array names rdfTypes] {
		set ts [$objName prependRDFPrefix type]
		append result "  [my insertIndent $objName]<$ts resource=\"$t\"/>\n"
	    }
	}
	return $result
    }

    namespace export RDFRecreatorVisitor
}

namespace import ::xotcl::rdf::recreatorVisitor::*
