N4 is another notation for RDF like languages. It named N4 because it is "after" N3
Table of contents |
2 A short example: 3 Comments about the example 4 Metaclasses 5 WebResourceDescriptionLanguage |
The N4 syntax is intentionally very simple:
RDF based notations use a metaclass based design which can be used to represent things in a very concise way. Lets recall that a Metaclass is a class whose instances are also classes.
Metaclasses allow to define class variables, i.e. slot values hold by classes. Class variables are naturally shared by all instances of the class.
Here is presented the WRSDL format, which allows to type web resources on a given site, and to map various url schemes to these resources.
An example:
Detailed comments.The Syntax
N4 = '(' *(uri (uri | String | N4)) ')'
A short example:
(
n4ns:n4 http://n4.org/n4/
n4ns:p http://x.org/personal/
n4ns: http://x.org/docs/1/
p:Person (a n4:Class
n4:dof (li x:address li x:name)
)
p:Address (a n4:Class
n4:dof (li p:city li p:street)
)
(li p:city li p:street)(a n4:Property n4:range n4:String)
:me (a p:Person p:name "me"
p:address (a p:Address id :me/address
p:city "Paris"
)
)
:me/address (p:street "tur")
)
Comments about the example
Metaclasses
(li :fcolor li :bcolor) (a n4:Property n4:domain :mc)
Shared slots allow to use an interesting idiom : only define objects which are classes, and derive them following the two relations is-instance-of AND is-subclass-of. Lets note this double relation by the keyword "as".
WebResourceDescriptionLanguage
(n4ns: http://n4.org/wrsdl/s1
n4ns:r http://n4.org/wrsdl/1.0/schema
li (a r:Resource r:name "home" id :home
li (a r:Get r:description "the home page "
li (a r:Accept r:mime "text/html")
li (a r:Accept r:mime "application/n4" r:class :Home)
)
)
li (a r:Resource r:name "welcome" id :welcome r:description "splash"
li (a r:Get
li (a r:Accept r:mime "image/gif" id :welcome/gif)
li (a r:Accept r:mime "image/png" id :welcome/png)
)
)
) li (a r:Mapping r:of :home
li (a r:Path r:value "/Home")
)
)
li (a r:Mapping r:of :welcome
li (a r:Path r:value "/Welcome")
li (a r:Parameter r:name "size" r:type :sizes)
)
)