Today's post in the XQJ series explains how to access and manipulate the static context through the XQJ API.
XQuery defines the Static Context as follows,
The static context of an expression is the information that is available during static analysis of the expression, prior to its evaluation. Refer to the XQuery spec for the complete list, but the static context includes for example information like,Most of the components in the static context can be initialized or augmented in the query prolog. In the next example, the boundary-space policy is explicitly specified,
[cc lang="java"]declare boundary-space preserve; [/cc]
If a static context component is not initialized in the query prolog, an implementation default is used. Indeed, although that XQuery defines default values for each of the components in the static context, as outlined in Appendix C of the XQuery specification, implementations are free to override and/or extend these defaults.[cc lang="java"]... // get a static context object with the implementation's defaults XQStaticContext xqsc = xqc.getStaticContext(); // make sure boundary-space policy is preserve xqsc.setBoundarySpacePolicy(XQConstants.BOUNDARY_SPACE_PRESERVE); // make the changes effective xqc.setStaticContext(xqsc); ...[/cc]
First retrieve the implementation's default values for the static context components through an XQStaticContext object. XQStaticContext defines setter and getter methods for the various static context components.In addition, XQStaticContext includes a number of XQJ specific properties,
View all posts from Marc Van Cappellen on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites