Monday, 16 April 2018

ASN.1: SEQUENCE: Define collection of items

Type: SEQUENCE        

Description: Used to define collection of items.       

Example
Employee ::= SEQUENCE {
    name VisibleString,
    id VisibleString,
    salary REAL
}

Sample data for above schema
employee Employee ::= {
    name "Rama Krishna",
    id "I123456",
    salary 565432.34
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <id>I123456</id>
  <salary>565432.34</salary>
</Employee>

You can also embed nested types.
Employee ::= SEQUENCE {
 firstName VisibleString,
 lastName VisibleString,
 address Address
}

Address ::= SEQUENCE {
 street VisibleString,
 city VisibleString,
 state VisibleString,
 country VisibleString,
 pin INTEGER
}


In the above example,
a.   Employee and Address are types.
b.   firstName, lastName, address, street, city, state, country and pin are identifiers.

You can create an Employee object like below.
employee1 Employee ::= {
 firstName "Hari Krishna",
 lastName "Gurram",
 address {
  street "chowdesrai temple street",
  city "Bangalore",
  state "Karnantaka",
  country "India",
  pin 523145
 }
}










Previous                                                 Next                                                 Home

No comments:

Post a Comment