} else if (ev instanceof StartForm) {
StartForm startForm = (StartForm)ev;
StartElement startElement = startForm.startElement;
String view = startElement.attributes.getValue(VIEW);
String id = startElement.attributes.getValue(ID);
Form newForm = Form.lookup(objectModel, id);
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
if (newForm == null) {
throw new SAXParseException("Form not found: " + id,
ev.location,
null);
}
rootContext =
jxpathContextFactory.newContext(null,
newForm.getModel());
execute(consumer, newForm, view, contextPath,
rootContext, rootContext,
startForm.next, startForm.endForm);
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
ev = startForm.endForm.next;
continue;
} else if (ev instanceof EndForm) {
StartElement startElement =
((EndForm)ev).startForm.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartSubmit) {
StartElement startElement = ((StartSubmit)ev).startElement;
Attributes attrs = startElement.attributes;
if (kont != null) {
String id = startElement.attributes.getValue(ID);
if (id == null) {
id = "";
}
String cont =
startElement.attributes.getValue(CONTINUATION);
int level = 0;
if (BACK.equals(cont)) {
level = 3;
}
WebContinuation wk = kont;
for (int i = 0; i < level; i++) {
wk = wk.getParentContinuation();
if (wk == null) {
throw new SAXParseException("No such continuation",
ev.location,
null);
}
}
String kontId = wk.getId();
AttributesImpl newAttrs =
new AttributesImpl(startElement.attributes);
int i = newAttrs.getIndex(ID);
String phase = attrs.getValue(PHASE);
if (phase == null) {
phase = currentView;
}
if (i >= 0) {
newAttrs.setValue(i, kontId + ":" + phase + ":" +id);
} else {
newAttrs.addAttribute(null, ID, ID, "CDATA",
kontId + ":" + phase + ":" + id);
}
attrs = newAttrs;
}
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
attrs);
} else if (ev instanceof EndSubmit) {
StartElement startElement =
((EndSubmit)ev).startSubmit.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartItem) {
StartElement startElement = ((StartItem)ev).startElement;
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
} else if (ev instanceof EndItem) {
StartElement startElement =
((EndItem)ev).startItem.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartChoices) {
StartElement startElement = ((StartChoices)ev).startElement;
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
} else if (ev instanceof EndChoices) {
StartElement startElement =
((EndChoices)ev).startChoices.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartValue) {
StartElement startElement = ((StartValue)ev).startElement;
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
} else if (ev instanceof EndValue) {
StartElement startElement =
((EndValue)ev).startValue.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartHidden) {
StartElement startElement = ((StartHidden)ev).startElement;
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
} else if (ev instanceof EndHidden) {
StartElement startElement =
((EndHidden)ev).startHidden.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartOutput) {
StartOutput startOutput = (StartOutput)ev;
StartElement startElement = startOutput.startElement;
JXPathContext rootCtx = rootContext;
JXPathContext ctx = currentContext;
String formId = startElement.attributes.getValue(FORM);
if (formId != null) {
Form theForm = Form.lookup(objectModel, formId);
if (theForm == null) {
throw new SAXParseException("form not found: " + formId,
ev.location,
null);
}
rootCtx =
ctx =
jxpathContextFactory.newContext(null,
theForm.getModel());
}
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
Object val = null;
if (startOutput.ref != null) {
val = startOutput.ref.getValue(rootCtx, ctx);
} else if (startOutput.value != null) {
val = startOutput.value.getValue(rootCtx, ctx);
}
if (val != null) {
consumer.startPrefixMapping(XF, NS);
consumer.startElement(NS, VALUE, XF_VALUE, EMPTY_ATTRS);
String str = String.valueOf(val);
consumer.characters(str.toCharArray(), 0, str.length());
consumer.endElement(NS, VALUE, XF_VALUE);
consumer.endPrefixMapping(XF);
}
} else if (ev instanceof EndOutput) {
StartElement startElement =
((EndOutput)ev).startOutput.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof EndGroup) {
StartElement startElement =
((EndGroup)ev).startGroup.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartViolations) {
StartViolations startViolations =
(StartViolations)ev;
StartElement startElement =
startViolations.startElement;
Attributes attrs = startElement.attributes;
String formAttr = attrs.getValue(FORM);
Form theForm = form;
if (formAttr != null) {
theForm = Form.lookup(objectModel, formAttr);
}
Set violations = form.getViolationsAsSortedSet();
String mypath = null;