Basics

(this is not available right now)

You can transform an object into XML or JSON (see Convert Object Model Into XML or JSON). But you can have a fine control to modify the behaviour of the transformation by using code annotation.

Class Annotations

Are placed in the class scope and will modify the behaviour of the entire class.

@object:getter get

Defines the prefix name of the getter method. The default prefix is 'get'

/**
 * @object:getter obtenir
 */
class MyClass
{ 
    protected $unePropriete

    public function obtenirUnePropriete()
    {
        // ...
    }
}

@object:nodename name

Defines the root node name. The default is the full name including the namespace.

/**
 * @object:nodename OtherName
 */
class MyClass
{ 
    // ...
}

@object:writeempty false

Xmlnuke by default does not write empty properties. You can change this setting true in this annotation.

@object:propertypattern /([^a-zA-Z0-9])/,

Defines how the name of the property will match with the getter method.

The default property pattern removes special chars using only letters and numbers. The example bellow show how a property name matches with your proper getter.

protected $_my_property;

public function getMyProperty() ...

The property pattern have the follow format: search regular expression, replaced by

@object:doctype xml

Defines if the class will be render as XML or RDF. Note that 'xml' is the default option and enables produces JSON as output.

@object:rdftype {HOST}/rdf/class/{CLASS}

Defines the RDF type generated by this class. It is possible use two vars {HOST} - The host name {CLASS} - The class name

@object:rdfabout {HOST}/rdf/instance/{CLASS}/{GetID()}

TBD

@object:defaultprefix prefix

Defines a default prefix to be added do the property name. By default there is not prefix on node names. Use this with @object:namespace.

@object:ignore

If this parameter is setted all class will ignored and will not be rendered.

@object:namespace prefix!uri

Defines the namespaces of the properties and objects. If the property name has a namespace prefix this option is mandatory.

@object:dontcreatenode

Do not create the class node and all properties will be rendered in the parent node.

Method Annotations

@object:ignore

Does not render the property

@object:nodename name

Change the property name to 'name'.

@object:dontcreatenode

Do not create a node with the property name. Use this only when the property returns an object or array and you do not want render this object inside the property name.

@object:isattributeof propertyname

Defines that this property is an attribute of the 'propertyname' instead a node name.

@object:isclassattribute

Defines that this property is an attribute of the 'class' (root node) instead a node name inside the class.

@object:isblanknode nodename

(applied only to @object:doctype rdf)

@object:isresourceuri

Requires @object:isblanknode

(applied only to @object:doctype rdf)