コード例 #1
0
ファイル: XPath.java プロジェクト: jartang/JDK
  /**
   * Get the match score of the given node.
   *
   * @param xctxt XPath runtime context.
   * @param context The current source tree context node.
   * @return score, one of {@link #MATCH_SCORE_NODETEST}, {@link #MATCH_SCORE_NONE}, {@link
   *     #MATCH_SCORE_OTHER}, or {@link #MATCH_SCORE_QNAME}.
   * @throws javax.xml.transform.TransformerException
   */
  public double getMatchScore(XPathContext xctxt, int context)
      throws javax.xml.transform.TransformerException {

    xctxt.pushCurrentNode(context);
    xctxt.pushCurrentExpressionNode(context);

    try {
      XObject score = m_mainExp.execute(xctxt);

      if (DEBUG_MATCHES) {
        DTM dtm = xctxt.getDTM(context);
        System.out.println(
            "score: "
                + score.num()
                + " for "
                + dtm.getNodeName(context)
                + " for xpath "
                + this.getPatternString());
      }

      return score.num();
    } finally {
      xctxt.popCurrentNode();
      xctxt.popCurrentExpressionNode();
    }

    // return XPath.MATCH_SCORE_NONE;
  }