com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy. 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 JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * <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;
}
 
Example #2
Source File: NodeInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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;
}
 
Example #3
Source File: NodeInfo.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * <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;
}
 
Example #4
Source File: ExsltBase.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string value of a Node
 *
 * @param n The Node.
 * @return The string value of the Node
 */
protected static String toString(Node n)
{
  if (n instanceof DTMNodeProxy)
       return ((DTMNodeProxy)n).getStringValue();
  else
  {
    String value = n.getNodeValue();
    if (value == null)
    {
      NodeList nodelist = n.getChildNodes();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < nodelist.getLength(); i++)
      {
        Node childNode = nodelist.item(i);
        buf.append(toString(childNode));
      }
      return buf.toString();
    }
    else
      return value;
  }
}
 
Example #5
Source File: SAXImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Create an org.w3c.dom.Node from a node in the tree
 */
public Node makeNode(int index) {
    if (_nodes == null) {
        _nodes = new Node[_namesSize];
    }

    int nodeID = makeNodeIdentity(index);
    if (nodeID < 0) {
        return null;
    }
    else if (nodeID < _nodes.length) {
        return (_nodes[nodeID] != null) ? _nodes[nodeID]
            : (_nodes[nodeID] = new DTMNodeProxy((DTM)this, index));
    }
    else {
        return new DTMNodeProxy((DTM)this, index);
    }
}
 
Example #6
Source File: NodeInfo.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * <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;
}
 
Example #7
Source File: ExsltBase.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string value of a Node
 *
 * @param n The Node.
 * @return The string value of the Node
 */
protected static String toString(Node n)
{
  if (n instanceof DTMNodeProxy)
       return ((DTMNodeProxy)n).getStringValue();
  else
  {
    String value = n.getNodeValue();
    if (value == null)
    {
      NodeList nodelist = n.getChildNodes();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < nodelist.getLength(); i++)
      {
        Node childNode = nodelist.item(i);
        buf.append(toString(childNode));
      }
      return buf.toString();
    }
    else
      return value;
  }
}
 
Example #8
Source File: NodeInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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;
}
 
Example #9
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 #10
Source File: NodeInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

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

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example #11
Source File: ExsltBase.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Return the string value of a Node
 *
 * @param n The Node.
 * @return The string value of the Node
 */
protected static String toString(Node n)
{
  if (n instanceof DTMNodeProxy)
       return ((DTMNodeProxy)n).getStringValue();
  else
  {
    String value = n.getNodeValue();
    if (value == null)
    {
      NodeList nodelist = n.getChildNodes();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < nodelist.getLength(); i++)
      {
        Node childNode = nodelist.item(i);
        buf.append(toString(childNode));
      }
      return buf.toString();
    }
    else
      return value;
  }
}
 
Example #12
Source File: NodeInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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;
}
 
Example #13
Source File: SAXImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create an org.w3c.dom.Node from a node in the tree
 */
public Node makeNode(int index) {
    if (_nodes == null) {
        _nodes = new Node[_namesSize];
    }

    int nodeID = makeNodeIdentity(index);
    if (nodeID < 0) {
        return null;
    }
    else if (nodeID < _nodes.length) {
        return (_nodes[nodeID] != null) ? _nodes[nodeID]
            : (_nodes[nodeID] = new DTMNodeProxy((DTM)this, index));
    }
    else {
        return new DTMNodeProxy((DTM)this, index);
    }
}
 
Example #14
Source File: ExsltBase.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Return the string value of a Node
 *
 * @param n The Node.
 * @return The string value of the Node
 */
protected static String toString(Node n)
{
  if (n instanceof DTMNodeProxy)
       return ((DTMNodeProxy)n).getStringValue();
  else
  {
    String value = n.getNodeValue();
    if (value == null)
    {
      NodeList nodelist = n.getChildNodes();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < nodelist.getLength(); i++)
      {
        Node childNode = nodelist.item(i);
        buf.append(toString(childNode));
      }
      return buf.toString();
    }
    else
      return value;
  }
}
 
Example #15
Source File: SAXImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create an org.w3c.dom.Node from a node in the tree
 */
public Node makeNode(int index) {
    if (_nodes == null) {
        _nodes = new Node[_namesSize];
    }

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

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

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

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

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example #21
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 #22
Source File: NodeInfo.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * <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;
}
 
Example #23
Source File: SAXImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Create an org.w3c.dom.Node from a node in the tree
 */
public Node makeNode(int index) {
    if (_nodes == null) {
        _nodes = new Node[_namesSize];
    }

    int nodeID = makeNodeIdentity(index);
    if (nodeID < 0) {
        return null;
    }
    else if (nodeID < _nodes.length) {
        return (_nodes[nodeID] != null) ? _nodes[nodeID]
            : (_nodes[nodeID] = new DTMNodeProxy((DTM)this, index));
    }
    else {
        return new DTMNodeProxy((DTM)this, index);
    }
}
 
Example #24
Source File: ExsltBase.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string value of a Node
 *
 * @param n The Node.
 * @return The string value of the Node
 */
protected static String toString(Node n)
{
  if (n instanceof DTMNodeProxy)
       return ((DTMNodeProxy)n).getStringValue();
  else
  {
    String value = n.getNodeValue();
    if (value == null)
    {
      NodeList nodelist = n.getChildNodes();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < nodelist.getLength(); i++)
      {
        Node childNode = nodelist.item(i);
        buf.append(toString(childNode));
      }
      return buf.toString();
    }
    else
      return value;
  }
}
 
Example #25
Source File: NodeInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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;
}
 
Example #26
Source File: NodeInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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;
}
 
Example #27
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 #28
Source File: ExsltBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string value of a Node
 *
 * @param n The Node.
 * @return The string value of the Node
 */
protected static String toString(Node n)
{
  if (n instanceof DTMNodeProxy)
       return ((DTMNodeProxy)n).getStringValue();
  else
  {
    String value = n.getNodeValue();
    if (value == null)
    {
      NodeList nodelist = n.getChildNodes();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < nodelist.getLength(); i++)
      {
        Node childNode = nodelist.item(i);
        buf.append(toString(childNode));
      }
      return buf.toString();
    }
    else
      return value;
  }
}
 
Example #29
Source File: NodeInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <code>lineNumber</code> returns the line number of the node
 * passed as argument. If a node set is passed as argument, the line
 * number of the first node in the set is returned.
 *
 * NOTE: Xalan does not normally record location information for each node.
 * To obtain it, you must set the custom TrAX attribute
 * "http://xml.apache.org/xalan/features/source_location"
 * true in the TransformerFactory before generating the Transformer and executing
 * the stylesheet. Storage cost per node will be noticably increased in this mode.
 *
 * @param nodeList a <code>NodeList</code> value
 * @return an <code>int</code> value. This may be -1 to indicate that the
 * line number is not known.
 */
public static int lineNumber(NodeList nodeList)
{
  if (nodeList == null || nodeList.getLength() == 0)
    return -1;

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

  if (locator != null)
    return locator.getLineNumber();
  else
    return -1;
}
 
Example #30
Source File: SAXImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create an org.w3c.dom.Node from a node in the tree
 */
public Node makeNode(int index) {
    if (_nodes == null) {
        _nodes = new Node[_namesSize];
    }

    int nodeID = makeNodeIdentity(index);
    if (nodeID < 0) {
        return null;
    }
    else if (nodeID < _nodes.length) {
        return (_nodes[nodeID] != null) ? _nodes[nodeID]
            : (_nodes[nodeID] = new DTMNodeProxy((DTM)this, index));
    }
    else {
        return new DTMNodeProxy((DTM)this, index);
    }
}