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


Java XSLMessages.createMessage方法代码示例

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


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

示例1: evaluate

import com.sun.org.apache.xalan.internal.res.XSLMessages; //导入方法依赖的package包/类
/**
 * The dyn:evaluate function evaluates a string as an XPath expression and returns
 * the resulting value, which might be a boolean, number, string, node set, result
 * tree fragment or external object. The sole argument is the string to be evaluated.
 * <p>
 * If the expression string passed as the second argument is an invalid XPath
 * expression (including an empty string), this function returns an empty node set.
 * <p>
 * You should only use this function if the expression must be constructed dynamically,
 * otherwise it is much more efficient to use the expression literally.
 *
 * @param myContext The ExpressionContext passed by the extension processor
 * @param xpathExpr The XPath expression string
 *
 * @return The evaluation result
 */
public static XObject evaluate(ExpressionContext myContext, String xpathExpr)
  throws SAXNotSupportedException
{
  if (myContext instanceof XPathContext.XPathExpressionContext)
  {
    XPathContext xctxt = null;
    try
    {
      xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext();
      XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(),
                                     xctxt.getNamespaceContext(),
                                     XPath.SELECT);

      return dynamicXPath.execute(xctxt, myContext.getContextNode(),
                                  xctxt.getNamespaceContext());
    }
    catch (TransformerException e)
    {
      return new XNodeSet(xctxt.getDTMManager());
    }
  }
  else
    throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); //"Invalid context passed to evaluate "
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:ExsltDynamic.java

示例2: execute

import com.sun.org.apache.xalan.internal.res.XSLMessages; //导入方法依赖的package包/类
/**
 * Execute the function.  The function must return
 * a valid object.
 * @param xctxt The current execution context.
 * @return A valid XObject.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{

  SubContextList subContextList = xctxt.getCurrentNodeList();
  int currentNode = DTM.NULL;

  if (null != subContextList) {
      if (subContextList instanceof PredicatedNodeTest) {
          LocPathIterator iter = ((PredicatedNodeTest)subContextList)
                                                        .getLocPathIterator();
          currentNode = iter.getCurrentContextNode();
       } else if(subContextList instanceof StepPattern) {
         throw new RuntimeException(XSLMessages.createMessage(
            XSLTErrorResources.ER_PROCESSOR_ERROR,null));
       }
  } else {
      // not predicate => ContextNode == CurrentNode
      currentNode = xctxt.getContextNode();
  }
  return new XNodeSet(currentNode, xctxt.getDTMManager());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:FuncCurrent.java

示例3: max

import com.sun.org.apache.xalan.internal.res.XSLMessages; //导入方法依赖的package包/类
/**
 * The dyn:max function calculates the maximum value for the nodes passed as
 * the first argument, where the value of each node is calculated dynamically
 * using an XPath expression passed as a string as the second argument.
 * <p>
 * The expressions are evaluated relative to the nodes passed as the first argument.
 * In other words, the value for each node is calculated by evaluating the XPath
 * expression with all context information being the same as that for the call to
 * the dyn:max function itself, except for the following:
 * <p>
 * <ul>
 *  <li>the context node is the node whose value is being calculated.</li>
 *  <li>the context position is the position of the node within the node set passed as
 *   the first argument to the dyn:max function, arranged in document order.</li>
 *  <li>the context size is the number of nodes passed as the first argument to the
 *   dyn:max function.</li>
 * </ul>
 * <p>
 * The dyn:max function returns the maximum of these values, calculated in exactly
 * the same way as for math:max.
 * <p>
 * If the expression string passed as the second argument is an invalid XPath
 * expression (including an empty string), this function returns NaN.
 * <p>
 * This function must take a second argument. To calculate the maximum of a set of
 * nodes based on their string values, you should use the math:max function.
 *
 * @param myContext The ExpressionContext passed by the extension processor
 * @param nl The node set
 * @param expr The expression string
 *
 * @return The maximum evaluation value
 */
public static double max(ExpressionContext myContext, NodeList nl, String expr)
  throws SAXNotSupportedException
{

  XPathContext xctxt = null;
  if (myContext instanceof XPathContext.XPathExpressionContext)
    xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext();
  else
    throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext }));

  if (expr == null || expr.length() == 0)
    return Double.NaN;

  NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt);
  xctxt.pushContextNodeList(contextNodes);

  double maxValue = - Double.MAX_VALUE;
  for (int i = 0; i < contextNodes.getLength(); i++)
  {
    int contextNode = contextNodes.item(i);
    xctxt.pushCurrentNode(contextNode);

    double result = 0;
    try
    {
      XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                     xctxt.getNamespaceContext(),
                                     XPath.SELECT);
      result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num();
    }
    catch (TransformerException e)
    {
      xctxt.popCurrentNode();
      xctxt.popContextNodeList();
      return Double.NaN;
    }

    xctxt.popCurrentNode();

    if (result > maxValue)
        maxValue = result;
  }

  xctxt.popContextNodeList();
  return maxValue;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:81,代码来源:ExsltDynamic.java

示例4: min

import com.sun.org.apache.xalan.internal.res.XSLMessages; //导入方法依赖的package包/类
/**
 * The dyn:min function calculates the minimum value for the nodes passed as the
 * first argument, where the value of each node is calculated dynamically using
 * an XPath expression passed as a string as the second argument.
 * <p>
 * The expressions are evaluated relative to the nodes passed as the first argument.
 * In other words, the value for each node is calculated by evaluating the XPath
 * expression with all context information being the same as that for the call to
 * the dyn:min function itself, except for the following:
 * <p>
 * <ul>
 *  <li>the context node is the node whose value is being calculated.</li>
 *  <li>the context position is the position of the node within the node set passed
 *    as the first argument to the dyn:min function, arranged in document order.</li>
 *  <li>the context size is the number of nodes passed as the first argument to the
 *    dyn:min function.</li>
 * </ul>
 * <p>
 * The dyn:min function returns the minimum of these values, calculated in exactly
 * the same way as for math:min.
 * <p>
 * If the expression string passed as the second argument is an invalid XPath expression
 * (including an empty string), this function returns NaN.
 * <p>
 * This function must take a second argument. To calculate the minimum of a set of
 * nodes based on their string values, you should use the math:min function.
 *
 * @param myContext The ExpressionContext passed by the extension processor
 * @param nl The node set
 * @param expr The expression string
 *
 * @return The minimum evaluation value
 */
public static double min(ExpressionContext myContext, NodeList nl, String expr)
  throws SAXNotSupportedException
{

  XPathContext xctxt = null;
  if (myContext instanceof XPathContext.XPathExpressionContext)
    xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext();
  else
    throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext }));

  if (expr == null || expr.length() == 0)
    return Double.NaN;

  NodeSetDTM contextNodes = new NodeSetDTM(nl, xctxt);
  xctxt.pushContextNodeList(contextNodes);

  double minValue = Double.MAX_VALUE;
  for (int i = 0; i < nl.getLength(); i++)
  {
    int contextNode = contextNodes.item(i);
    xctxt.pushCurrentNode(contextNode);

    double result = 0;
    try
    {
      XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                     xctxt.getNamespaceContext(),
                                     XPath.SELECT);
      result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num();
    }
    catch (TransformerException e)
    {
      xctxt.popCurrentNode();
      xctxt.popContextNodeList();
      return Double.NaN;
    }

    xctxt.popCurrentNode();

    if (result < minValue)
        minValue = result;
  }

  xctxt.popContextNodeList();
  return minValue;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:81,代码来源:ExsltDynamic.java


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