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

The following examples show how to use javax.xml.transform.SourceLocator#getPublicId() . 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>publicId</code> returns the public identifier of the node passed as
 * argument. If a node set is passed as argument, the public identifier of
 * the first node in the set is returned.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return a <code>String</code> value
 */
public static String publicId(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.getPublicId();
  else
    return null;
}
 
Example 2
Source File: NodeInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the node passed as
 * argument. If a node set is passed as argument, the public identifier of
 * the first node in the set is returned.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return a <code>String</code> value
 */
public static String publicId(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.getPublicId();
  else
    return null;
}
 
Example 3
Source File: NodeInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the node passed as
 * argument. If a node set is passed as argument, the public identifier of
 * the first node in the set is returned.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return a <code>String</code> value
 */
public static String publicId(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.getPublicId();
  else
    return null;
}
 
Example 4
Source File: NodeInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the node passed as
 * argument. If a node set is passed as argument, the public identifier of
 * the first node in the set is returned.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return a <code>String</code> value
 */
public static String publicId(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.getPublicId();
  else
    return null;
}
 
Example 5
Source File: NodeInfo.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the node passed as
 * argument. If a node set is passed as argument, the public identifier of
 * the first node in the set is returned.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return a <code>String</code> value
 */
public static String publicId(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.getPublicId();
  else
    return null;
}
 
Example 6
Source File: NodeInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the node passed as
 * argument. If a node set is passed as argument, the public identifier of
 * the first node in the set is returned.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return a <code>String</code> value
 */
public static String publicId(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.getPublicId();
  else
    return null;
}
 
Example 7
Source File: NodeInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the node passed as
 * argument. If a node set is passed as argument, the public identifier of
 * the first node in the set is returned.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return a <code>String</code> value
 */
public static String publicId(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.getPublicId();
  else
    return null;
}
 
Example 8
Source File: NodeInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the current
 * context node.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return a <code>String</code> value
 */
public static String publicId(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getPublicId();
  else
    return null;
}
 
Example 9
Source File: NodeInfo.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the current
 * context node.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return a <code>String</code> value
 */
public static String publicId(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getPublicId();
  else
    return null;
}
 
Example 10
Source File: NodeInfo.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the current
 * context node.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return a <code>String</code> value
 */
public static String publicId(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getPublicId();
  else
    return null;
}
 
Example 11
Source File: ProcessXSLT.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void printLocation(PrintWriter diagnosticsWriter, Throwable throwable) {
    try {
        Class<?> errorHandler =
                Class.forName("com.sun.org.apache.xml.internal.utils.DefaultErrorHandler");
        Method m = errorHandler.getMethod("printLocation", PrintWriter.class, Throwable.class);
        m.invoke(null, diagnosticsWriter, throwable);
    } catch (Throwable t) {
        SourceLocator locator = null;
        Throwable cause = throwable;

        // Try to find the locator closest to the cause.
        do {
            if (cause instanceof TransformerException) {
                SourceLocator causeLocator = ((TransformerException) cause).getLocator();
                if (null != causeLocator) {
                    locator = causeLocator;
                }
                cause = ((TransformerException) cause).getCause();
            } else if (cause instanceof SAXException) {
                cause = ((SAXException) cause).getException();
            } else {
                cause = cause.getCause();
            }
        } 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() : "SystemId Unknown"; //"SystemId Unknown";

            diagnosticsWriter.print(id + "; " + "line: " + locator.getLineNumber()
                    + "; column: " + locator.getColumnNumber() + "; ");
        }
        diagnosticsWriter.print("(" + throwable + ": unknown location)");
    }
}
 
Example 12
Source File: NodeInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the current
 * context node.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return a <code>String</code> value
 */
public static String publicId(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getPublicId();
  else
    return null;
}
 
Example 13
Source File: NodeInfo.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <code>publicId</code> returns the public identifier of the current
 * context node.
 *
 * Xalan does not currently record this value, and will return null.
 *
 * @param context an <code>ExpressionContext</code> value
 * @return a <code>String</code> value
 */
public static String publicId(ExpressionContext context)
{
  Node contextNode = context.getContextNode();
  int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber();
  SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM()
    .getSourceLocatorFor(nodeHandler);

  if (locator != null)
    return locator.getPublicId();
  else
    return null;
}
 
Example 14
Source File: DefaultErrorHandler.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
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)+")");
}
 
Example 15
Source File: DefaultErrorHandler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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)+")");
}
 
Example 16
Source File: DefaultErrorHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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)+")");
}
 
Example 17
Source File: DefaultErrorHandler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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)+")");
}
 
Example 18
Source File: DefaultErrorHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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)+")");
}
 
Example 19
Source File: DefaultErrorHandler.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
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)+")");
}
 
Example 20
Source File: DefaultErrorHandler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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)+")");
}