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


Java XPathProcessorException类代码示例

本文整理汇总了Java中com.sun.org.apache.xpath.internal.XPathProcessorException的典型用法代码示例。如果您正苦于以下问题:Java XPathProcessorException类的具体用法?Java XPathProcessorException怎么用?Java XPathProcessorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: consumeExpected

import com.sun.org.apache.xpath.internal.XPathProcessorException; //导入依赖的package包/类
/**
 * Consume an expected token, throwing an exception if it
 * isn't there.
 *
 * @param expected The string to be expected.
 *
 * @throws javax.xml.transform.TransformerException
 */
private final void consumeExpected(String expected)
        throws javax.xml.transform.TransformerException
{

  if (tokenIs(expected))
  {
    nextToken();
  }
  else
  {
    error(XPATHErrorResources.ER_EXPECTED_BUT_FOUND, new Object[]{ expected,
                                                                   m_token });  //"Expected "+expected+", but found: "+m_token);

        // Patch for Christina's gripe. She wants her errorHandler to return from
        // this error and continue trying to parse, rather than throwing an exception.
        // Without the patch, that put us into an endless loop.
              throw new XPathProcessorException(CONTINUE_AFTER_FATAL_ERROR);
      }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:XPathParser.java

示例2: initXPath

import com.sun.org.apache.xpath.internal.XPathProcessorException; //导入依赖的package包/类
/**
 * Given an string, init an XPath object for selections,
 * in order that a parse doesn't
 * have to be done each time the expression is evaluated.
 *
 * @param compiler The compiler object.
 * @param expression A string conforming to the XPath grammar.
 * @param namespaceContext An object that is able to resolve prefixes in
 * the XPath to namespaces.
 *
 * @throws javax.xml.transform.TransformerException
 */
public void initXPath(
        Compiler compiler, String expression, PrefixResolver namespaceContext)
          throws javax.xml.transform.TransformerException
{

  m_ops = compiler;
  m_namespaceContext = namespaceContext;
  m_functionTable = compiler.getFunctionTable();

  Lexer lexer = new Lexer(compiler, namespaceContext, this);

  lexer.tokenize(expression);

  m_ops.setOp(0,OpCodes.OP_XPATH);
  m_ops.setOp(OpMap.MAPINDEX_LENGTH,2);


      // Patch for Christine's gripe. She wants her errorHandler to return from
      // a fatal error and continue trying to parse, rather than throwing an exception.
      // Without the patch, that put us into an endless loop.
      //
      // %REVIEW% Is there a better way of doing this?
      // %REVIEW% Are there any other cases which need the safety net?
      //      (and if so do we care right now, or should we rewrite the XPath
      //      grammar engine and can fix it at that time?)
      try {

    nextToken();
    Expr();

    if (null != m_token)
    {
      String extraTokens = "";

      while (null != m_token)
      {
        extraTokens += "'" + m_token + "'";

        nextToken();

        if (null != m_token)
          extraTokens += ", ";
      }

      error(XPATHErrorResources.ER_EXTRA_ILLEGAL_TOKENS,
            new Object[]{ extraTokens });  //"Extra illegal tokens: "+extraTokens);
    }

  }
  catch (com.sun.org.apache.xpath.internal.XPathProcessorException e)
  {
        if(CONTINUE_AFTER_FATAL_ERROR.equals(e.getMessage()))
        {
              // What I _want_ to do is null out this XPath.
              // I doubt this has the desired effect, but I'm not sure what else to do.
              // %REVIEW%!!!
              initXPath(compiler, "/..",  namespaceContext);
        }
        else
              throw e;
  }

  compiler.shrink();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:77,代码来源:XPathParser.java


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