Package org.exist.xquery

Examples of org.exist.xquery.LocationStep


    public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
        super.analyze(contextInfo);
        final List<LocationStep> steps = BasicExpressionVisitor.findLocationSteps(getArgument(0));
        if (!steps.isEmpty()) {
            LocationStep firstStep = steps.get(0);
            LocationStep lastStep = steps.get(steps.size() - 1);
            if (firstStep != null && steps.size() == 1 && firstStep.getAxis() == Constants.SELF_AXIS) {
                final Expression outerExpr = contextInfo.getContextStep();
                if (outerExpr != null && outerExpr instanceof LocationStep) {
                    final LocationStep outerStep = (LocationStep) outerExpr;
                    final NodeTest test = outerStep.getTest();
                    if (!test.isWildcardTest() && test.getName() != null) {
                        contextQName = new QName(test.getName());
                        if (outerStep.getAxis() == Constants.ATTRIBUTE_AXIS || outerStep.getAxis() == Constants.DESCENDANT_ATTRIBUTE_AXIS)
                            {contextQName.setNameType(ElementValue.ATTRIBUTE);}
                        contextStep = firstStep;
                        axis = outerStep.getAxis();
                        optimizeSelf = true;
                    }
                }
            } else if (firstStep != null && lastStep != null) {
                final NodeTest test = lastStep.getTest();
View Full Code Here


  }
 
  public void validate() throws XPathException {
    if (select == null) {
      select = new XSLPathExpr(getXSLContext());
      select.add(new LocationStep(getContext(), Constants.SELF_AXIS, new AnyNodeTest()));
    }
   
  }
View Full Code Here

  public static void parse(XQueryContext context, String pattern, XSLPathExpr content) throws XPathException {
    boolean xpointer = false;
   
    //TODO: rewrite RootNode?
    if (pattern.equals("//")) {
      content.add(new LocationStep(context, Constants.SELF_AXIS, new AnyNodeTest()));
      return;
    }
    if (pattern.equals("/")) {
      content.add(new LocationStep(context, Constants.SELF_AXIS, new AnyNodeTest()));
      return;
    }
   
    Source source = new StringSource(pattern);
        Reader reader;
View Full Code Here

    double priority = 0.5;
    if (match != null)
      if (match.getLength() > 0) {
        Expression expr = match.getExpression(0);
        if (expr instanceof LocationStep) {
          LocationStep locationStep = (LocationStep) expr;
          NodeTest test = locationStep.getTest();
          if ((test.getName() == null)
              || (test.getName().getLocalName() == null))
            priority = -0.5;
          else if (locationStep.getPredicates().size() > 0)
            priority = 0.25;
          else
            priority = 0;
          //TODO: else (element(E,T) 0.25 (matches by name and type) ...)
        }
View Full Code Here

  public boolean isSmallWildcard() {
    if (match != null)
      if (match.getLength() > 0) {
        Expression expr = match.getExpression(0);
        if (expr instanceof LocationStep) {
          LocationStep locationStep = (LocationStep) expr;
          NodeTest test = locationStep.getTest();
          if (test instanceof TypeTest) {
            if (test.getName() == null)
            return true;
          }
        }
View Full Code Here

    protected void _check_(Expression path) {
        for (int index = 0; index < path.getSubExpressionCount(); index++) {
            Expression expr = path.getSubExpression(index);
            if ((index == 0) && (expr instanceof LocationStep)) {
                LocationStep location = (LocationStep) expr;
                if (location.getTest().isWildcardTest())
                    ;
                else if (location.getAxis() == Constants.CHILD_AXIS) {
                    location.setAxis(Constants.SELF_AXIS);
                }
            } else {
                _check_(expr);
            }
        }
View Full Code Here

    protected void _check_childNodes_(Expression path) {
        if (path.getSubExpressionCount() != 0) {
            Expression expr = path.getSubExpression(path.getSubExpressionCount()-1);
            if (expr instanceof LocationStep) {
                LocationStep location = (LocationStep) expr;
                //TODO: rewrite
                if (location.getAxis() == Constants.ATTRIBUTE_AXIS)
                    ;
                else if (!"node()".equals(location.getTest().toString())) {
                    ((PathExpr)path).add(new LocationStep(getContext(), Constants.CHILD_AXIS, new AnyNodeTest()));
                } else {
                    location.setAxis(Constants.CHILD_AXIS);
                }
            }
        }
    }
View Full Code Here

 
  public ForEach(XSLContext context) {
    super(context);
   
    childNodes = new PathExpr(getContext());
    childNodes.add(new LocationStep(getContext(), Constants.CHILD_AXIS, new AnyNodeTest()));

  }
View Full Code Here

  private LocationStep anyChild;

  public ApplyTemplates(XSLContext context) {
    super(context);

    anyChild = new LocationStep(getContext(), Constants.CHILD_AXIS, new AnyNodeTest());
  }
View Full Code Here

        super.analyze(contextInfo);
        if (isCalledAs("match-any"))
            {this.type = Constants.FULLTEXT_OR;}
        final List<LocationStep> steps = BasicExpressionVisitor.findLocationSteps(getArgument(0));
        if (!steps.isEmpty()) {
            LocationStep firstStep = steps.get(0);
            LocationStep lastStep = steps.get(steps.size() - 1);
            if (firstStep != null && steps.size() == 1 && firstStep.getAxis() == Constants.SELF_AXIS) {
                final Expression outerExpr = contextInfo.getContextStep();
                if (outerExpr != null && outerExpr instanceof LocationStep) {
                    final LocationStep outerStep = (LocationStep) outerExpr;
                    final NodeTest test = outerStep.getTest();
                    if (!test.isWildcardTest() && test.getName() != null) {
                        contextQName = new QName(test.getName());
                        if (outerStep.getAxis() == Constants.ATTRIBUTE_AXIS || outerStep.getAxis() == Constants.DESCENDANT_ATTRIBUTE_AXIS)
                            {contextQName.setNameType(ElementValue.ATTRIBUTE);}
                        contextStep = firstStep;
                        axis = outerStep.getAxis();
                        optimizeSelf = true;
                    }
                }
            } else if (firstStep != null && lastStep != null) {
                final NodeTest test = lastStep.getTest();
View Full Code Here

TOP

Related Classes of org.exist.xquery.LocationStep

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.