Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2552

Xalan 2.7.1 TransformerFactory.transform gives out invalid xml.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 2.7.1
    • None
    • transformation
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • None

    Description

      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.

      <root><child1/></root>

      if I give the node corresponding to 'child1' the transformed xml gives out

      <child1></root>

      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();
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            jegan.s Jeganathan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: