本文整理汇总了Java中org.apache.xpath.XPath.MATCH_SCORE_NONE属性的典型用法代码示例。如果您正苦于以下问题:Java XPath.MATCH_SCORE_NONE属性的具体用法?Java XPath.MATCH_SCORE_NONE怎么用?Java XPath.MATCH_SCORE_NONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.xpath.XPath
的用法示例。
在下文中一共展示了XPath.MATCH_SCORE_NONE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
protected void update(Node n) {
if (!isSelected(n)) {
try {
double matchScore
= xpath.execute(context, n, prefixResolver).num();
if (matchScore != XPath.MATCH_SCORE_NONE) {
if (!descendantSelected(n)) {
nodes.add(n);
}
} else {
n = n.getFirstChild();
while (n != null) {
update(n);
n = n.getNextSibling();
}
}
} catch (javax.xml.transform.TransformerException te) {
AbstractDocument doc
= (AbstractDocument) contentElement.getOwnerDocument();
throw doc.createXPathException
(XPathException.INVALID_EXPRESSION_ERR,
"xpath.error",
new Object[] { expression, te.getMessage() });
}
}
}
示例2: getPriorityOrScore
/**
* Given a match pattern and template association, return the
* score of that match. This score or priority can always be
* statically calculated.
*
* @param matchPat The match pattern to template association.
*
* @return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
* {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
* {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
* {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
* {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}, or
* the value defined by the priority attribute of the template.
*
*/
private double getPriorityOrScore(TemplateSubPatternAssociation matchPat)
{
double priority = matchPat.getTemplate().getPriority();
if (priority == XPath.MATCH_SCORE_NONE)
{
Expression ex = matchPat.getStepPattern();
if (ex instanceof NodeTest)
{
return ((NodeTest) ex).getDefaultScore();
}
}
return priority;
}
示例3: findAncestor
/**
* Given a 'from' pattern (ala xsl:number), a match pattern
* and a context, find the first ancestor that matches the
* pattern (including the context handed in).
*
* @param xctxt The XPath runtime state for this.
* @param fromMatchPattern The ancestor must match this pattern.
* @param countMatchPattern The ancestor must also match this pattern.
* @param context The node that "." expresses.
* @param namespaceContext The context in which namespaces in the
* queries are supposed to be expanded.
*
* @return the first ancestor that matches the given pattern
*
* @throws javax.xml.transform.TransformerException
*/
int findAncestor(
XPathContext xctxt, XPath fromMatchPattern, XPath countMatchPattern,
int context, ElemNumber namespaceContext)
throws javax.xml.transform.TransformerException
{
DTM dtm = xctxt.getDTM(context);
while (DTM.NULL != context)
{
if (null != fromMatchPattern)
{
if (fromMatchPattern.getMatchScore(xctxt, context)
!= XPath.MATCH_SCORE_NONE)
{
//context = null;
break;
}
}
if (null != countMatchPattern)
{
if (countMatchPattern.getMatchScore(xctxt, context)
!= XPath.MATCH_SCORE_NONE)
{
break;
}
}
context = dtm.getParent(context);
}
return context;
}
示例4: findPrecedingOrAncestorOrSelf
/**
* Given a 'from' pattern (ala xsl:number), a match pattern
* and a context, find the first ancestor that matches the
* pattern (including the context handed in).
* @param xctxt The XPath runtime state for this.
* @param fromMatchPattern The ancestor must match this pattern.
* @param countMatchPattern The ancestor must also match this pattern.
* @param context The node that "." expresses.
* @param namespaceContext The context in which namespaces in the
* queries are supposed to be expanded.
*
* @return the first preceding, ancestor or self node that
* matches the given pattern
*
* @throws javax.xml.transform.TransformerException
*/
private int findPrecedingOrAncestorOrSelf(
XPathContext xctxt, XPath fromMatchPattern, XPath countMatchPattern,
int context, ElemNumber namespaceContext)
throws javax.xml.transform.TransformerException
{
DTM dtm = xctxt.getDTM(context);
while (DTM.NULL != context)
{
if (null != fromMatchPattern)
{
if (fromMatchPattern.getMatchScore(xctxt, context)
!= XPath.MATCH_SCORE_NONE)
{
context = DTM.NULL;
break;
}
}
if (null != countMatchPattern)
{
if (countMatchPattern.getMatchScore(xctxt, context)
!= XPath.MATCH_SCORE_NONE)
{
break;
}
}
int prevSibling = dtm.getPreviousSibling(context);
if (DTM.NULL == prevSibling)
{
context = dtm.getParent(context);
}
else
{
// Now go down the chain of children of this sibling
context = dtm.getLastChild(prevSibling);
if (context == DTM.NULL)
context = prevSibling;
}
}
return context;
}
示例5: getMatchingAncestors
/**
* Get the ancestors, up to the root, that match the
* pattern.
*
* @param xctxt The XPath runtime state for this.
* @param node Count this node and it's ancestors.
* @param stopAtFirstFound Flag indicating to stop after the
* first node is found (difference between level = single
* or multiple)
* @return The number of ancestors that match the pattern.
*
* @throws javax.xml.transform.TransformerException
*/
NodeVector getMatchingAncestors(
XPathContext xctxt, int node, boolean stopAtFirstFound)
throws javax.xml.transform.TransformerException
{
NodeSetDTM ancestors = new NodeSetDTM(xctxt.getDTMManager());
XPath countMatchPattern = getCountMatchPattern(xctxt, node);
DTM dtm = xctxt.getDTM(node);
while (DTM.NULL != node)
{
if ((null != m_fromMatchPattern)
&& (m_fromMatchPattern.getMatchScore(xctxt, node)
!= XPath.MATCH_SCORE_NONE))
{
// The following if statement gives level="single" different
// behavior from level="multiple", which seems incorrect according
// to the XSLT spec. For now we are leaving this in to replicate
// the same behavior in XT, but, for all intents and purposes we
// think this is a bug, or there is something about level="single"
// that we still don't understand.
if (!stopAtFirstFound)
break;
}
if (null == countMatchPattern)
System.out.println(
"Programmers error! countMatchPattern should never be null!");
if (countMatchPattern.getMatchScore(xctxt, node)
!= XPath.MATCH_SCORE_NONE)
{
ancestors.addElement(node);
if (stopAtFirstFound)
break;
}
node = dtm.getParent(node);
}
return ancestors;
}
示例6: matches
/**
* Return the mode associated with the template.
*
*
* @param xctxt XPath context to use with this template
* @param targetNode Target node
* @param mode reference, which may be null, to the <a href="http://www.w3.org/TR/xslt#modes">current mode</a>.
* @return The mode associated with the template.
*
* @throws TransformerException
*/
public boolean matches(XPathContext xctxt, int targetNode, QName mode)
throws TransformerException
{
double score = m_stepPattern.getMatchScore(xctxt, targetNode);
return (XPath.MATCH_SCORE_NONE != score)
&& matchModes(mode, m_template.getMode());
}