Document layout = null;
try
{
// fix hard coded 1 later for multiple profiles
IUserProfile profile = userLayoutStore.getUserProfileByFname(owner, "default");
profile.setLocaleManager(new LocaleManager(owner, new Locale[] { locale }));
// see if we have structure & theme stylesheets for this user yet.
// If not then fall back on system's selected stylesheets.
if (profile.getStructureStylesheetId() == 0 ||
profile.getThemeStylesheetId() == 0)
profile = userLayoutStore.getSystemProfileByFname(profile.getProfileFname());
view.profileId = profile.getProfileId();
view.profileFname = profile.getProfileFname();
view.layoutId = profile.getLayoutId();
// view.structureStylesheetId = profile.getStructureStylesheetId();
// view.themeStylesheetId = profile.getThemeStylesheetId();
layout = userLayoutStore.getFragmentLayout( owner, profile );
Element root = layout.getDocumentElement();