Skip to content

Commit

Permalink
Support XForms 2.0 xforms:property child element
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruchez committed Oct 2, 2012
1 parent 0edf026 commit 9f6bf04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/java/org/orbeon/oxf/xforms/XFormsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,11 @@ public enum DeploymentType { separate, integrated, standalone}
public static final QName XXFORMS_PROGRESS_MESSAGE_QNAME = new QName("progress-message", XXFORMS_NAMESPACE);
public static final QName XXFORMS_OPEN_QNAME = new QName("open", XXFORMS_NAMESPACE);

public static final QName XXFORMS_REFRESH_ITEMS_QNAME = new QName("refresh-items", XXFORMS_NAMESPACE);
// XForms 2.0 standardizes the xforms:property element
public static final QName XFORMS_PROPERTY_QNAME = new QName("property", XFORMS_NAMESPACE);
public static final QName XXFORMS_CONTEXT_QNAME = new QName("context", XXFORMS_NAMESPACE);

public static final QName XXFORMS_REFRESH_ITEMS_QNAME = new QName("refresh-items", XXFORMS_NAMESPACE);
public static final QName XXFORMS_REPEAT_INDEXES_QNAME = new QName("repeat-indexes", XXFORMS_NAMESPACE);
public static final QName XXFORMS_DND_QNAME = new QName("dnd", XXFORMS_NAMESPACE);
public static final QName XXFORMS_DEFERRED_UPDATES_QNAME = new QName("deferred-updates", XXFORMS_NAMESPACE);
Expand Down
19 changes: 10 additions & 9 deletions src/scala/org/orbeon/oxf/xforms/action/XFormsAction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,41 @@ abstract class XFormsAction extends Logging {
// Iterate over context information if any
val tuples =
for {
currentContextInfo Dom4j.elements(actionElement, XXFORMS_CONTEXT_QNAME)
element Dom4j.elements(actionElement)
if Set(XFORMS_PROPERTY_QNAME, XXFORMS_CONTEXT_QNAME)(element.getQName) // xforms:property since XForms 2.0

// Get and check attributes
name =
Option(Dom4jUtils.qNameToExplodedQName(Dom4jUtils.extractAttributeValueQName(currentContextInfo, NAME_QNAME))) getOrElse
Option(Dom4jUtils.qNameToExplodedQName(Dom4jUtils.extractAttributeValueQName(element, NAME_QNAME))) getOrElse
(throw new OXFException(XXFORMS_CONTEXT_QNAME.getQualifiedName + " element must have a \"name\" attribute."))

value = VariableAnalysis.valueOrSelectAttribute(currentContextInfo) match {
value = VariableAnalysis.valueOrSelectAttribute(element) match {
case valueOrSelect: String
// XPath expression

// Set context on context element
val currentActionScope = actionInterpreter.getActionScope(currentContextInfo)
contextStack.pushBinding(currentContextInfo, actionInterpreter.getSourceEffectiveId(currentContextInfo), currentActionScope, false)
val currentActionScope = actionInterpreter.getActionScope(element)
contextStack.pushBinding(element, actionInterpreter.getSourceEffectiveId(element), currentActionScope, false)

// Evaluate context parameter
val result = XPathCache.normalizeSingletons(XPathCache.evaluate(
actionInterpreter.actionXPathContext.getCurrentNodeset,
actionInterpreter.actionXPathContext.getCurrentPosition,
valueOrSelect,
actionInterpreter.getNamespaceMappings(currentContextInfo),
actionInterpreter.getNamespaceMappings(element),
contextStack.getCurrentVariables,
XFormsContainingDocument.getFunctionLibrary,
contextStack.getFunctionContext(actionInterpreter.getSourceEffectiveId(currentContextInfo)),
contextStack.getFunctionContext(actionInterpreter.getSourceEffectiveId(element)),
null,
currentContextInfo.getData.asInstanceOf[LocationData]).asScala)
element.getData.asInstanceOf[LocationData]).asScala)

contextStack.returnFunctionContext()
contextStack.popBinding()

result
case _
// Literal text
currentContextInfo.getStringValue
element.getStringValue
}
} yield
(name, Option(value))
Expand Down

0 comments on commit 9f6bf04

Please sign in to comment.