The application of Relax NG in Odoo

Source: Internet
Author: User

Some of you must be surprised that Odoo is how the XML in the module, such as the record, how the MenuItem is organized and defined, and the various fields of the various properties of what exactly, today, we come to a probe.

Relax NG:The next-generation normal language for Extensible Markup Language is a syntax-based Extensible Markup Language schema language that can be used to describe, define, and limit the vocabulary of Extensible Markup Language (a subset of standard generic markup languages). Simply put, Relax Ng is a set of XML that explains how XML is defined. Odoo defines its own set of XML framework structures by defining a set of rng files that, when the module is installed or upgraded, resolves it into its corresponding built-in object, stored in the database. For relax Ng's grammatical rules, refer to relax Ng's official website.

The code for parsing the XML file is in the Convert_xml_import method of convert.py:

defConvert_xml_import (CR, module, XMLFile, Idref=none, mode='Init', Noupdate=false, report=None): Doc=etree.parse (xmlfile) Relaxng=etree. Relaxng (Etree.parse (Os.path.join (config['Root_path'],'import_xml.rng' )))    Try: Relaxng.assert_ (DOC)exceptException: _logger.error ('The XML file does not fit the required schema!') _logger.error (Misc.ustr (relaxng.error_log.last_error) )Raise    ifIdref isNone:idref={} obj= Xml_import (CR, module, IDREF, Mode, Report=report, noupdate=noupdate) Obj.parse (Doc.getroot (), Mode=mode)returnTrue

In the Xml_import method, we deal with a variety of common nodes: Menuitem,record,template,url and so on.

By interpreting the Rng file, we can summarize the structure of the Odoo XML as follows:

Top node: openerp

Level Two nodes: elements (multiple): Data

Properties (optional): noupdate, context

Level three nodes: elements (multiple): MenuItem, Record, template, delete, Act_window, URL, assert, report, workflow, function, Ir_set

Common Node Properties:

MenuItem:ID (required), name,parent,action,sequence,groups,icon,web_icon,web_icon_hover,string

record:ID (optional), forcecreate (optional), model,context (optional),

child nodes:field (can be multiple)

Template:id,t-name,name,forecreate,context,priority,inherit_id,primary,groups,active,customzie_show, Page

Delete:model,id,search

Act_window:Id,name,res_model,domain,src_model,context,view_id,view_type,view_mode,multi,target,key2, Groups,limit,usage,auto_refresh

URL:id,name,url,target

assert:model,search,count,string,id,context,severity,test

Report :Id,string,model,name,report_type,multi,menu,keyword,rml,file,sxw,xml,xsl,parser,auto,header, Webkit_header,attachment,attachment_use,groups,usage

Workflow:model,action,uid,context,ref,value

function:model,name,id,context,eval

ir_set: child node: field

Similarly, in view, the Relax NG organization defines the schema of the view, as described in another article:

Http://www.cnblogs.com/kfx2007/p/5478375.html

The application of Relax NG in Odoo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.