Xalan 2.7.1 TransformerFactory.transform gives out invalid xml.
----------------------------------------------------------------

                 Key: XALANJ-2552
                 URL: https://issues.apache.org/jira/browse/XALANJ-2552
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in 
Xalan projects.  Anybody can view the issue.)
          Components: transformation
    Affects Versions: 2.7.1
            Reporter: Jeganathan


In Xalan 2.7.1, Treewalker.java uses Object.equals() API to compare two 
nodes.Node.isEqualNode() API should have been used instead.Because of this 
serialization gives out improper xml.
DOM specification does not mandate overriding Object.equals() API. Previous 
release of Xalan that is bundled with JDK1.6 was working fine.


{code}
<root><child1/></root>
{code}
if I give the node corresponding to 'child1' the transformed xml gives out 
{code}
<child1></root>
{code}


The code snippet where the equals used instead of Node.isEqualNode() is given 
below.
 /**
   * Perform a pre-order traversal non-recursive style.

   * Note that TreeWalker assumes that the subtree is intended to represent
   * a complete (though not necessarily well-formed) document and, during a
   * traversal, startDocument and endDocument will always be issued to the
   * SAX listener.
   *
   * @param pos Node in the tree where to start traversal
   * @param top Node in the tree where to end traversal
   *
   * @throws TransformerException
   */
  public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
  {

        this.m_contentHandler.startDocument();

    while (null != pos)
    {
      startNode(pos);

      Node nextNode = pos.getFirstChild();

      while (null == nextNode)
      {
        endNode(pos);

        if ((null != top) && top.equals(pos))
          break;

        nextNode = pos.getNextSibling();

        if (null == nextNode)
        {
          pos = pos.getParentNode();

          if ((null == pos) || ((null != top) && top.equals(pos)))
          {
            nextNode = null;

            break;
          }
        }
      }

      pos = nextNode;
    }
    this.m_contentHandler.endDocument();
  }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscr...@xml.apache.org
For additional commands, e-mail: xalan-dev-h...@xml.apache.org

Reply via email to