Issue 118514 - Faulty method getElementsByTagName with com.sun.star.xml.dom.XElement resp. XDocument
Summary: Faulty method getElementsByTagName with com.sun.star.xml.dom.XElement resp. X...
Status: UNCONFIRMED
Alias: None
Product: xml
Classification: Code
Component: code (show other issues)
Version: OOo 3.2.1
Hardware: PC Linux, all
: P5 (lowest) Major (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-15 12:37 UTC by Volker Lenhardt
Modified: 2013-01-23 01:31 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Fancy xml file as test object for the getElementsByTagName bug (2.66 KB, text/xml)
2011-10-15 12:37 UTC, Volker Lenhardt
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Volker Lenhardt 2011-10-15 12:37:53 UTC
Created attachment 76891 [details]
Fancy xml file as test object for the getElementsByTagName bug

Importing xml files with DOM. The getElementsByTagName method of the interfaces com.sun.star.xml.dom.XDocument and com.sun.star.xml.dom.XDocument yields faulty results for tag names of length 8 and 16 (no longer names tested).

Usually the bug doesn't show with only few elements. You can force the bug to become visible by multiple calls to the test below or by increasing the number of iterations. OOo gets unstable and is apt to crash.

I attach a short fancy xml file. You can use this test on the file.

Sub Test
  Dim sURL As String
  Dim oDocBuilder
  Dim oDOM
  Dim i%
  Dim oElements
  Dim sTagName As String
  
  sTagName = "validTo" 'Length 7: okay -> 10 elements
  'sTagName = "document" 'Length 8: faulty -> 10 elements
  'sTagName = "slot" 'Length 4: okay -> 13 elements
  'sTagName = "customer" 'Length 8: faulty -> 18 elements
  sURL = "your_path"
  oDocBuilder = createUnoService("com.sun.star.xml.dom.DocumentBuilder")
  oDOM = oDocBuilder.parseURI(sUrl)
  oDOM.normalize()
  If IsEmpty(oDOM) Then Exit Sub
    oElements = oDOM.getElementsByTagName(sTagName)
'    Print oElements.getLength
'    Exit Sub
  For i = 0 To 10         'With "slot" and "validTo" even 10000 is ok
    If oElements.getLength <> 10 Then  'Number depends on the tag name (s.a.)
    	Print i, "Error"
    	Exit Sub
    End If
  Next
  Print "Done"
End Sub

Volker Lenhardt
Comment 1 Volker Lenhardt 2011-10-15 12:53:15 UTC
Sorry, copying the the test code from my module I mixed up important lines. The code has to be changed to become meaningful:

Sub Test
  Dim sURL As String
  Dim oDocBuilder
  Dim oDOM
  Dim i%
  Dim oElements
  Dim sTagName As String

  sTagName = "validTo" 'Length 7: okay -> 10 elements
  'sTagName = "document" 'Length 8: faulty -> 10 elements
  'sTagName = "slot" 'Length 4: okay -> 13 elements
  'sTagName = "customer" 'Length 8: faulty -> 18 elements
  sURL = "your_path"
  oDocBuilder = createUnoService("com.sun.star.xml.dom.DocumentBuilder")
  oDOM = oDocBuilder.parseURI(sUrl)
  oDOM.normalize()
  If IsEmpty(oDOM) Then Exit Sub
  For i = 0 To 10         'With "slot" and "validTo" even 10000 is ok
    oElements = oDOM.getElementsByTagName(sTagName)
    If oElements.getLength <> 10 Then  'Number depends on the tag name (s.a.)
        Print i, "Error"
        Exit Sub
    End If
  Next
  Print "Done"
End Sub