Rework property typing to use classes and factory methods.

At the same time, switch to processing elements instead of element text,
so that nested classes use the same approach as string/int/long types and
so that more complex tree manipulations are possible.