Java 类javax.xml.transform.SourceLocator 实例源码

项目:OpenJSharp    文件:NodeInfo.java   
/**
 * <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;
}
项目:OpenJSharp    文件:NodeInfo.java   
/**
 * <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;
}
项目:OpenJSharp    文件:NodeInfo.java   
/**
 * <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;
}
项目:OpenJSharp    文件:NodeInfo.java   
/**
 * <code>columnNumber</code> returns the column 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
 * column number is not known.
 */
public static int columnNumber(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.getColumnNumber();
  else
    return -1;
}
项目:OpenJSharp    文件:SAX2DTM.java   
/** Retrieve the SourceLocator associated with a specific node.
 * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was
 * set True using setProperty; if it was never set, or was set false, we
 * will return null.
 *
 * (We _could_ return a locator with the document's base URI and bogus
 * line/column information. Trying that; see the else clause.)
 * */
public SourceLocator getSourceLocatorFor(int node)
{
  if (m_useSourceLocationProperty)
  {

    node = makeNodeIdentity(node);


    return new NodeLocator(null,
                           m_sourceSystemId.elementAt(node),
                           m_sourceLine.elementAt(node),
                           m_sourceColumn.elementAt(node));
  }
  else if(m_locator!=null)
  {
      return new NodeLocator(null,m_locator.getSystemId(),-1,-1);
  }
  else if(m_systemId!=null)
  {
      return new NodeLocator(null,m_systemId,-1,-1);
  }
  return null;
}
项目:OpenJSharp    文件:SourceTreeManager.java   
/**
 * Get the source tree from the a base URL and a URL string.
 *
 * @param base The base URI to use if the urlString is relative.
 * @param urlString An absolute or relative URL string.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return should be a non-null reference to the node identified by the
 * base and urlString.
 *
 * @throws TransformerException If the URL can not resolve to a node.
 */
public int getSourceTree(
        String base, String urlString, SourceLocator locator, XPathContext xctxt)
          throws TransformerException
{

  // System.out.println("getSourceTree");
  try
  {
    Source source = this.resolveURI(base, urlString, locator);

    // System.out.println("getSourceTree - base: "+base+", urlString: "+urlString+", source: "+source.getSystemId());
    return getSourceTree(source, locator, xctxt);
  }
  catch (IOException ioe)
  {
    throw new TransformerException(ioe.getMessage(), locator, ioe);
  }

  /* catch (TransformerException te)
   {
     throw new TransformerException(te.getMessage(), locator, te);
   }*/
}
项目:OpenJSharp    文件:SourceTreeManager.java   
/**
 * Get the source tree from the input source.
 *
 * @param source The Source object that should identify the desired node.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return non-null reference to a node.
 *
 * @throws TransformerException if the Source argument can't be resolved to
 *         a node.
 */
public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt)
        throws TransformerException
{

  int n = getNode(source);

  if (DTM.NULL != n)
    return n;

  n = parseToNode(source, locator, xctxt);

  if (DTM.NULL != n)
    putDocumentInCache(n, source);

  return n;
}
项目:OpenJSharp    文件:XPath.java   
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @param msg An error msgkey that corresponds to one of the constants found
 *            in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
 *            a key for a format string.
 * @param args An array of arguments represented in the format string, which
 *             may be null.
 *
 * @throws TransformerException if the current ErrorListoner determines to
 *                              throw an exception.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
项目:openjdk-jdk10    文件:NodeInfo.java   
/**
 * <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;
}
项目:openjdk-jdk10    文件:NodeInfo.java   
/**
 * <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;
}
项目:openjdk-jdk10    文件:NodeInfo.java   
/**
 * <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;
}
项目:openjdk-jdk10    文件:NodeInfo.java   
/**
 * <code>columnNumber</code> returns the column 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
 * column number is not known.
 */
public static int columnNumber(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.getColumnNumber();
  else
    return -1;
}
项目:openjdk-jdk10    文件:SAX2DTM.java   
/** Retrieve the SourceLocator associated with a specific node.
 * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was
 * set True using setProperty; if it was never set, or was set false, we
 * will return null.
 *
 * (We _could_ return a locator with the document's base URI and bogus
 * line/column information. Trying that; see the else clause.)
 * */
public SourceLocator getSourceLocatorFor(int node)
{
  if (m_useSourceLocationProperty)
  {

    node = makeNodeIdentity(node);


    return new NodeLocator(null,
                           m_sourceSystemId.elementAt(node),
                           m_sourceLine.elementAt(node),
                           m_sourceColumn.elementAt(node));
  }
  else if(m_locator!=null)
  {
      return new NodeLocator(null,m_locator.getSystemId(),-1,-1);
  }
  else if(m_systemId!=null)
  {
      return new NodeLocator(null,m_systemId,-1,-1);
  }
  return null;
}
项目:openjdk-jdk10    文件:SourceTreeManager.java   
/**
 * Get the source tree from the a base URL and a URL string.
 *
 * @param base The base URI to use if the urlString is relative.
 * @param urlString An absolute or relative URL string.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return should be a non-null reference to the node identified by the
 * base and urlString.
 *
 * @throws TransformerException If the URL can not resolve to a node.
 */
public int getSourceTree(
        String base, String urlString, SourceLocator locator, XPathContext xctxt)
          throws TransformerException
{

  // System.out.println("getSourceTree");
  try
  {
    Source source = this.resolveURI(base, urlString, locator);

    // System.out.println("getSourceTree - base: "+base+", urlString: "+urlString+", source: "+source.getSystemId());
    return getSourceTree(source, locator, xctxt);
  }
  catch (IOException ioe)
  {
    throw new TransformerException(ioe.getMessage(), locator, ioe);
  }

  /* catch (TransformerException te)
   {
     throw new TransformerException(te.getMessage(), locator, te);
   }*/
}
项目:openjdk-jdk10    文件:SourceTreeManager.java   
/**
 * Get the source tree from the input source.
 *
 * @param source The Source object that should identify the desired node.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return non-null reference to a node.
 *
 * @throws TransformerException if the Source argument can't be resolved to
 *         a node.
 */
public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt)
        throws TransformerException
{

  int n = getNode(source);

  if (DTM.NULL != n)
    return n;

  n = parseToNode(source, locator, xctxt);

  if (DTM.NULL != n)
    putDocumentInCache(n, source);

  return n;
}
项目:openjdk-jdk10    文件:XPath.java   
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @param msg An error msgkey that corresponds to one of the constants found
 *            in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
 *            a key for a format string.
 * @param args An array of arguments represented in the format string, which
 *             may be null.
 *
 * @throws TransformerException if the current ErrorListoner determines to
 *                              throw an exception.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
项目:openjdk9    文件:NodeInfo.java   
/**
 * <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;
}
项目:openjdk9    文件:NodeInfo.java   
/**
 * <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;
}
项目:openjdk9    文件:NodeInfo.java   
/**
 * <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;
}
项目:openjdk9    文件:NodeInfo.java   
/**
 * <code>columnNumber</code> returns the column 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
 * column number is not known.
 */
public static int columnNumber(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.getColumnNumber();
  else
    return -1;
}
项目:openjdk9    文件:SAX2DTM.java   
/** Retrieve the SourceLocator associated with a specific node.
 * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was
 * set True using setProperty; if it was never set, or was set false, we
 * will return null.
 *
 * (We _could_ return a locator with the document's base URI and bogus
 * line/column information. Trying that; see the else clause.)
 * */
public SourceLocator getSourceLocatorFor(int node)
{
  if (m_useSourceLocationProperty)
  {

    node = makeNodeIdentity(node);


    return new NodeLocator(null,
                           m_sourceSystemId.elementAt(node),
                           m_sourceLine.elementAt(node),
                           m_sourceColumn.elementAt(node));
  }
  else if(m_locator!=null)
  {
      return new NodeLocator(null,m_locator.getSystemId(),-1,-1);
  }
  else if(m_systemId!=null)
  {
      return new NodeLocator(null,m_systemId,-1,-1);
  }
  return null;
}
项目:openjdk9    文件:SourceTreeManager.java   
/**
 * This will be called by the processor when it encounters
 * an xsl:include, xsl:import, or document() function.
 *
 * @param base The base URI that should be used.
 * @param urlString Value from an xsl:import or xsl:include's href attribute,
 * or a URI specified in the document() function.
 *
 * @return a Source that can be used to process the resource.
 *
 * @throws IOException
 * @throws TransformerException
 */
public Source resolveURI(
        String base, String urlString, SourceLocator locator)
          throws TransformerException, IOException
{

  Source source = null;

  if (null != m_uriResolver)
  {
    source = m_uriResolver.resolve(urlString, base);
  }

  if (null == source)
  {
    String uri = SystemIDResolver.getAbsoluteURI(urlString, base);

    source = new StreamSource(uri);
  }

  return source;
}
项目:openjdk9    文件:SourceTreeManager.java   
/**
 * Get the source tree from the a base URL and a URL string.
 *
 * @param base The base URI to use if the urlString is relative.
 * @param urlString An absolute or relative URL string.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return should be a non-null reference to the node identified by the
 * base and urlString.
 *
 * @throws TransformerException If the URL can not resolve to a node.
 */
public int getSourceTree(
        String base, String urlString, SourceLocator locator, XPathContext xctxt)
          throws TransformerException
{

  // System.out.println("getSourceTree");
  try
  {
    Source source = this.resolveURI(base, urlString, locator);

    // System.out.println("getSourceTree - base: "+base+", urlString: "+urlString+", source: "+source.getSystemId());
    return getSourceTree(source, locator, xctxt);
  }
  catch (IOException ioe)
  {
    throw new TransformerException(ioe.getMessage(), locator, ioe);
  }

  /* catch (TransformerException te)
   {
     throw new TransformerException(te.getMessage(), locator, te);
   }*/
}
项目:openjdk9    文件:SourceTreeManager.java   
/**
 * Get the source tree from the input source.
 *
 * @param source The Source object that should identify the desired node.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return non-null reference to a node.
 *
 * @throws TransformerException if the Source argument can't be resolved to
 *         a node.
 */
public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt)
        throws TransformerException
{

  int n = getNode(source);

  if (DTM.NULL != n)
    return n;

  n = parseToNode(source, locator, xctxt);

  if (DTM.NULL != n)
    putDocumentInCache(n, source);

  return n;
}
项目:openjdk9    文件:XPath.java   
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @param msg An error msgkey that corresponds to one of the constants found
 *            in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
 *            a key for a format string.
 * @param args An array of arguments represented in the format string, which
 *             may be null.
 *
 * @throws TransformerException if the current ErrorListoner determines to
 *                              throw an exception.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
项目:mycore    文件:MCRErrorListener.java   
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();
}
项目:mycore    文件:MCRTemplatesCompiler.java   
private static String buildErrorMessage(String resource, Exception cause) {
    StringBuilder msg = new StringBuilder("Error compiling XSL stylesheet ");
    msg.append(resource);

    if (cause instanceof TransformerException) {
        TransformerException tex = (TransformerException) cause;
        msg.append("\n").append(tex.getMessage());
        SourceLocator sl = tex.getLocator();
        if (sl != null) {
            msg.append(" (").append(sl.getSystemId()).append(") ");
            msg.append(" at line ").append(sl.getLineNumber());
            msg.append(" column ").append(sl.getColumnNumber());
        }
    }

    return msg.toString();
}
项目:lookaside_java-1.8.0-openjdk    文件:NodeInfo.java   
/**
 * <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;
}
项目:lookaside_java-1.8.0-openjdk    文件:NodeInfo.java   
/**
 * <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;
}
项目:lookaside_java-1.8.0-openjdk    文件:NodeInfo.java   
/**
 * <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;
}
项目:lookaside_java-1.8.0-openjdk    文件:NodeInfo.java   
/**
 * <code>columnNumber</code> returns the column 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
 * column number is not known.
 */
public static int columnNumber(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.getColumnNumber();
  else
    return -1;
}
项目:lookaside_java-1.8.0-openjdk    文件:SAX2DTM.java   
/** Retrieve the SourceLocator associated with a specific node.
 * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was
 * set True using setProperty; if it was never set, or was set false, we
 * will return null.
 *
 * (We _could_ return a locator with the document's base URI and bogus
 * line/column information. Trying that; see the else clause.)
 * */
public SourceLocator getSourceLocatorFor(int node)
{
  if (m_useSourceLocationProperty)
  {

    node = makeNodeIdentity(node);


    return new NodeLocator(null,
                           m_sourceSystemId.elementAt(node),
                           m_sourceLine.elementAt(node),
                           m_sourceColumn.elementAt(node));
  }
  else if(m_locator!=null)
  {
      return new NodeLocator(null,m_locator.getSystemId(),-1,-1);
  }
  else if(m_systemId!=null)
  {
      return new NodeLocator(null,m_systemId,-1,-1);
  }
  return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:SourceTreeManager.java   
/**
 * This will be called by the processor when it encounters
 * an xsl:include, xsl:import, or document() function.
 *
 * @param base The base URI that should be used.
 * @param urlString Value from an xsl:import or xsl:include's href attribute,
 * or a URI specified in the document() function.
 *
 * @return a Source that can be used to process the resource.
 *
 * @throws IOException
 * @throws TransformerException
 */
public Source resolveURI(
        String base, String urlString, SourceLocator locator)
          throws TransformerException, IOException
{

  Source source = null;

  if (null != m_uriResolver)
  {
    source = m_uriResolver.resolve(urlString, base);
  }

  if (null == source)
  {
    String uri = SystemIDResolver.getAbsoluteURI(urlString, base);

    source = new StreamSource(uri);
  }

  return source;
}
项目:lookaside_java-1.8.0-openjdk    文件:SourceTreeManager.java   
/**
 * Get the source tree from the a base URL and a URL string.
 *
 * @param base The base URI to use if the urlString is relative.
 * @param urlString An absolute or relative URL string.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return should be a non-null reference to the node identified by the
 * base and urlString.
 *
 * @throws TransformerException If the URL can not resolve to a node.
 */
public int getSourceTree(
        String base, String urlString, SourceLocator locator, XPathContext xctxt)
          throws TransformerException
{

  // System.out.println("getSourceTree");
  try
  {
    Source source = this.resolveURI(base, urlString, locator);

    // System.out.println("getSourceTree - base: "+base+", urlString: "+urlString+", source: "+source.getSystemId());
    return getSourceTree(source, locator, xctxt);
  }
  catch (IOException ioe)
  {
    throw new TransformerException(ioe.getMessage(), locator, ioe);
  }

  /* catch (TransformerException te)
   {
     throw new TransformerException(te.getMessage(), locator, te);
   }*/
}
项目:lookaside_java-1.8.0-openjdk    文件:SourceTreeManager.java   
/**
 * Get the source tree from the input source.
 *
 * @param source The Source object that should identify the desired node.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return non-null reference to a node.
 *
 * @throws TransformerException if the Source argument can't be resolved to
 *         a node.
 */
public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt)
        throws TransformerException
{

  int n = getNode(source);

  if (DTM.NULL != n)
    return n;

  n = parseToNode(source, locator, xctxt);

  if (DTM.NULL != n)
    putDocumentInCache(n, source);

  return n;
}
项目:lookaside_java-1.8.0-openjdk    文件:XPath.java   
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @param msg An error msgkey that corresponds to one of the constants found
 *            in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
 *            a key for a format string.
 * @param args An array of arguments represented in the format string, which
 *             may be null.
 *
 * @throws TransformerException if the current ErrorListoner determines to
 *                              throw an exception.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
项目:javify    文件:GnomeTransformer.java   
private void warning (String message,
                      int lineNumber,
                      int columnNumber,
                      String publicId,
                      String systemId)
  throws TransformerException
{
  if (errorListener == null)
    {
      return;
    }
  SourceLocator l = new StandaloneLocator (lineNumber,
                                           columnNumber,
                                           publicId,
                                           systemId);
  errorListener.warning (new TransformerException (message, l));
}
项目:javify    文件:GnomeTransformer.java   
private void error (String message,
                    int lineNumber,
                    int columnNumber,
                    String publicId,
                    String systemId)
  throws TransformerException
{
  if (errorListener == null)
    {
      return;
    }
  SourceLocator l = new StandaloneLocator (lineNumber,
                                           columnNumber,
                                           publicId,
                                           systemId);
  errorListener.error (new TransformerException (message, l));
}
项目:javify    文件:GnomeTransformer.java   
private void fatalError (String message,
                         int lineNumber,
                         int columnNumber,
                         String publicId,
                         String systemId)
  throws TransformerException
{
  if (errorListener == null)
    {
      return;
    }
  SourceLocator l = new StandaloneLocator (lineNumber,
                                           columnNumber,
                                           publicId,
                                           systemId);
  errorListener.fatalError (new TransformerException (message, l));
}
项目:jvm-stm    文件:GnomeTransformer.java   
private void warning (String message,
                      int lineNumber,
                      int columnNumber,
                      String publicId,
                      String systemId)
  throws TransformerException
{
  if (errorListener == null)
    {
      return;
    }
  SourceLocator l = new StandaloneLocator (lineNumber,
                                           columnNumber,
                                           publicId,
                                           systemId);
  errorListener.warning (new TransformerException (message, l));
}