コード例 #1
0
ファイル: XQueryExpression.java プロジェクト: orbeon/saxon
 /**
  * Get a list containing the names of the external variables in the query.
  *
  * <p>
  *
  * <p><i>Changed in Saxon 9.0 to return an array of StructuredQName objects rather than integer
  * fingerprints.</i>
  *
  * @return an array of StructuredQName objects, representing the names of external variables
  *     defined in the query
  */
 public StructuredQName[] getExternalVariableNames() {
   List list = stackFrameMap.getVariableMap();
   StructuredQName[] names = new StructuredQName[stackFrameMap.getNumberOfVariables()];
   for (int i = 0; i < names.length; i++) {
     names[i] = (StructuredQName) list.get(i);
   }
   return names;
 }
コード例 #2
0
ファイル: XPathCache.java プロジェクト: johar111/orbeon-forms
  private static List<String> analyzeExpression(Expression expression, String xpathString) {
    if (expression instanceof ComputedExpression) {
      try {
        final PathMap pathmap = new PathMap((ComputedExpression) expression, new Configuration());
        logger.info("TEST XPATH PATHS - path for expression: " + xpathString);
        pathmap.diagnosticDump(System.out);

        final int dependencies = expression.getDependencies();

        if ((dependencies & StaticProperty.DEPENDS_ON_CONTEXT_ITEM) != 0) {
          System.out.println("  xxx DEPENDS_ON_CONTEXT_ITEM");
          return null;
        }
        if ((dependencies & StaticProperty.DEPENDS_ON_CURRENT_ITEM) != 0) {
          System.out.println("  xxx DEPENDS_ON_CURRENT_ITEM");
          return null;
        }
        if ((dependencies & StaticProperty.DEPENDS_ON_CONTEXT_DOCUMENT) != 0) {
          System.out.println("  xxx DEPENDS_ON_CONTEXT_DOCUMENT");
          return null;
        }
        if ((dependencies & StaticProperty.DEPENDS_ON_LOCAL_VARIABLES) != 0) {
          System.out.println("  xxx DEPENDS_ON_LOCAL_VARIABLES");
          // Some day we'll have variables
          return null;
        }
        if ((dependencies & StaticProperty.NON_CREATIVE) != 0) {
          System.out.println("  xxx NON_CREATIVE");
        }

        final List<String> instancesList = new ArrayList<String>();

        final PathMap.PathMapRoot[] roots = pathmap.getPathMapRoots();
        for (final PathMap.PathMapRoot root : roots) {
          final Expression rootExpression = root.getRootExpression();

          if (rootExpression instanceof Instance || rootExpression instanceof XXFormsInstance) {
            final FunctionCall functionCall = (FunctionCall) rootExpression;

            // TODO: Saxon 9.0 expressions should test "instanceof StringValue" to "instanceof
            // StringLiteral"
            if (functionCall.getArguments()[0] instanceof StringValue) {
              final String instanceName =
                  ((StringValue) functionCall.getArguments()[0]).getStringValue();
              instancesList.add(instanceName);
            } else {
              // Instance name is not known at compile time
              return null;
            }
          } else if (rootExpression
              instanceof Doc) { // don't need document() function as that is XSLT
            final FunctionCall functionCall = (FunctionCall) rootExpression;

            // TODO: Saxon 9.0 expressions should test "instanceof StringValue" to "instanceof
            // StringLiteral"
            if (functionCall.getArguments()[0] instanceof StringValue) {
              //                            final String literalURI = ((StringValue)
              // functionCall.getArguments()[0]).getStringValue();
              return null;
            } else {
              // Document name is not known at compile time
              return null;
            }
          } else if (rootExpression instanceof ContextItemExpression) {
            return null;
          } else if (rootExpression instanceof RootExpression) {
            // We depend on the current XForms model.
            return null;
          }

          //                                final PathMap.PathMapArc[] rootArcs = root.getArcs();
          //
          //                                for (int j = 0; j < rootArcs.length; j++) {
          //                                    final PathMapArc currentArc = rootArcs[j];
          //                                    final AxisExpression getStep
          //                                }

        }
        return instancesList;

      } catch (Exception e) {
        logger.error("EXCEPTION WHILE ANALYZING PATHS: " + xpathString);
        return null;
      }
    } else {
      logger.info("TEST XPATH PATHS - expression not a ComputedExpression: " + xpathString);
      return Collections.emptyList();
    }
  }