This file is indexed.

/usr/share/tcltk/xotcl1.6.7-rdf/RDFCreator.xotcl is in xotcl 1.6.7-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# $Id: RDFCreator.xotcl,v 1.6 2006/09/27 08:12:40 neumann Exp $

package provide xotcl::rdf::tripleRecreator 0.9
package require XOTcl
package require xotcl::rdf::parser

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

    Class RDFCreator -parameter {
	{rdfNS "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}
	{openExprs ""}
    }

    Class OpenExpr -parameter {
	{type ""}
	{subject ""}
	{closing ""}
    } 

    RDFCreator instproc init args {
	next
    }

    RDFCreator instproc free {} {
	my instvar openExprs
	while {$openExprs ne ""} {
	    set o [lindex $openExprs 0]
	    set openExprs [lrange $openExprs 1 end]
	    $o destroy
	}
    }

    RDFCreator instproc sort {tl} {
	#
	# this assumes that the triples are created and named in node tree order, e.g. 
	# through autonames like triple0, triple1, ... (as in rdfTripleCreator)
	#
	# => bag types defs are before bag's _1, _2 -- etc.
	#
	# otherwise overload sorting method !
	#
	return [lsort $tl]
    }

    RDFCreator instproc createFromTriples {tripleList} {
	my instvar openExprs
	set heading "<?xml version=\"1.0\"?>\n<RDF
  xmlns:rdf=\"[my set rdfNS]\""
	set body ""
	XMLNamespace [self]::ns
	[self]::ns add rdf [set rdfNS [my rdfNS]]
	my free

	foreach t [my sort $tripleList] {
	    set p [$t predicate]
	    set o [$t object]
	    set s [$t subject]

	    
	    set opening ""
	    set closing ""
	    if {[regexp "(^.*://.*/(\[^/\]+)(/|\#))(\[^/\]+)\$" $p _ ns prefix __ name]} {
		
		if {[string match $rdfNS $ns]} {
		    if {"type" eq $name} {
			if {[regexp "${rdfNS}(RDFAlt|RDFBag|RDFSeq)" $o _ type]} {
			    set opening "\n<rdf:$type ID=\"$s\">"
			    set closing "\n</rdf:$type>"
			}
		    }
		}

		if {[set nsPrefix [[self]::ns searchFullName $ns]] == ""} {
		    [self]::ns add [set nsPrefix [my autoname $prefix]] $ns
		    append heading "\n  xmlns:${nsPrefix}=\"$ns\""
		}
		
		set oe [lindex [my set openExprs] 0]

		if {$oe eq "" || [$oe subject] != $s} {
		    if {$oe ne ""} {
			append body [$oe closing]
			[lindex [set openExprs] 0] destroy
			set openExprs [lrange $openExprs 1 end]
		    }
		    if {$opening eq ""} {
			append body "\n<rdf:Description about=\"$s\">"
			set closing "\n</rdf:Description>"
			set type "Description"
		    } else {
			append body $opening
		    }
		    set noe [my OpenExpr [my autoname oe]]
		    set openExprs [concat $noe $openExprs]
		    
		    $noe subject $s
		    $noe closing $closing
		    $noe type $type
		    set oe $noe
		}
		set tn ${nsPrefix}:$name

		switch -exact [$oe type] {
		    RDFDescription {
			#puts DESCRIPTION
			append body "\n<$tn> [$t object] </$tn>"
		    }
		    RDFAlt - RDFSeq {
			#puts ALT---$tn
			if {[regexp {rdf:_([0-9]*)} $tn _ __]} {
			    append body "\n<rdf:li resource=\"[$t object]\"/>"
			}
		    } 
		    RDFBag {
			if {[regexp {rdf:_([0-9]*)} $tn _ __]} {
			    append body "\n<$tn resource=\"[$t object]\"/>"
			}
		    }
		}
	    } else { 
		puts "Predicate '$p' not matched"
		# hier als xmlns behandeln ...
	    } 
	}
	append heading ">"
	set r $heading
	while {$openExprs ne ""} {
	    set oe [lindex $openExprs 0]
	    set openExprs [lrange $openExprs 1 end]
	    append body [$oe closing]
	    $oe destroy
	}
	append r $body
	append r "\n</RDF>"
	return $r
    }

    namespace export RDFCreator OpenExpr
}

namespace import ::xotcl::rdf::tripleRecreator::*