Java Code Examples for javax.xml.transform.SourceLocator#getLineNumber()

The following examples show how to use javax.xml.transform.SourceLocator#getLineNumber() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeInfo.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 2
Source File: NodeInfo.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 3
Source File: NodeInfo.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 4
Source File: NodeInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 5
Source File: NodeInfo.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 6
Source File: NodeInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 7
Source File: NodeInfo.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 8
Source File: NodeInfo.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 9
Source File: MCRErrorListener.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
public static String getMyMessageAndLocation(TransformerException exception) {
    SourceLocator locator = exception.getLocator();
    StringBuilder msg = new StringBuilder();
    if (locator != null) {
        String systemID = locator.getSystemId();
        int line = locator.getLineNumber();
        int col = locator.getColumnNumber();
        if (systemID != null) {
            msg.append("SystemID: ");
            msg.append(systemID);
        }
        if (line != 0) {
            msg.append(" [");
            msg.append(line);
            if (col != 0) {
                msg.append(',');
                msg.append(col);
            }
            msg.append("]");
        }
    }
    msg.append(": ");
    msg.append(exception.getMessage());
    return msg.toString();
}
 
Example 10
Source File: NodeInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

  Node node = nodeList.item(0);
  int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)node).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 11
Source File: NodeInfo.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 12
Source File: NodeInfo.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 13
Source File: NodeInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 14
Source File: NodeInfo.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 15
Source File: NodeInfo.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 16
Source File: NodeInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 17
Source File: NodeInfo.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 18
Source File: NodeInfo.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 19
Source File: NodeInfo.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example 20
Source File: NodeInfo.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the current
 * context node.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}