implement XPath/XQuery facade class
Key functionality for a new form framework is the availability of an XPath/XQuery facade class in Java that provides the following interface. The proposed methods do not need to be exactly as layed out below but provide the implied functionality.
public static List evaluate(Element element, String xpath)
public static NodeList evaluate(Element element, String xpath)
public static String evaluateAsString(Element element,String xpath)
public static String getAsString(List nodeset, int position)
public static boolean getAsBoolean(List nodeset, int position)
public static double getAsDouble(List nodeset, int position)
public static boolean existsNode(List contextNodeset, int positionInNodeset)
public static Node getAsNode(List nodeset, int position)
/**
* Returns the set of all references to other nodes contained in the given
* XPath expression.
* <p/>
* The returned references are expected to be strings and not some
* XPath processor specific classes.
*
* @param xpath the XPath expression.
* @return the set of all references to other nodes.
* @throws XFormsException if a reference detection error occurred.
*/
public static Set<String> getReferences(String xpath)
The signatures might be incomplete and may require more arguments such as prefixMappings or other contextual information. These have been left away here for clarity.
getReferences
This needs a bit more context. I attached a file that is of central importance in betterFORM to build the dependency graph. Essentially this class analyses XPath expressions to find references to other nodes. E.g. a function may take a node as argument or a predicate refers to another node.
I attached the orgininal implementation to give an impression of what needs to be done. However it must be investigated how the use of full XQuery influences this analysis. Essentially the algorithm must be able to detect references to the node itself as well as to other nodes. This will be sufficient to setup the dependency graph for calculation and validation.
It should also be noted that is considered an error if validations contains circular dependencies.