下面列出了javax.xml.transform.SourceLocator#getSystemId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* <code>systemId</code> returns the system id of the node passed as
* argument. If a node set is passed as argument, the system id of
* the first node in the set is returned.
*
* @param nodeList a <code>NodeList</code> value
* @return a <code>String</code> value
*/
public static String systemId(NodeList nodeList)
{
if (nodeList == null || nodeList.getLength() == 0)
return null;
Node node = nodeList.item(0);
int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)node).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the node passed as
* argument. If a node set is passed as argument, the system id of
* the first node in the set is returned.
*
* @param nodeList a <code>NodeList</code> value
* @return a <code>String</code> value
*/
public static String systemId(NodeList nodeList)
{
if (nodeList == null || nodeList.getLength() == 0)
return null;
Node node = nodeList.item(0);
int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)node).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the node passed as
* argument. If a node set is passed as argument, the system id of
* the first node in the set is returned.
*
* @param nodeList a <code>NodeList</code> value
* @return a <code>String</code> value
*/
public static String systemId(NodeList nodeList)
{
if (nodeList == null || nodeList.getLength() == 0)
return null;
Node node = nodeList.item(0);
int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)node).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the node passed as
* argument. If a node set is passed as argument, the system id of
* the first node in the set is returned.
*
* @param nodeList a <code>NodeList</code> value
* @return a <code>String</code> value
*/
public static String systemId(NodeList nodeList)
{
if (nodeList == null || nodeList.getLength() == 0)
return null;
Node node = nodeList.item(0);
int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)node).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
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>systemId</code> returns the system id of the node passed as
* argument. If a node set is passed as argument, the system id of
* the first node in the set is returned.
*
* @param nodeList a <code>NodeList</code> value
* @return a <code>String</code> value
*/
public static String systemId(NodeList nodeList)
{
if (nodeList == null || nodeList.getLength() == 0)
return null;
Node node = nodeList.item(0);
int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)node).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the current
* context node.
*
* @param context an <code>ExpressionContext</code> value
* @return a <code>String</code> value
*/
public static String systemId(ExpressionContext context)
{
Node contextNode = context.getContextNode();
int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the current
* context node.
*
* @param context an <code>ExpressionContext</code> value
* @return a <code>String</code> value
*/
public static String systemId(ExpressionContext context)
{
Node contextNode = context.getContextNode();
int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the current
* context node.
*
* @param context an <code>ExpressionContext</code> value
* @return a <code>String</code> value
*/
public static String systemId(ExpressionContext context)
{
Node contextNode = context.getContextNode();
int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the current
* context node.
*
* @param context an <code>ExpressionContext</code> value
* @return a <code>String</code> value
*/
public static String systemId(ExpressionContext context)
{
Node contextNode = context.getContextNode();
int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the current
* context node.
*
* @param context an <code>ExpressionContext</code> value
* @return a <code>String</code> value
*/
public static String systemId(ExpressionContext context)
{
Node contextNode = context.getContextNode();
int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
/**
* <code>systemId</code> returns the system id of the current
* context node.
*
* @param context an <code>ExpressionContext</code> value
* @return a <code>String</code> value
*/
public static String systemId(ExpressionContext context)
{
Node contextNode = context.getContextNode();
int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getSystemId();
else
return null;
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}
public static void printLocation(PrintWriter pw, Throwable exception)
{
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 WrappedRuntimeException)
cause = ((WrappedRuntimeException)cause).getException();
else if(cause instanceof SAXException)
cause = ((SAXException)cause).getException();
else
cause = null;
}
while(null != cause);
if(null != locator)
{
// m_pw.println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
}
else
pw.print("("+XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null)+")");
}