private void evaluateContext(Element target, ModelElement contextModel, Node contextNode) throws ParseException { // TODO support for 'bind attribute' if (target instanceof ModelElement) { contextModel = (ModelElement) target; contextNode = contextModel.getInitialContextNode(); } else if (target.getAttribute("model") != null) { // 7.4-3-a: context model which 'model' atttibeute determines is used String id = target.getAttribute("model"); contextModel = (ModelElement) getElementById(id); // reset the context node to the top-level element node contextNode = contextModel.getInitialContextNode(); } if (contextModel == null) { // 7.4-3-c: The first model in document order is used contextModel = getInitialContextModel(); // 7.4-1: 'outermost element' uses the top-level element node contextNode = contextModel.getInitialContextNode(); } if (target instanceof XFormsElement) ((XFormsElement) target).setContextNode(contextNode); System.out.println( "evaluete : context node[" + target.getTagName() + "] = " + ((InstanceDocument) contextNode.getOwnerDocument()).getOwner().getAttribute("id")); for (Node n = target.getFirstChild(); n != null; n = n.getNextSibling()) { if (!(n instanceof Element)) continue; // 7.4.3-b: The context model of immediately enclosing element is used // 7.4-2: 'non-outermost element' uses // first node of the binding expression of the immediately enclosing element if (target instanceof XFormsElement) { Node bindingNode = ((XFormsElement) target).getBindingNode(); if (bindingNode != null) { evaluateContext((Element) n, contextModel, bindingNode); continue; } } evaluateContext((Element) n, contextModel, contextNode); } }
public void destruct() throws Exception { for (Enumeration e = xpathSelectElements("//model"); e.hasMoreElements(); ) { Element model = (Element) e.nextElement(); model.dispatchEvent(new Event("xforms-destruct", true, false)); } }