} catch (Exception exc) {
throw new SAXParseException(exc.getMessage(),
ev.location,
exc);
}
JXPathContext localJXPathContext =
jxpathContextFactory.newContext(null, value);
String path = "";
if (contextPath != null) {
path = contextPath + "/.";
}
path += ptr.asPath();
execute(consumer,
form,
currentView,
path,
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 CompiledExpression ref = startGroup.ref;
if (ref != null) {
Object value;
try {
value = ref.getValue(jxpathContext);
} catch (Exception exc) {
throw new SAXParseException(exc.getMessage(),
ev.location,
exc);
}
JXPathContext localJXPathContext =
jxpathContextFactory.newContext(null, value);
String path = "";
if (contextPath != null) {
path = contextPath + "/.";
}
path += startElement.attributes.getValue(REF);
execute(consumer,
form,
currentView,
path,
localJXPathContext,
startGroup.next,
startGroup.endGroup);
ev = startGroup.endGroup;
continue;
}
} else if (ev instanceof StartItemSet) {
StartItemSet startItemSet = (StartItemSet)ev;
final CompiledExpression nodeset = startItemSet.nodeset;
Iterator iter = null;
try {
if (nodeset == null) {
iter = NULL_ITER;
} else {
iter =
nodeset.iteratePointers(jxpathContext);
}
} 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()) {
Object value;
Pointer ptr = (Pointer)iter.next();
try {
value = ptr.getNode();
} catch (Exception exc) {
throw new SAXParseException(exc.getMessage(),
ev.location,
exc);
}
JXPathContext localJXPathContext =
jxpathContextFactory.newContext(null, value);
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute(NS, "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,
ptr.asPath(),
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;
CompiledExpression ref = startInputControl.ref;
StartElement startElement = startInputControl.startElement;
String refStr = startElement.attributes.getValue("ref");
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
startElement.attributes);
if (ref != null) {
Iterator iter = ref.iteratePointers(jxpathContext);
while (iter.hasNext()) {
Pointer ptr = (Pointer)iter.next();
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute(NS, REF, REF, "CDATA",
ptr.asPath());
consumer.startElement(NS, VALUE, VALUE, EMPTY_ATTRS);
Object val = ptr.getNode();
String str = String.valueOf(val);
consumer.characters(str.toCharArray(), 0, str.length());
consumer.endElement(NS, VALUE, VALUE);
}
}
} 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(jxpathContext);
}
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);
execute(consumer, newForm, view, contextPath,
jxpathContextFactory.newContext(null,
newForm.getModel()),
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("", 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 ctx = jxpathContext;
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,