javax.xml.transform.TransformerException#setLocator ( )源码实例Demo

下面列出了javax.xml.transform.TransformerException#setLocator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码2 项目: TencentKona-8   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码3 项目: jdk8u60   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码4 项目: JDKSourceCode1.8   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码5 项目: openjdk-jdk8u   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码7 项目: Bytecoder   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码8 项目: openjdk-jdk9   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码9 项目: hottub   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码10 项目: openjdk-8-source   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码11 项目: openjdk-8   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;

  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }

    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);

  exception.setLocator(locator);
}
 
源代码12 项目: j2objc   文件: DefaultErrorHandler.java
public static void ensureLocationSet(TransformerException exception)
{
  // SourceLocator locator = exception.getLocator();
  SourceLocator locator = null;
  Throwable cause = exception;
  
  // Try to find the locator closest to the cause.
  do
  {
    if(cause instanceof SAXParseException)
    {
      locator = new SAXSourceLocator((SAXParseException)cause);
    }
    else if (cause instanceof TransformerException)
    {
      SourceLocator causeLocator = ((TransformerException)cause).getLocator();
      if(null != causeLocator)
        locator = causeLocator;
    }
    
    if(cause instanceof TransformerException)
      cause = ((TransformerException)cause).getCause();
    else if(cause instanceof SAXException)
      cause = ((SAXException)cause).getException();
    else
      cause = null;
  }
  while(null != cause);
  
  exception.setLocator(locator);
}
 
源代码13 项目: j2objc   文件: ElemValueOf.java
/**
 * Execute the string expression and copy the text to the
 * result tree.
 * The required select attribute is an expression; this expression
 * is evaluated and the resulting object is converted to a string
 * as if by a call to the string function. The string specifies
 * the string-value of the created text node. If the string is
 * empty, no text node will be created. The created text node will
 * be merged with any adjacent text nodes.
 * @see <a href="http://www.w3.org/TR/xslt#value-of">value-of in XSLT Specification</a>
 *
 * @param transformer non-null reference to the the current transform-time state.
 *
 * @throws TransformerException
 */
public void execute(TransformerImpl transformer) throws TransformerException
{

  XPathContext xctxt = transformer.getXPathContext();
  SerializationHandler rth = transformer.getResultTreeHandler();

  try
  {
    // Optimize for "."
      xctxt.pushNamespaceContext(this);

      int current = xctxt.getCurrentNode();

      xctxt.pushCurrentNodeAndExpression(current, current);

      if (m_disableOutputEscaping)
        rth.processingInstruction(
          javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");

      try
      {
        Expression expr = m_selectExpression.getExpression();

          expr.executeCharsToContentHandler(xctxt, rth);
      }
      finally
      {
        if (m_disableOutputEscaping)
          rth.processingInstruction(
            javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");

        xctxt.popNamespaceContext();
        xctxt.popCurrentNodeAndExpression();
      }
  }
  catch (SAXException se)
  {
    throw new TransformerException(se);
  }
  catch (RuntimeException re) {
  	TransformerException te = new TransformerException(re);
  	te.setLocator(this);
  	throw te;
  }
}
 
源代码14 项目: j2objc   文件: TransformerImpl.java
/**
   * Execute each of the children of a template element.
   *
   * @param elem The ElemTemplateElement that contains the children
   * that should execute.
   * @param shouldAddAttrs true if xsl:attributes should be executed.
   *
   * @throws TransformerException
   * @xsl.usage advanced
   */
  public void executeChildTemplates(
          ElemTemplateElement elem, boolean shouldAddAttrs)
            throws TransformerException
  {

    // Does this element have any children?
    ElemTemplateElement t = elem.getFirstChildElem();

    if (null == t)
      return;      
    
    if(elem.hasTextLitOnly() && m_optimizer)
    {      
      char[] chars = ((ElemTextLiteral)t).getChars();
      try
      {
        // Have to push stuff on for tooling...
        this.pushElemTemplateElement(t);
        m_serializationHandler.characters(chars, 0, chars.length);
      }
      catch(SAXException se)
      {
        throw new TransformerException(se);
      }
      finally
      {
        this.popElemTemplateElement();
      }
      return;
    }

//    // Check for infinite loops if we have to.
//    boolean check = (m_stackGuard.m_recursionLimit > -1);
//
//    if (check)
//      getStackGuard().push(elem, xctxt.getCurrentNode());

    XPathContext xctxt = m_xcontext;
    xctxt.pushSAXLocatorNull();
    int currentTemplateElementsTop = m_currentTemplateElements.size();
    m_currentTemplateElements.push(null);

    try
    {
      // Loop through the children of the template, calling execute on 
      // each of them.
      for (; t != null; t = t.getNextSiblingElem())
      {
        if (!shouldAddAttrs
                && t.getXSLToken() == Constants.ELEMNAME_ATTRIBUTE)
          continue;

        xctxt.setSAXLocator(t);
        m_currentTemplateElements.setElementAt(t,currentTemplateElementsTop);
        t.execute(this);
      }
    }
    catch(RuntimeException re)
    {
    	TransformerException te = new TransformerException(re);
    	te.setLocator(t);
    	throw te;
    }
    finally
    {
      m_currentTemplateElements.pop();
      xctxt.popSAXLocator();
    }

    // Check for infinite loops if we have to
//    if (check)
//      getStackGuard().pop();
  }