class ResultElement(XsltElement): """ When an func:result element is instantiated, during the instantiation of a func:function element, the function returns with its value. """ content = ContentInfo.Template legalAttrs = { 'select': AttributeInfo.Expression(), } doesSetup = doesPrime = True def setup(self): if not self._select: self._select = RtfExpr(self.children) return def prime(self, processor, context): self._function = None current = self.parent while current: # this loop will stop when it hits the top of the tree if current.expandedName == (EXSL_FUNCTIONS_NS, 'function'): self._function = current break current = current.parent if not self._function: raise XsltRuntimeException(ExsltError.RESULT_NOT_IN_FUNCTION, self) if not self.isLastChild(): siblings = self.parent.children for node in siblings[siblings.index(self) + 1:]: if node.expandedName != (XSL_NAMESPACE, 'fallback'): raise XsltRuntimeException( ExsltError.ILLEGAL_RESULT_SIBLINGS, self) return def instantiate(self, context, processor): context.processorNss = self.namespaces context.currentInstruction = self self._function.result = self._select.evaluate(context) return
class ResultElement(XsltElement): """ When an func:result element is instantiated, during the instantiation of a func:function element, the function returns with its value. """ content = ContentInfo.Template legalAttrs = { 'select' : AttributeInfo.Expression(), } doesSetup = doesPrime = True def setup(self): if not self._select: self._select = RtfExpr(self.children) return def prime(self, processor, context): self._function = None current = self.parent while current: # this loop will stop when it hits the top of the tree if current.expandedName == (EXSL_FUNCTIONS_NS, 'function'): self._function = current break current = current.parent if not self._function: raise XsltRuntimeException(ExsltError.RESULT_NOT_IN_FUNCTION, self) if not self.isLastChild(): siblings = self.parent.children for node in siblings[siblings.index(self)+1:]: if node.expandedName != (XSL_NAMESPACE, 'fallback'): raise XsltRuntimeException(ExsltError.ILLEGAL_RESULT_SIBLINGS, self) return def instantiate(self, context, processor): context.processorNss = self.namespaces context.currentInstruction = self self._function.result = self._select.evaluate(context) return
def setup(self): if not self._select: self._select = RtfExpr(self.children) return