19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file
49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information
59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file
69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License.
89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at
99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software
139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and
169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License.
179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: MsgMgr.java 468645 2006-10-28 06:57:24Z minchau $
209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xalan.transformer;
229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.ErrorListener;
249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.SourceLocator;
259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.TransformerException;
269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.res.XSLMessages;
289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.w3c.dom.Node;
309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/**
329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This class will manage error messages, warning messages, and other types of
339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * message events.
349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class MsgMgr
369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{
379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Create a message manager object.
409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param transformer non transformer instance
429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public MsgMgr(TransformerImpl transformer)
449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_transformer = transformer;
469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Transformer instance          */
499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private TransformerImpl m_transformer;
509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Warn the user of a problem.
539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This is public for access by extensions.
549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg The message text to issue
569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param terminate Flag indicating whether to terminate this process
579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void message(SourceLocator srcLctr, String msg, boolean terminate) throws TransformerException
639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    ErrorListener errHandler = m_transformer.getErrorListener();
669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (null != errHandler)
689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      errHandler.warning(new TransformerException(msg, srcLctr));
709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      if (terminate)
749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        throw new TransformerException(msg, srcLctr);
759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      else
769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        System.out.println(msg);
779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Warn the user of a problem.
829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void warn(SourceLocator srcLctr, String msg) throws TransformerException
919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    warn(srcLctr, null, null, msg, null);
939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Warn the user of a problem.
979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param args Arguments to pass to the message
1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void warn(SourceLocator srcLctr, String msg, Object[] args) throws TransformerException
1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    warn(srcLctr, null, null, msg, args);
1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Warn the user of a problem.
1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param styleNode Stylesheet node
1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param sourceNode Source tree node
1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void warn(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg)
1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          throws TransformerException
1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    warn(srcLctr, styleNode, sourceNode, msg, null);
1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Warn the user of a problem.
1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param styleNode Stylesheet node
1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param sourceNode Source tree node
1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param args Arguments to pass to the message
1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void warn(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg, Object args[])
1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          throws TransformerException
1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    String formattedMsg = XSLMessages.createWarning(msg, args);
1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    ErrorListener errHandler = m_transformer.getErrorListener();
1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (null != errHandler)
1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      errHandler.warning(new TransformerException(formattedMsg, srcLctr));
1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      System.out.println(formattedMsg);
1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /* This method is not properly i18nized. We need to use the following method
1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell the user of an error, and probably throw an
1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception.
1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void error(SourceLocator srcLctr, String msg) throws TransformerException
1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Locator locator = m_stylesheetLocatorStack.isEmpty()
1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //                  ? null :
1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //                    ((Locator)m_stylesheetLocatorStack.peek());
1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Locator locator = null;
1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    ErrorListener errHandler = m_transformer.getErrorListener();
1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (null != errHandler)
1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      errHandler.fatalError(new TransformerException(msg, srcLctr));
1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      throw new TransformerException(msg, srcLctr);
1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @xsl.usage internal
1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell the user of an error, and probably throw an
1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception.
1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void error(SourceLocator srcLctr, String msg) throws TransformerException
1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    error(srcLctr, null, null, msg, null);
1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell the user of an error, and probably throw an
2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception.
2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param args Arguments to be passed to the message
2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void error(SourceLocator srcLctr, String msg, Object[] args) throws TransformerException
2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    error(srcLctr, null, null, msg, args);
2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell the user of an error, and probably throw an
2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception.
2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param e Exception to throw
2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void error(SourceLocator srcLctr, String msg, Exception e) throws TransformerException
2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    error(srcLctr, msg, null, e);
2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell the user of an error, and probably throw an
2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception.
2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param args Arguments to use in message
2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param e Exception to throw
2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void error(SourceLocator srcLctr, String msg, Object args[], Exception e) throws TransformerException
2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //msg  = (null == msg) ? XSLTErrorResources.ER_PROCESSOR_ERROR : msg;
2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    String formattedMsg = XSLMessages.createMessage(msg, args);
2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Locator locator = m_stylesheetLocatorStack.isEmpty()
2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //                   ? null :
2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //                    ((Locator)m_stylesheetLocatorStack.peek());
2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Locator locator = null;
2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    ErrorListener errHandler = m_transformer.getErrorListener();
2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (null != errHandler)
2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      errHandler.fatalError(new TransformerException(formattedMsg, srcLctr));
2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      throw new TransformerException(formattedMsg, srcLctr);
2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell the user of an error, and probably throw an
2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception.
2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param styleNode Stylesheet node
2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param sourceNode Source tree node
2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void error(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg)
2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          throws TransformerException
2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    error(srcLctr, styleNode, sourceNode, msg, null);
2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell the user of an error, and probably throw an
2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception.
2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param styleNode Stylesheet node
2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param sourceNode Source tree node
2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param msg Message text to issue
2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param args Arguments to use in message
2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the error condition is severe enough to halt processing.
2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws TransformerException
2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @xsl.usage internal
2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void error(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg, Object args[])
2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          throws TransformerException
3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    String formattedMsg = XSLMessages.createMessage(msg, args);
3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Locator locator = m_stylesheetLocatorStack.isEmpty()
3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //                   ? null :
3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //                    ((Locator)m_stylesheetLocatorStack.peek());
3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Locator locator = null;
3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    ErrorListener errHandler = m_transformer.getErrorListener();
3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (null != errHandler)
3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      errHandler.fatalError(new TransformerException(formattedMsg, srcLctr));
3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      throw new TransformerException(formattedMsg, srcLctr);
3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}
316