ev.location,
null);
}
while (iter.hasNext()) {
Pointer ptr = (Pointer)iter.next();
JXPathContext localJXPathContext =
currentContext.getRelativeContext(ptr);
String path = "";
if (contextPath != null) {
path = contextPath + "/.";
}
path += ptr.asPath();
execute(consumer,
form,
currentView,
path,
rootContext,
localJXPathContext,
startRepeat.next,
startRepeat.endRepeat);
}
ev = startRepeat.endRepeat.next;
continue;
} else if (ev instanceof StartGroup) {
StartGroup startGroup = (StartGroup)ev;
StartElement startElement = startGroup.startElement;
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
final XPathExpr ref = startGroup.ref;
if (ref != null) {
Pointer ptr;
try {
ptr = ref.getPointer(rootContext, currentContext);
} catch (Exception exc) {
throw new SAXParseException(exc.getMessage(),
ev.location,
exc);
}
JXPathContext localJXPathContext =
currentContext.getRelativeContext(ptr);
String path;
if (ref.absolute) {
path = ref.string;
} else {
path = contextPath;
if (path != null) {
path += "/.";
} else {
path = "";
}
path += ref.string;
}
execute(consumer,
form,
currentView,
path,
rootContext,
localJXPathContext,
startGroup.next,
startGroup.endGroup);
ev = startGroup.endGroup;
continue;
}
} else if (ev instanceof StartItemSet) {
StartItemSet startItemSet = (StartItemSet)ev;
final XPathExpr nodeset = startItemSet.nodeset;
Iterator iter = null;
try {
if (nodeset == null) {
iter = EMPTY_ITER;
} else {
iter =
nodeset.iteratePointers(rootContext,
currentContext);
}
} catch (Exception exc) {
throw new SAXParseException(exc.getMessage(),
ev.location,
exc);
} catch (Error err) {
throw new SAXParseException(err.getMessage(),
ev.location,
null);
}
while (iter.hasNext()) {
Pointer ptr = (Pointer)iter.next();
JXPathContext localJXPathContext =
currentContext.getRelativeContext(ptr);
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute(null, REF, REF, "CDATA",
ptr.asPath());
consumer.startElement(NS, ITEM, ITEM,
attrs);
String path = "";
if (contextPath != null) {
path = contextPath + "/.";
}
path += ptr.asPath();
execute(consumer,
form,
currentView,
path,
rootContext,
localJXPathContext,
startItemSet.next,
startItemSet.endItemSet);
consumer.endElement(NS, ITEM, ITEM);
}
ev = startItemSet.endItemSet.next;
continue;
} else if (ev instanceof StartInputControl) {
//
// input, textarea, secret, select1, selectMany
//
StartInputControl startInputControl =
(StartInputControl)ev;
XPathExpr ref = startInputControl.ref;
StartElement startElement = startInputControl.startElement;
Attributes attrs = startElement.attributes;
if (!ref.absolute && contextPath != null) {
AttributesImpl impl = new AttributesImpl(attrs);
int index = impl.getIndex(REF);
impl.setValue(index, contextPath + "/" + ref.string);
attrs = impl;
}
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
attrs);
if (ref != null) {
Iterator iter = ref.iterate(rootContext,
currentContext);
while (iter.hasNext()) {
Object val = iter.next();
consumer.startPrefixMapping(XF, NS);
consumer.startElement(NS, VALUE,
XF_VALUE, EMPTY_ATTRS);
if (val == null) val = "";
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 EndInputControl) {
StartInputControl startInputControl =
((EndInputControl)ev).startInputControl;
StartElement startElement = startInputControl.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} else if (ev instanceof StartReadonlyInputControl) {
//
// label, hint, help, value
//
// substitute "ref" if present
StartReadonlyInputControl startReadonlyInputControl =
(StartReadonlyInputControl)ev;
StartElement startElement = startReadonlyInputControl.startElement;
Object refValue = null;
if (startReadonlyInputControl.ref != null) {
refValue =
startReadonlyInputControl.ref.getValue(rootContext,
currentContext);
}
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
if (refValue != null) {
String v = String.valueOf(refValue);
consumer.characters(v.toCharArray(), 0, v.length());
}
} else if (ev instanceof EndReadonlyInputControl) {
StartReadonlyInputControl startReadonlyInputControl =
((EndReadonlyInputControl)ev).startReadonlyInputControl;
StartElement startElement =
startReadonlyInputControl.startElement;
consumer.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
} 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,