Accessing Data in XML Form

Data from the XML document is accessed in the same way as the photograph widget described in the previous chapter. The source path is extended to extract an individual value. For example, /details/name retrieves the person's name.

Figure 1. Getting the Person name and Reference Number
String name = context.getDataAccessor().get(
        field.getBinding().getSourcePath()
                          .extendPath("/details/name"));
    String reference = context.getDataAccessor().get(
        field.getBinding().getSourcePath()
                          .extendPath("/details/reference"));

All values in the XML document can be accessed using the same technique except for the e-mail address value. The e-mail address widget described in An E-Mail Address Widget will be re-used to output the e-mail address. As shown in that chapter, the e-mail address widget uses a Field object, its Binding property and a source path to access the e-mail address value. The next section will explain how to invoke that renderer.