N4 N4

N4 - Definition

The N4 is a major road in Ireland, see N4 road.

N4 is another notation for RDF like languages. It named N4 because it is "after" N3

Contents

The Syntax

The N4 syntax is intentionally very simple:

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:id "me"
       p:address (a p:Address id :me/address 
           p:city "Paris"
       )
    )
    :me/address (p:street "tur")
)

Comments about the example

  • it is a parenthesized expression
  • namespaces are used as shorthands for uris
  • the empty namespace is the current n4 document
  • each n4 expression is a sequence of attribute-value pairs
  • An attribute name can be a n4 expression
  • a n4 expression denotes an "object", i.e. an uri with assertions on it.
  • keywords 'a', 'li' and 'id' are "specials" uris
    • 'a' types an expression
    • 'li' introduces an element of a list
    • 'id' names an expression in a namespace
  • a blind list in subject position is a list a of subjects

Metaclasses

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.

:mc (a n4:Class n4:subClassOf n4:Class)
(li :fcolor li :bcolor) (a n4:Property n4:domain :mc)
:c (a :mc :fcolor "red")
:o1 (a :c)
:o2 (a :c)
  •  :o1 and :o2 are instances of c and share the value of the slot :fcolor.
  •  :c is a class whose class is a metaclass
  •  :c is also a regular object.

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".

:c1 (as :c :bcolor "white")
:c2 (as :c1 :fcolor "red")
:c3 (as :c1 :fcolor "blue")
:c4 (as :c3 :bcolor "red")

WebResourceDescriptionLanguage

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:

(n4ns: http://n4.org/wrsdl/s1
n4ns:r http://n4.org/wrsdl/1.0/schema

:site (a r:Site r:name "example site"

   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)
      )
   )
)

:xmap (a r:Mappings r:host "n4.org:4445" r:context "/example/s1")
:map/home (as :xmap 
   li (a r:Mapping r:of :home
      li (a r:Path r:value "/Home")
   )
)
:map/welcome (as x:map 
   li (a r:Mapping r:of :welcome
      li (a r:Path r:value "/Welcome")
      li (a r:Parameter r:name "size" r:type :sizes)
   ) 
)

:sizes (a r:Enumeration li "small" li "big" li "huge")

:Home (a r:LinkSequence)  

Detailed comments.

Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.