sjsxp
  1. sjsxp
  2. SJSXP-22

XMLStreamReaderImpl.hasName() returns true on PROCESSING_INSTRUCTION

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      22

      Description

      StAX specification states that XMLStreamReader.hasName() should return true on
      a START_ELEMENT or END_ELEMENT event, false otherwise.

      Current XMLStreamReaderImpl returns true when on a PROCESSING_INSTRUCTION event.

      Unit test:

      public void testHasNameOnProcessingInstructionEvent() throws Exception

      { String xml = "<root><?foo bar='baz'?></root>"; XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader r = factory.createXMLStreamReader( new StringReader( xml ) ); r.require( XMLStreamReader.START_DOCUMENT, null, null ); r.next(); r.require( XMLStreamReader.START_ELEMENT, null, "root" ); r.next(); r.require( XMLStreamReader.PROCESSING_INSTRUCTION, null, null ); assertFalse( r.hasName() ); // fails }

      Solution:

      Change guard in XMLStreamWriterImpl.hasName() to drop the processing
      instruction.

      Probably should get it to drop the entity reference too since getName() is an
      invalid state for ENTITY_REFERENCE.

        Activity

        Hide
        Santiago Pericas-Geertsen added a comment -

        Yes, it shouldn't return true in this case.

        Show
        Santiago Pericas-Geertsen added a comment - Yes, it shouldn't return true in this case.
        Hide
        Joe Wang added a comment -

        Fixed. Unit test added. The latest build now contains the fix.

        Thanks again!

        Show
        Joe Wang added a comment - Fixed. Unit test added. The latest build now contains the fix. Thanks again!

          People

          • Assignee:
            Joe Wang
            Reporter:
            jeffrey_sinclair
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: