for (int i_navRule = 0; i_navRule < navRules.getLength(); i_navRule++) {
Node navRule = navRules.item(i_navRule);
NodeList fromViewIdList = (NodeList)
xpath.evaluate(".//ns1:from-view-id/text()", navRule, XPathConstants.NODESET);
if (1 != fromViewIdList.getLength()) {
throw new XPathExpressionException("Within <navigation-rule> must have exactly one <from-view-id>");
}
String fromViewId = fromViewIdList.item(0).getNodeValue().trim();
NodeList navCases = (NodeList)
xpath.evaluate(".//ns1:navigation-case", navRule, XPathConstants.NODESET);
for (int i_navCase = 0; i_navCase < navCases.getLength(); i_navCase++) {
Node navCase = navCases.item(i_navCase);
NodeList toViewIdList = (NodeList)
xpath.evaluate(".//ns1:to-view-id/text()", navCase, XPathConstants.NODESET);
if (1 != toViewIdList.getLength()) {
throw new XPathExpressionException("Within <navigation-case>, must have exactly one <to-view-id>");
}
String toViewId = toViewIdList.item(0).getNodeValue().trim();
NavigationCaseBuilder ncb = flowBuilder.navigationCase();
ncb.fromViewId(fromViewId).toViewId(toViewId);
{
NodeList fromOutcomeList = (NodeList)
xpath.evaluate(".//ns1:from-outcome/text()", navCase, XPathConstants.NODESET);
if (null != fromOutcomeList && 1 < fromOutcomeList.getLength()) {
throw new XPathExpressionException("Within <navigation-case>, must have at most one <from-outcome>");
}
if (null != fromOutcomeList && 1 == fromOutcomeList.getLength()) {
String fromOutcome = fromOutcomeList.item(0).getNodeValue().trim();
ncb.fromOutcome(fromOutcome);
}
}
{
NodeList fromActionList = (NodeList)
xpath.evaluate(".//ns1:from-action/text()", navCase, XPathConstants.NODESET);
if (null != fromActionList && 1 < fromActionList.getLength()) {
throw new XPathExpressionException("Within <navigation-case>, must have at most one <from-action>");
}
if (null != fromActionList && 1 == fromActionList.getLength()) {
String fromAction = fromActionList.item(0).getNodeValue().trim();
ncb.fromAction(fromAction);
}
}
{
NodeList ifList = (NodeList)
xpath.evaluate(".//ns1:if/text()", navCase, XPathConstants.NODESET);
if (null != ifList && 1 < ifList.getLength()) {
throw new XPathExpressionException("Within <navigation-case>, must have zero or one <if>");
}
if (null != ifList && 1 == ifList.getLength()) {
String ifStr = ifList.item(0).getNodeValue().trim();
ncb.condition(ifStr);
}
}
{
NodeList redirectList = (NodeList)
xpath.evaluate(".//ns1:redirect", navCase, XPathConstants.NODESET);
if (null != redirectList && 1 < redirectList.getLength()) {
throw new XPathExpressionException("Within <navigation-case>, must have zero or one <redirect>");
}
if (null != redirectList && 1 == redirectList.getLength()) {
NavigationCaseBuilder.RedirectBuilder redirector = ncb.redirect();
Node redirectNode = redirectList.item(0);
String includeViewParams = getAttribute(redirectNode, "include-view-params");
if (null != includeViewParams && "true".equalsIgnoreCase(includeViewParams)) {
redirector.includeViewParams();
}
NodeList viewParamList = (NodeList)
xpath.evaluate(".//ns1:redirect-param", redirectNode, XPathConstants.NODESET);
if (null != viewParamList) {
for (int i_viewParam = 0; i_viewParam < viewParamList.getLength(); i_viewParam++) {
Node viewParam = viewParamList.item(i_viewParam);
NodeList nameList = (NodeList)
xpath.evaluate(".//ns1:name/text()", viewParam, XPathConstants.NODESET);
if (null == nameList || 1 != nameList.getLength()) {
throw new XPathExpressionException("Within <redirect-param> must have <name>.");
}
String nameStr = nameList.item(0).getNodeValue().trim();
NodeList valueList = (NodeList)
xpath.evaluate(".//ns1:value/text()", viewParam, XPathConstants.NODESET);
if (null == valueList || 1 != valueList.getLength()) {
throw new XPathExpressionException("Within <redirect-param> must have <value>.");
}
String valueStr = valueList.item(0).getNodeValue().trim();
redirector.parameter(nameStr, valueStr);
}
}