# An RDF Schema to XHTML Convertor @prefix : <#> . @prefix rdf: . @prefix rdfs: . @prefix daml: . @prefix log: . @prefix string: . @prefix os: . @prefix dc: . @prefix doc: . @prefix foaf: . this log:forAll :a , :b , :c , :F , :p , :q , :r , :s , :x , :y , :z . <> dc:title "An RDF Schema to XHTML Convertor"; dc:description """Converts a properly made RDF Schema file into XHTML using a bit of CWM magic. To run it, use:- TARGET=targetdoc.n3; cwm rdfstoxhtml.n3 --think --strings > out.html """; dc:creator [ foaf:name "Sean B. Palmer"; foaf:mbox ; foaf:homepage ] . # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Configurable Stuff # # Pass the TARGET environment variable through, and parse the semantics # into a target context { :x log:uri [ is os:environ of "TARGET" ] } log:implies { :x a :TargetDocument } . # or if TARGET doesn't work, simply de-comment one of the following:- # a :TargetDocument . # <0.95-think.n3> a :TargetDocument . # a :TargetDocument . # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Less Configurable Stuff # # Get the semantics of the TargetDocument { :x a :TargetDocument; log:semantics :F } log:implies { :F a :Target } . # Put out the header :Result_a0 log:outputString """ RDF Schema to XHTML Result """ . # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Get the document information # # Get the title of the document # Old hack:- # # { :F a :Target; log:includes { :x dc:title :y } . # ("

" :y "

") string:concatenation :z } # log:implies { :Result_a1 log:outputString :z } . :Result_a1a log:outputString "

RDFS to XHTML Result" . { :F a :Target; log:includes { :x dc:title :y } . :x a :TargetDocument . (" for: " :y) string:concatenation :z } log:implies { :Result_a1b log:outputString :z } . :Result_a1c log:outputString "

" . # Fix this bit # # If we can't get the title, use any old heading # # { :F a :Target; log:notIncludes { :x dc:title :y } . # :x a :TargetDocument . :x log:uri :z . # ("

" :z "

") string:concatenation :q } # log:implies { :Result_a2 log:outputString :q } . # # { :F a :Target; log:notIncludes { :x dc:title :y } } log:implies # { :Result_a2a log:outputString "

RDFS to XHTML Result

" } . # # This isn't quite right: sniffs dc:title anywhere. Gmprpgrpgrgh: it # doesn't work anyway; it = log:notIncludes # Get description and comments { :F a :Target; log:includes { :x dc:description :y } . :x a :TargetDocument . ("

Description: " :y "

") string:concatenation :z } log:implies { :Result_a2b log:outputString :z } . { :F a :Target; log:includes { :x rdfs:comment :y } . :x a :TargetDocument . ("

Comment: " :y "

") string:concatenation :z } log:implies { :Result_a2c log:outputString :z } . # What other stuff is relevent? Use rdfs:seeAlso # Sniff for rdfs:seeAlso { :F a :Target; log:includes { :x rdfs:seeAlso :y } . :x a :TargetDocument } log:implies { :Result_a2d log:outputString "

See also:-

\n
    " } . { :F a :Target; log:includes { :x rdfs:seeAlso :y } . :x a :TargetDocument . :y log:uri :z . ("
  • " :z "
  • ") string:concatenation :p } log:implies { :Result_a2e log:outputString :p } . { :F a :Target; log:includes { :x rdfs:seeAlso :y } . :x a :TargetDocument } log:implies { :Result_a2f log:outputString "
" } . # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Get the Classes, and their labels # :Result_a3 log:outputString """

Classes

The schema contains the following RDFS classes:-

""" . :Result_a4 log:outputString "
    " . # Get classes with labels and comments { :F a :Target; log:includes { :x a rdfs:Class; rdfs:label :y; rdfs:comment :z } . :x log:uri :p . ("
  • " :y " - " :z) string:concatenation :q } log:implies { :Result_a5 log:outputString :q } . # Get classes with comments { :F a :Target; log:includes { :x a rdfs:Class; rdfs:comment :z }; log:notIncludes { :x rdfs:label :r } . :x log:uri :p . ("
  • " :p " - " :z) string:concatenation :q } log:implies { :Result_a6 log:outputString :q } . # Get classes { :F a :Target; log:includes { :x a rdfs:Class } . :x log:uri :p . ("
  • " :p "") string:concatenation :q } log:implies { :Result_a7 log:outputString :q } . :Result_a8 log:outputString "
" . # I need daml:oneOf as a built in... well, rather something a bit # like daml:oneOf; log:in # { :F a :Target; log:includes { :x a rdfs:Class; :y :z } } log:implies # { :x :y :z . # { :x rdfs:comment :p . ("blargh: " :p) log:concatenation :q } # log:implies { :Result_a7 log:outputString :q } # } . # Could get other properties... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Get the Properties, and their labels # :Result_a9 log:outputString """

Properties

The schema contains the following RDF properties:-

""" . :Result_b1 log:outputString "
    " . # Get properties with labels and comments { :F a :Target; log:includes { :x a rdf:Property; rdfs:label :y; rdfs:comment :z } . :x log:uri :p . ("
  • " :y " - " :z) string:concatenation :q } log:implies { :Result_b2 log:outputString :q } . # Get properties with comments { :F a :Target; log:includes { :x a rdf:Property; rdfs:comment :z }; log:notIncludes { :x rdfs:label :z } . :x log:uri :p . ("
  • " :p " - " :z) string:concatenation :q } log:implies { :Result_b3 log:outputString :q } . # Get properties { :F a :Target; log:includes { :x a rdf:Property } . :x log:uri :p . ("
  • " :p "") string:concatenation :q } log:implies { :Result_b4 log:outputString :q } . :Result_b5 log:outputString "
" . :Result_b6 log:outputString "
" . # Junk # { :F a :Target; log:includes { :x rdfs:label :y } . } # log:implies { ("label: " :y) string:concatenation :Blargh } . # { ("x" "y") string:concatenation :x } log:implies # { :Result6 log:outputString :x } . # { :x string:concatenation :Blargh } log:implies { :Blargh a :Deeley } . # { :Result6 :blargh :x } log:implies { :Result6 log:outputString :x } . # { :F :title :g . ("

" :g "

") string:concatenation :x } # log:implies { :Result3 log:outputString :x } . # I want log:fragment or something... # Trailer: :Result_y log:outputString """
Converted using rdfstoxhtml.n3, SBP
""" . :Result_z log:outputString "\n" . # Cleanup: log:implies a log:Chaff . # Not that this matters # EOF