# source file: yin.rng namespace dc = "http://purl.org/dc/terms" default namespace ns1 = "urn:ietf:params:xml:ns:yang:yin:1" dc:title [ "RELAX NG Schema for YIN" ] dc:creator [ "Ladislav Lhotka" ] dc:date [ "2010-04-15" ] dc:subject [ "YIN, XML syntax for YANG" ] dc:identifier [ "urn:ietf:params:xml:ns:yang:yin:1" ] dc:description [ "RELAX NG schema defines grammar for data models\x{a}" ~ " expressed in YIN, an XML syntax equivalent to YANG." ] start = module-stmt | submodule-stmt module-stmt = element module { attribute name { identifier }, ((module-header-stmts, linkage-stmts, meta-stmts, revision-stmts, body-stmts) & an-extension) } submodule-stmt = element submodule { attribute name { identifier }, ((submodule-header-stmts, linkage-stmts, meta-stmts, revision-stmts, body-stmts) & an-extension) } module-header-stmts = yang-version-stmt? & namespace-stmt & prefix-stmt submodule-header-stmts = yang-version-stmt? & belongs-to-stmt & an-extension meta-stmts = organization-stmt? & contact-stmt? & description-stmt? & reference-stmt? linkage-stmts = (import-stmt | include-stmt)* revision-stmts = revision-stmt* body-stmts = (feature-stmt | identity-stmt | extension-stmt | typedef-stmt | grouping-stmt | data-def-stmt | rpc-stmt | notification-stmt)* feature-stmt = element feature { attribute name { identifier }, (if-feature-stmt* & status-desc-ref & an-extension) } if-feature-stmt = element if-feature { attribute name { identifier-ref }, an-extension } identity-stmt = element identity { attribute name { identifier }, (base-stmt? & status-desc-ref & an-extension) } base-stmt = element base { attribute name { identifier-ref }, an-extension } data-def-stmt = container-stmt | leaf-stmt | leaf-list-stmt | list-stmt | choice-stmt | anyxml-stmt | uses-stmt | augment-stmt case-data-def-stmt = container-stmt | leaf-stmt | leaf-list-stmt | list-stmt | anyxml-stmt | uses-stmt | augment-stmt yang-version-stmt = element yang-version { attribute value { "1" }, an-extension } import-stmt = element import { attribute module { identifier }, (prefix-stmt & an-extension) } include-stmt = element include { attribute module { identifier }, an-extension } namespace-stmt = element namespace { attribute uri { xsd:anyURI }, an-extension } prefix-stmt = element prefix { attribute value { identifier }, an-extension } belongs-to-stmt = element belongs-to { attribute module { identifier }, (prefix-stmt & an-extension) } organization-stmt = element organization { element text { text } & an-extension } contact-stmt = element contact { element text { text } & an-extension } description-stmt = element description { element text { text } & an-extension } reference-stmt = element reference { element text { text } & an-extension } units-stmt = element units { attribute name { xsd:string }, an-extension } revision-stmt = element revision { attribute date { xsd:date }, (description-stmt? & an-extension) } extension-stmt = element extension { attribute name { identifier }, (argument-stmt? & status-desc-ref & an-extension) } argument-stmt = element argument { attribute name { identifier }, (yin-element-stmt? & an-extension) } yin-element-stmt = element yin-element { attribute value { xsd:boolean }, an-extension } typedef-stmt = element typedef { attribute name { identifier }, (type-stmt & units-stmt? & default-stmt? & status-desc-ref & an-extension) } type-stmt = element type { ((attribute name { identifier-ref }, (range-stmt | (length-stmt & pattern-stmts))) | integer-type | decimal64-type | string-type | enumeration-type | bits-type | binary-type | leafref-type | identityref-type | union-type | instance-identifier-type) & an-extension } integer-type = attribute name { "int8" | "int16" | "int32" | "int64" | "uint8" | "uint16" | "uint32" | "uint64" }, range-stmt range-stmt = element range { attribute value { range-expr }, (error-message-stmt? & error-app-tag-stmt? & description-stmt? & reference-stmt? & an-extension) }? decimal64-type = attribute name { "decimal64" }, (range-stmt & element fraction-digits { attribute value { xsd:unsignedByte { minInclusive = "1" maxInclusive = "18" } } } & an-extension) string-type = attribute name { "string" }, (length-stmt & pattern-stmts & an-extension) length-stmt = element length { attribute value { length-expr }, (error-message-stmt? & error-app-tag-stmt? & description-stmt? & reference-stmt? & an-extension) }? pattern-stmts = element pattern { attribute value { xsd:string }, (error-message-stmt? & error-app-tag-stmt? & description-stmt? & reference-stmt? & an-extension) }* default-stmt = element default { attribute value { xsd:string }, an-extension } enumeration-type = attribute name { "enumeration" }, enum-stmt+ enum-stmt = element enum { attribute name { identifier }, (value-stmt? & status-desc-ref & an-extension) } bits-type = attribute name { "bits" }, bit-stmt+ bit-stmt = element bit { attribute name { identifier }, (position-stmt? & status-desc-ref & an-extension) } position-stmt = element position { attribute value { xsd:nonNegativeInteger }, an-extension } binary-type = attribute name { "binary" }, (length-stmt? & an-extension) leafref-type = attribute name { "leafref" }, (element path { attribute value { path-arg }, an-extension } & require-instance-stmt?) require-instance-stmt = element require-instance { attribute value { xsd:boolean }, an-extension } identityref-type = attribute name { "identityref" }, base-stmt union-type = attribute name { "union" }, type-stmt+ instance-identifier-type = attribute name { "instance-identifier" }, require-instance-stmt? status-stmt = element status { attribute value { status-arg }, an-extension } status-arg = "current" | "obsolete" | "deprecated" config-stmt = element config { attribute value { xsd:boolean }, an-extension } mandatory-stmt = element mandatory { attribute value { xsd:boolean }, an-extension } presence-stmt = element presence { attribute value { xsd:string }, an-extension } ordered-by-stmt = element ordered-by { attribute value { ordered-by-arg }, an-extension } ordered-by-arg = "user" | "system" must-stmt = element must { attribute condition { xsd:string }, (error-message-stmt? & error-app-tag-stmt? & description-stmt? & reference-stmt? & an-extension) } error-message-stmt = element error-message { element value { text, an-extension }, an-extension } error-app-tag-stmt = element error-app-tag { attribute value { xsd:string }, an-extension } min-elements-stmt = element min-elements { attribute value { xsd:nonNegativeInteger }, an-extension } max-elements-stmt = element max-elements { attribute value { "unbounded" | xsd:positiveInteger }, an-extension } value-stmt = element value { attribute value { xsd:integer }, an-extension } grouping-stmt = element grouping { attribute name { identifier }, (status-desc-ref & (typedef-stmt | grouping-stmt | data-def-stmt)* & an-extension) } container-stmt = element container { attribute name { identifier }, (when-stmt? & if-feature-stmt* & must-stmt* & presence-stmt? & config-stmt? & status-desc-ref & (typedef-stmt | grouping-stmt | data-def-stmt)* & an-extension) } leaf-stmt = element leaf { attribute name { identifier }, (when-stmt? & if-feature-stmt* & type-stmt & units-stmt? & must-stmt* & default-stmt? & config-stmt? & mandatory-stmt? & status-desc-ref & an-extension) } leaf-list-stmt = element leaf-list { attribute name { identifier }, (when-stmt? & if-feature-stmt* & type-stmt & units-stmt? & must-stmt* & config-stmt? & min-elements-stmt? & max-elements-stmt? & ordered-by-stmt? & status-desc-ref & an-extension) } list-stmt = element list { attribute name { identifier }, (when-stmt? & if-feature-stmt* & must-stmt* & key-stmt? & unique-stmt* & config-stmt? & min-elements-stmt? & max-elements-stmt? & ordered-by-stmt? & status-desc-ref & (typedef-stmt | grouping-stmt)* & data-def-stmt+ & an-extension) } key-stmt = element key { attribute value { list { identifier+ } }, an-extension } unique-stmt = element unique { attribute tag { list { descendant-schema-nodeid+ } }, an-extension } choice-stmt = element choice { attribute name { identifier }, (when-stmt? & if-feature-stmt* & default-stmt? & config-stmt? & mandatory-stmt? & status-desc-ref & (short-case-stmt | case-stmt)* & an-extension) } short-case-stmt = container-stmt | leaf-stmt | leaf-list-stmt | list-stmt | anyxml-stmt case-stmt = element case { attribute name { identifier }, (when-stmt? & if-feature-stmt* & status-desc-ref & case-data-def-stmt* & an-extension) } anyxml-stmt = element anyxml { attribute name { identifier }, (when-stmt? & if-feature-stmt* & must-stmt* & config-stmt? & mandatory-stmt? & status-desc-ref & an-extension) } uses-stmt = element uses { attribute name { identifier-ref }, (when-stmt? & if-feature-stmt* & status-desc-ref & refine-stmt* & uses-augment-stmt* & an-extension) } refine-stmt = element refine { attribute target-node { descendant-schema-nodeid }, ((refine-container-stmts | refine-leaf-stmts | refine-leaf-list-stmts | refine-list-stmts | refine-choice-stmts | refine-case-stmts | refine-anyxml-stmts) & an-extension) } refine-container-stmts = must-stmt* & presence-stmt? & config-stmt? & description-stmt? & reference-stmt? refine-leaf-stmts = must-stmt* & default-stmt? & config-stmt? & mandatory-stmt? & description-stmt? & reference-stmt? refine-leaf-list-stmts = must-stmt* & config-stmt? & min-elements-stmt? & max-elements-stmt? & description-stmt? & reference-stmt? refine-list-stmts = must-stmt* & config-stmt? & min-elements-stmt? & max-elements-stmt? & description-stmt? & reference-stmt? refine-choice-stmts = default-stmt? & config-stmt? & mandatory-stmt? & description-stmt? & reference-stmt? refine-case-stmts = description-stmt? & reference-stmt? refine-anyxml-stmts = config-stmt? & mandatory-stmt? & description-stmt? & reference-stmt? uses-augment-stmt = element augment { attribute target-node { descendant-schema-nodeid }, (when-stmt? & if-feature-stmt* & status-desc-ref & (data-def-stmt | case-stmt)+ & an-extension) } augment-stmt = element augment { attribute target-node { absolute-schema-nodeid }, (when-stmt? & if-feature-stmt* & status-desc-ref & (data-def-stmt | case-stmt)+ & an-extension) } when-stmt = element when { attribute condition { xsd:string }, an-extension } rpc-stmt = element rpc { attribute name { identifier }, (if-feature-stmt* & status-desc-ref & (typedef-stmt | grouping-stmt)* & input-stmt? & output-stmt? & an-extension) } input-stmt = element input { (typedef-stmt | grouping-stmt)* & data-def-stmt+ & an-extension } output-stmt = element output { (typedef-stmt | grouping-stmt)* & data-def-stmt+ & an-extension } notification-stmt = element notification { attribute name { identifier }, (if-feature-stmt* & status-desc-ref & (typedef-stmt | grouping-stmt | data-def-stmt)* & an-extension) } an-extension = element * - ns1:* { (attribute * { text } | any-element)* }? any-element = element * { (attribute * { text } | any-element)* } # Common combinations of patterns status-desc-ref = status-stmt? & description-stmt? & reference-stmt? # Regular expressions for lexical terms identifier = xsd:NCName { pattern = "[_A-Za-z][_\-A-Za-z0-9.]*" } identifier-ref = xsd:Name { pattern = "([_A-Za-z][_\-A-Za-z0-9.]*:)?[_A-Za-z][_\-A-Za-z0-9.]*" } range-expr = xsd:string { pattern = "\s*(-INF|INF|min|max|\-?(0|[1-9][0-9]*)(\.[0-9]+(E[\-+]?[0-9]+)?)?)(\s*\.\.\s*(-INF|INF|min|max|\-?(0|[1-9][0-9]*)(\.[0-9]+(E[\-+]?[0-9]+)?)?))?(\s*\|\s*(-INF|INF|min|max|\-?(0|[1-9][0-9]*)(\.[0-9]+(E[\-+]?[0-9]+)?)?)(\s*\.\.\s*(-INF|INF|min|max|\-?(0|[1-9][0-9]*)(\.[0-9]+(E[\-+]?[0-9]+)?)?))?)*\s*" } length-expr = xsd:string { pattern = "\s*(min|max|(0|[1-9][0-9]*))(\s*\.\.\s*(min|max|(0|[1-9][0-9]*)))?(\s*\|\s*(min|max|(0|[1-9][0-9]*))(\s*\.\.\s*(min|max|(0|[1-9][0-9]*)))?)*\s*" } path-arg = xsd:string { pattern = "((/([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*(\[\s*([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*=\s*current\s*\(\s*\)\s*/\s*(\.\.\s*/\s*)+(([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*/\s*)*([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*\])*)+)|((\.\./)+([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*((\[\s*([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*=\s*current\s*\(\s*\)\s*/\s*(\.\.\s*/\s*)+(([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*/\s*)*([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*\])*(/([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*(\[\s*([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*=\s*current\s*\(\s*\)\s*/\s*(\.\.\s*/\s*)+(([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*/\s*)*([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*\s*\])*)+)?)" } absolute-schema-nodeid = xsd:string { pattern = "(/([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*)+" } descendant-schema-nodeid = xsd:string { pattern = "([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*(/([_A-Za-z][._\-A-Za-z0-9]*:)?[_A-Za-z][._\-A-Za-z0-9]*)*" }