Groovy
  1. Groovy
  2. GROOVY-2779

GPath evaluation problem for html with namespace

    Details

      Description

      I am trying to parse HTML with XmlParser (see example below).

      I expect both expressions
      html.body
      and
      html.":body"
      will return the same value, since namespace prefix is empty.

      But the first one does not work (it rerurns empty list).

      Sorce code:

      import groovy.xml.*
      def text = """
      <html xmlns="http://www.w3.org/1999/xhtml">
          <body>
              text
          </body>
      </html>
      """
      def html = new XmlParser().parseText(text)
      println html.body  
      println html.":body"
      

      Result:
      []
      [

      {http://www.w3.org/1999/xhtml}

      body[attributes={}; value=[text]]]

        Activity

        Sergey Bondarenko created issue -
        Hide
        Paul King added a comment -

        add code tags

        Show
        Paul King added a comment - add code tags
        Paul King made changes -
        Field Original Value New Value
        Description I am trying to parse HTML with XmlParser (see example below).

        I expect both expressions
            html.body
        and
            html.":body"
        will return the same value, since namespace prefix is empty.

        But the first one does not work (it rerurns empty list).


        Sorce code:
        import groovy.xml.*
        def text = """
        <html xmlns="http://www.w3.org/1999/xhtml">
            <body>
                text
            </body>
        </html>
        """
        def html = new XmlParser().parseText(text)
        println html.body
        println html.":body"

        Result:
        []
        [{http://www.w3.org/1999/xhtml}body[attributes={}; value=[text]]]

        I am trying to parse HTML with XmlParser (see example below).

        I expect both expressions
            {{html.body}}
        and
            {{html.":body"}}
        will return the same value, since namespace prefix is empty.

        But the first one does not work (it rerurns empty list).

        Sorce code:
        {code}
        import groovy.xml.*
        def text = """
        <html xmlns="http://www.w3.org/1999/xhtml">
            <body>
                text
            </body>
        </html>
        """
        def html = new XmlParser().parseText(text)
        println html.body
        println html.":body"
        {code}

        Result:
        []
        [{http://www.w3.org/1999/xhtml}body[attributes={}; value=[text]]]

        Hide
        Paul King added a comment -

        Fixed in trunk - still to add test and merge to 1.6 and 1.5 releases.

        Show
        Paul King added a comment - Fixed in trunk - still to add test and merge to 1.6 and 1.5 releases.
        Paul King made changes -
        Assignee Paul King [ paulk ]
        Fix Version/s 1.5.8 [ 14630 ]
        Fix Version/s 1.6-rc-1 [ 14009 ]
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Hide
        Sergey Bondarenko added a comment -

        Paul, thank you!
        Now it works properly.

        Show
        Sergey Bondarenko added a comment - Paul, thank you! Now it works properly.
        Hide
        Paul King added a comment -

        Test added and merged onto 1.5 and 1.6 branches.

        Show
        Paul King added a comment - Test added and merged onto 1.5 and 1.6 branches.
        Paul King made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12731802 ] Default workflow, editable Closed status [ 12743599 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12969742 ] Default workflow, editable Closed status [ 12977497 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        205d 19h 22m 1 Paul King 17/Nov/08 00:22
        Resolved Resolved Closed Closed
        36d 5h 35m 1 Paul King 23/Dec/08 05:58

          People

          • Assignee:
            Paul King
            Reporter:
            Sergey Bondarenko
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development