Package net.sf.saxon.expr.PathMap

Examples of net.sf.saxon.expr.PathMap.PathMapRoot


    }
   
  public void useDocumentProjection(List<XMLTable.XMLColumn> columns, AnalysisRecord record) {
    this.contextRoot = null;
    PathMap map = this.xQuery.getPathMap();
    PathMapRoot parentRoot;
    try {
      parentRoot = map.getContextRoot();
    } catch (IllegalStateException e) {
      if (record.recordDebug()) {
        record.println("Document projection will not be used, since multiple context item exist."); //$NON-NLS-1$
      }
      return;
    }
    if (parentRoot == null) {
      //TODO: this seems like we could omit the context item altogether
      //this.xQuery.usesContextItem() should also be false
      if (record.recordDebug()) {
        record.println("Document projection will not be used, since no context item reference was found in the XQuery"); //$NON-NLS-1$
      }
      return;     
    }
    HashSet<PathMapNode> finalNodes = new HashSet<PathMapNode>();
    getReturnableNodes(parentRoot, finalNodes);
       
    if (!finalNodes.isEmpty()) { 
      if (columns != null && !columns.isEmpty()) {
        if (finalNodes.size() != 1) {
          if (record.recordDebug()) {
            record.println("Document projection will not be used, since multiple return items exist"); //$NON-NLS-1$
          }
          return
        }
        parentRoot = projectColumns(parentRoot, columns, finalNodes.iterator().next(), record);
        if (parentRoot == null) {
          return;
        }
      } else {
        for (Iterator iter = finalNodes.iterator(); iter.hasNext(); ) {
                  PathMapNode subNode = (PathMapNode)iter.next();
                  subNode.createArc(new AxisExpression(Axis.DESCENDANT_OR_SELF, AnyNodeTest.getInstance()));
              }
      }
    }
    if (parentRoot.hasUnknownDependencies()) {
      if (record.recordDebug()) {
        record.println("Document projection will not be used since there are unknown dependencies (most likely a user defined function)."); //$NON-NLS-1$
      }
        return;
    }
View Full Code Here


      if (xmlColumn.isOrdinal()) {
        continue;
      }
        Expression internalExpression = xmlColumn.getPathExpression().getInternalExpression();
        PathMap subMap = new PathMap(internalExpression);
        PathMapRoot subContextRoot = null;
        for (PathMapRoot root : subMap.getPathMapRoots()) {
        if (root.getRootExpression() instanceof ContextItemExpression || root.getRootExpression() instanceof RootExpression) {
          if (subContextRoot != null) {
            if (record.recordDebug()) {
              record.println("Document projection will not be used, since multiple context items exist in column path " + xmlColumn.getPath()); //$NON-NLS-1$
            }
            return null;
          }
          subContextRoot = root;
        }
      }
        if (subContextRoot == null) {
          //special case for handling '.', which the pathmap logic doesn't consider as a root
          if (internalExpression instanceof ContextItemExpression) {
            addReturnedArcs(xmlColumn, finalNode);
          }
          continue;
        }
        for (PathMapArc arc : subContextRoot.getArcs()) {
        finalNode.createArc(arc.getStep(), arc.getTarget());
      }
        HashSet<PathMapNode> subFinalNodes = new HashSet<PathMapNode>();
      getReturnableNodes(subContextRoot, subFinalNodes);
        for (PathMapNode subNode : subFinalNodes) {
          addReturnedArcs(xmlColumn, subNode);
          }
    }
    //Workaround to rerun the reduction algorithm - by making a copy of the old version
    PathMap newMap = new PathMap(DUMMY_EXPRESSION);
    PathMapRoot newRoot = newMap.makeNewRoot(parentRoot.getRootExpression());
    if (parentRoot.isAtomized()) {
      newRoot.setAtomized();
    }
    if (parentRoot.isReturnable()) {
      newRoot.setReturnable(true);
    }
    if (parentRoot.hasUnknownDependencies()) {
      newRoot.setHasUnknownDependencies();
    }
    for (PathMapArc arc : parentRoot.getArcs()) {
      newRoot.createArc(arc.getStep(), arc.getTarget());
    }
    return newMap.reduceToDownwardsAxes(newRoot);
  }
View Full Code Here

TOP

Related Classes of net.sf.saxon.expr.PathMap.PathMapRoot

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.