public XQExpression visit(ElementConstructor constructor, XQueryContext ctxt)
throws XQueryException {
boolean isLoopInvariant = true;
String name = constructor.getElemName();
if(name == null) {
XQExpression nameExpr = constructor.getNameExpr();
nameExpr.visit(this, ctxt);
isLoopInvariant &= nameExpr.isLoopInvariant();
}
for(AttributeConstructorBase att : constructor.getAttributes()) {
att.visit(this, ctxt);
isLoopInvariant &= att.isLoopInvariant();
}
for(XQExpression v : constructor.getContents()) {
v.visit(this, ctxt);
isLoopInvariant &= v.isLoopInvariant();
}
if(isLoopInvariant) {
if(name != null) {
XQExpression nameExpr = constructor.getNameExpr();
removeInvariants(nameExpr);
for(AttributeConstructorBase att : constructor.getAttributes()) {
removeInvariants(att);
}
for(XQExpression v : constructor.getContents()) {