Uploaded image for project: 'Runtime'
  1. Runtime
  2. RUNTIME-802

AbstractAmetysElement and probably subclasses: The textContent() method is not implemented correctly

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.5
    • 2.5
    • None
    • None

      The method is:

      throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "getTextContent");

      It should implement this behaviour:

      concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.

          [RUNTIME-802] AbstractAmetysElement and probably subclasses: The textContent() method is not implemented correctly

          I've implemented it the way you propose it, but please note that no kernel implementation actually implements the getChildNodes() method...

          Cédric Damioli added a comment - I've implemented it the way you propose it, but please note that no kernel implementation actually implements the getChildNodes() method...

          You can replace the method by the following code:

          StringBuilder sb = new StringBuilder();
          NodeList childs = getChildNodes();
          for (int i = 0; i < childs.getLength(); i++)
          {
              sb.append(childs.item(i).getTextContent());
          }
          return sb.toString();

          Bérénice Maurel added a comment - You can replace the method by the following code: StringBuilder sb = new StringBuilder(); NodeList childs = getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { sb.append(childs.item(i).getTextContent()); } return sb.toString();

          Could you please join a patch and explain your use case ?

          Laurence Aumeunier added a comment - Could you please join a patch and explain your use case ?

          You can ... But it is a Ametys*XSLT*Helper to be used only in XSL ...

          Laurence Aumeunier added a comment - You can ... But it is a Ametys*XSLT*Helper to be used only in XSL ...

          I was a little out of the context because I have used this in Java code. But it's an important method and I think it should be proper to be implemented.
          It's a recursive call on children to getTextContent() method.

          I can make the patch if you want.

          Bérénice Maurel added a comment - I was a little out of the context because I have used this in Java code. But it's an important method and I think it should be proper to be implemented. It's a recursive call on children to getTextContent() method. I can make the patch if you want.

          Could you explain in which case to you need this ?
          AbstractAmetysElement is an abstract and very partial implementation of a Node, there is a lot of other method which are not implemented.
          textContent() is implemented in new class AmetysText which represents a text node.

          Laurence Aumeunier added a comment - Could you explain in which case to you need this ? AbstractAmetysElement is an abstract and very partial implementation of a Node, there is a lot of other method which are not implemented. textContent() is implemented in new class AmetysText which represents a text node.

            cedric Cédric Damioli
            bmaurel Bérénice Maurel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: