Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

DescriptionYangJava Object ViewNotesXML Validation

Datatypes and basic constraints

Basic String

leaf response-code {
  type string;
}

Datatypes validated by XmlParser

Yes
Mandatory Basic String

leaf response-code {
  type string;
    mandatory "true";
}

Mandatory NOT checked by XmlParser

No
Limited String leaf pnf-name {
  type string {
    length "0..256";
}

Specialized class to hold length limitationChecked by XmlParser

Yes
typedef (String) with pattern

typedef dotted-quad {
  type string {
pattern
  '(([0-9] ...';
  }
}

leaf address {
   type dotted-quad;
   mandatory "true";
}

Checked by XmlParserYes
Limited unint64 leaf cid {
  type string {
  length "0..52";
}


Probably, TBC
boolean with default value

leaf blacklisted {
  type boolean;
  default 1;
}


N/A

Unique

Unique list server {
  key "name";
  unique "ip port";
  leaf name {
    type string;
  }
  leaf ip {
    type dotted-quad;
  }
  leaf port {
    type uint32;
  }}

NOT checked by XmlParserNo

Choice

Choicechoice transfer-method {
  leaf transfer-interval {
    type uint64 { range "15..2880"; }
    units minutes; }
  leaf transfer-on-commit {
  type empty;
  }}


TBC

Must

Must leaf ifType {
type enumeration {
enum ethernet;
enum atm;}}
leaf ifMTU {
type uint32;}
must "ifType != 'ethernet' or "
+ "(ifType = 'ethernet' and ifMTU = 1500)" {error-message 466px"An ethernet MTU must be 1500";}


TBC

When

When
leaf a {
    type boolean;
}
leaf b {
    type string;
    when "../a = 'true'";
}


TBC

Extension

Extension declaration extension store-state-ext {
argument duration;
description "An extension to enable state-storage for any attribute. Use duration to specify how long: nnn h|d|y";
}


N/A
Extension usage leaf attribute-with-temporal-storage {
  type string;
  cm-notify-api:store-state-ext "3 d"; // store state 3 days
}

extension is stored as 'UnknownNode' and refers back to the extension declarationN/A

Augmentation


augment "server" {
  when "port = '8787'";
    leaf enable-debug {
      type boolean;
    }
}


N/A

RPC

rpc
rpc nbrlist-change-notification {
description
"RAN Neighbor List change notification to configure RuntimeDB";
input {
:
}
output {
:
}
}


N/A
rpc input
 input {
leaf fap-service-number-of-entries-changed {
type uint64;
description
"Number of cells for which neighbor list has changed";
}
list fap-service {
key "alias";
leaf alias {
type string {
length "1..64";
}
}
leaf cid {
type string {
length "0..52";
}
}
uses x-0005b9-lte-g;
leaf lte-cell-number-of-entries {
type uint64;
description
"Number of cells in a neighbor list that was changed";
}
list lte-ran-neighbor-list-in-use-lte-cell-changed {
key "plmnid cid";
uses lte-ran-neighbor-list-in-use-lte-cell-g;
description
"Changed/Modified List of cells in a neighbor list for this fap service";
}
}
}


N/A
rpc output
output {
uses cm-notification-response;
}


N/A

...


Data Parsing and validation

XML Parsing

Code Block
languagejava
themeMidnight
titleXML Parsing Example
linenumberstrue
collapsetrue
		SchemaContext schemaContext = ... (see previous snippets)
        final Module module = schemaContext.findModules("ultraconfig-interfaces").iterator().next();
        QName qName = QName.create(module.getQNameModule(),"interfaces");
        final Optional<DataSchemaNode> node = module.findDataChildByName(qName);
        //module.findDataChildByName(qName);
        System.out.println("Present:" + node.isPresent());
        if (node.isPresent()) {
            final InputStream resourceAsStream = classLoader.getResourceAsStream("example2data.xml");
            final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
            final NormalizedNodeResult result = new NormalizedNodeResult();
            final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
            final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, node.get() );
            xmlParser.parse(reader);
            final NormalizedNode<?, ?> transformedInput = result.getResult();
        }

*Note: the DataSchemaNode being used when creating the XmlParserStream HAS to be the root node of the xml data!

XML Validation Findings

  • The XML Parser is found to do basic data type checks including range checks and (regex) pattern validation. If the dat input doesn't conform those a clear exception detailing the problem is thrown
  • Features such as 'mandatory' and 'unique' are to be validated
  • More advanced features such as 'must', 'when', 'choice' etc have not yet been tested

The tabel in the sections above has  a column with the XML validation findings.


JSON Parsing

TBD