Retrieve record structure at run time

hi all,

I have a record which has several other records defined in it.

-----record1 element1
-----record1 element2
-----record2 element1
-----record2 element2

At runtime the sub-records - record1 and record2 does not exist. I have the name of record(for ex record1) at runtime whose structure I am tryiny to retrieve. How do I retrieve this structure(using query or in my java service) from the document at runtime?

The problem is the records are not present during runtime but I need to retrieve the record strucuture at runtime and populate the values in there.