Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-570

Bookmark are not copied when you copy cursors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Version 5.0.0
    • None
    • Cursor, XmlObject
    • None
    • UbuntuLinux, XMLBean 5.0.0

    Description

      Documentation state:

      The cursors and bookmarks located in the XML that was copied are also copied to the new location.

      It does not copy the bookmark, but moves it.

      It also move the original cursor.

      When running the code bellow, the expected output is:

      <a>Test 1</a>
      <a>modified</a>

      The current output is:

      <a>Test 1</a>

      Code (Kotlin) to reproduce the issue:

      data class TestBookmark(val key:String): XmlCursor.XmlBookmark(){
          override fun getKey():Any{
              return key
          }
      }
      
      fun main(){
          @Language("XML") val xml="""<r>
              |<a>Test 1</a>
              |<a>Test 2</a>
              |<a>Test 3</a>
              |<a>Test 4</a>
              |</r>""".trimMargin()
          val xmlObj=XmlObject.Factory.parse(xml)
          val bk=TestBookmark("test")
          xmlObj.newCursor().use { cur->
              cur.advanceTo(QName("a"))
              cur.setBookmark(bk)
              cur.newCursor().use { here ->
                  // Per doc: The cursors and bookmarks located in the XML that was copied are also copied to the new location.
                  cur.copyXml(here)
                  here.textValue="changed"
              }
          }
          xmlObj.newCursor().use { cur->
              while (cur.toNextBookmark("test")!=null){
                  // Expect to print <a>Test 1</a> and <a>changed</a>
                  println(cur.xmlText())
              }
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            Christian Baune Christian Baune
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: