当前位置: 首页>>代码示例>>Java>>正文


Java XPath.SELECT属性代码示例

本文整理汇总了Java中org.apache.xpath.XPath.SELECT属性的典型用法代码示例。如果您正苦于以下问题:Java XPath.SELECT属性的具体用法?Java XPath.SELECT怎么用?Java XPath.SELECT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.xpath.XPath的用法示例。


在下文中一共展示了XPath.SELECT属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAttributeBooleanValue

private static final boolean getAttributeBooleanValue(XSLProcessorContext ctx, ElemExtensionCall call, String attr, boolean defaultValue) throws TransformerException {
	Node node = ctx.getContextNode();
	String expr = call.getAttribute(attr);
	if (expr == null || expr.isEmpty())
		return defaultValue;
	XPathContext xpctx = ctx.getTransformer().getXPathContext();
	XPath xp = new XPath(expr, call, xpctx.getNamespaceContext(), XPath.SELECT);
	XObject xobj = xp.execute(xpctx, node, call);
	String value = xobj.str();
	if (value == null)
		return defaultValue;
	if (value.equals("yes"))
		return true;
	if (value.equals("true"))
		return true;
	if (value.equals("no"))
		return false;
	if (value.equals("false"))
		return false;
	return defaultValue;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:21,代码来源:XMLReader.java

示例2: StylesheetRoot

/**
 * Uses an XSL stylesheet document.
 * @throws TransformerConfigurationException if the baseIdentifier can not be resolved to a URL.
 */
public StylesheetRoot(ErrorListener errorListener) throws TransformerConfigurationException
{

  super(null);

  setStylesheetRoot(this);

  try
  {
    m_selectDefault = new XPath("node()", this, this, XPath.SELECT, errorListener);

    initDefaultRule(errorListener);
  }
  catch (TransformerException se)
  {
    throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_CANNOT_INIT_DEFAULT_TEMPLATES, null), se); //"Can't init default templates!", se);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:StylesheetRoot.java

示例3: getAttributeStringValue

private static final String getAttributeStringValue(XSLProcessorContext ctx, ElemExtensionCall call, String exprAttr, String valueAttr) throws TransformerException {
	Node node = ctx.getContextNode();
	String expr = call.getAttribute(exprAttr);
	if (expr == null || expr.isEmpty()) {
		return call.getAttribute(valueAttr);
	}
	XPathContext xpctx = ctx.getTransformer().getXPathContext();
	XPath xp = new XPath(expr, call, xpctx.getNamespaceContext(), XPath.SELECT);
	XObject xobj = xp.execute(xpctx, node, call);
	return xobj.str();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:11,代码来源:XMLReader.java

示例4: getAttributeIntValue

private static final int getAttributeIntValue(XSLProcessorContext ctx, ElemExtensionCall call, String attr) throws TransformerException {
	Node node = ctx.getContextNode();
	String expr = call.getAttribute(attr);
	XPathContext xpctx = ctx.getTransformer().getXPathContext();
	XPath xp = new XPath(expr, call, xpctx.getNamespaceContext(), XPath.SELECT);
	XObject xobj = xp.execute(xpctx, node, call);
	return (int) xobj.num();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:8,代码来源:XMLReader.java

示例5: compileXQExpr

/**
 * Take the received string, which is an XML query expression, compile it, and
 * store the compiled query locally. Note that for now, we only support XPath
 * because that's what Xalan supports.
 * 
 * @param queryExpr
 *          The XPath expression to compile
 */
public void compileXQExpr(final String queryExpr, final String opName,
    final DocumentBuilder dBuilder) throws StandardException {
  try {

    /* The following XPath constructor compiles the expression
     * as part of the construction process.  We have to pass
     * in a PrefixResolver object in order to avoid NPEs when
     * invalid/unknown functions are used, so we just create
     * a dummy one, which means prefixes will not be resolved
     * in the query (Xalan will just throw an error if a prefix
     * is used).  In the future we may want to revisit this
     * to make it easier for users to query based on namespaces.
     */
    query = new XPath(queryExpr, null, new PrefixResolverDefault(
        dBuilder.newDocument()), XPath.SELECT);

  } catch (Throwable te) {

    /* Something went wrong during compilation of the
     * expression; wrap the error and re-throw it.
     * Note: we catch "Throwable" here to catch as many
     * Xalan-produced errors as possible in order to
     * minimize the chance of an uncaught Xalan error
     * (such as a NullPointerException) causing Derby
     * to fail in a more serious way.  In particular, an
     * uncaught Java exception like NPE can result in
     * Derby throwing "ERROR 40XT0: An internal error was
     * identified by RawStore module" for all statements on
     * the connection after the failure--which we clearly
     * don't want.  If we catch the error and wrap it,
     * though, the statement will fail but Derby will
     * continue to run as normal. 
     */
    throw StandardException.newException(SQLState.LANG_XML_QUERY_ERROR, te,
        opName, te.getMessage());

  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:46,代码来源:SqlXmlHelperXalan.java

示例6: XPathExpr

/**
 * Creates a new XPathExpr object.
 */
public XPathExpr(String expr, XPathNSResolver res)
        throws DOMException, XPathException {
    resolver = res;
    prefixResolver = new NSPrefixResolver();
    try {
        xpath = new XPath(expr, null, prefixResolver, XPath.SELECT);
        context = new XPathContext();
    } catch (javax.xml.transform.TransformerException te) {
        throw createXPathException
            (XPathException.INVALID_EXPRESSION_ERR,
             "xpath.invalid.expression",
             new Object[] { expr, te.getMessage() });
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:17,代码来源:AbstractDocument.java

示例7: createExpression

/**
 * Creates a parsed XPath expression with resolved namespaces. This is
 * useful when an expression will be reused in an application since it makes
 * it possible to compile the expression string into a more efficient
 * internal form and preresolve all namespace prefixes which occur within
 * the expression.
 * 
 * @param expression
 *            The XPath expression string to be parsed.
 * @param resolver
 *            The <code>resolver</code> permits translation of prefixes
 *            within the XPath expression into appropriate namespace URIs .
 *            If this is specified as <code>null</code>, any namespace
 *            prefix within the expression will result in
 *            <code>DOMException</code> being thrown with the code
 *            <code>NAMESPACE_ERR</code>.
 * @return The compiled form of the XPath expression.
 * @exception XPathException
 *                INVALID_EXPRESSION_ERR: Raised if the expression is not
 *                legal according to the rules of the
 *                <code>XPathEvaluator</code>i
 * @exception DOMException
 *                NAMESPACE_ERR: Raised if the expression contains namespace
 *                prefixes which cannot be resolved by the specified
 *                <code>XPathNSResolver</code>.
 * 
 * @see org.w3c.dom.xpath.XPathEvaluator#createExpression(String,
 *      XPathNSResolver)
 */
@Override
public XPathExpression createExpression(String expression, XPathNSResolver resolver)
		throws XPathException, DOMException {

	try {

		// If the resolver is null, create a dummy prefix resolver
		XPath xpath = new XPath(expression, null,
				null == resolver ? new DummyPrefixResolver() : (PrefixResolver) resolver, XPath.SELECT);

		return new XPathExpressionImpl(xpath, m_doc);

	} catch (TransformerException e) {
		// Need to pass back exception code DOMException.NAMESPACE_ERR also.
		// Error found in DOM Level 3 XPath Test Suite.
		if (e instanceof XPathStylesheetDOM3Exception) {
			throw new DOMException(DOMException.NAMESPACE_ERR, e.getMessageAndLocation());
		} else {
			throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, e.getMessageAndLocation());
		}

	}
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:52,代码来源:XPathEvaluatorImpl.java

示例8: AVTPartXPath

/**
 * Construct a simple AVT part.
 * 
 * @param val A pure string section of an AVT.
 * @param nsNode An object which can be used to determine the
 * Namespace Name (URI) for any Namespace prefix used in the XPath. 
 * Usually this is based on the context where the XPath was specified,
 * such as a node within a Stylesheet.
 * @param xpathProcessor XPath parser
 * @param factory XPath factory
 * @param liaison An XPathContext object, providing infomation specific
 * to this invocation and this thread. Maintains SAX output state, 
 * variables, error handler and so on, so the transformation/XPath 
 * object itself can be simultaneously invoked from multiple threads.
 *
 * @throws javax.xml.transform.TransformerException
 * TODO: Fix or remove this unused c'tor.
 */
public AVTPartXPath(
        String val, org.apache.xml.utils.PrefixResolver nsNode, 
        XPathParser xpathProcessor, XPathFactory factory, 
        XPathContext liaison)
          throws javax.xml.transform.TransformerException
{
  m_xpath = new XPath(val, null, nsNode, XPath.SELECT, liaison.getErrorListener());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:AVTPartXPath.java

示例9: createXPath

/**
 * Process an expression string into an XPath.
 * Must be public for access by the AVT class.
 *
 * @param str A non-null reference to a valid or invalid XPath expression string.
 *
 * @return A non-null reference to an XPath object that represents the string argument.
 *
 * @throws javax.xml.transform.TransformerException if the expression can not be processed.
 * @see <a href="http://www.w3.org/TR/xslt#section-Expressions">Section 4 Expressions in XSLT Specification</a>
 */
public XPath createXPath(String str, ElemTemplateElement owningTemplate)
        throws javax.xml.transform.TransformerException
{
  ErrorListener handler = m_stylesheetProcessor.getErrorListener();
  XPath xpath = new XPath(str, owningTemplate, this, XPath.SELECT, handler, 
          m_funcTable);
  // Visit the expression, registering namespaces for any extension functions it includes.
  xpath.callVisitors(xpath, new ExpressionVisitor(getStylesheetRoot()));
  return xpath;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:StylesheetHandler.java


注:本文中的org.apache.xpath.XPath.SELECT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。