下面列出了javax.xml.transform.SourceLocator#getLineNumber ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* <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;
}
/**
* <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;
}
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();
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}
/**
* <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;
}