XPath Index Filter Performance

I create an xsl stylehseet and come up with this (in my opinion, illogical behavior):

This XPath:

/ root / element [1] [@ attr1! = '1' or @ attr2! = 'test']

works slower than this XPath:

/ root / element [count (previous-sibling :: element) + 1 = 1) and (@ attr1! = '1' or @ attr2! = 'test')]

I have 50 xml samples and it takes ~ 55 seconds with the first XPath.
With the second XPath, ~ 4 seconds are required!

I am using XslCompiledTransform (C # .NET 4.5).

Can someone explain why the first XPath is much slower than the second? I always thought it was better to use an explicit index filter.

Update: xml example:

<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<element attr2="test" attr1="1">
    <child>17</child>
    <child>17</child>
    <child>16</child>
    ...
    <child>3</child>
    <child>2</child>
    <child>1</child>
</element>
<element attr2="test2" attr1="2">
    <child/>
    <child/>
    <child/>
    <child/>
    <child/>
    <child/>
    <child/>
    ...
    <child/>
</element>
....
<element attr2="test21" attr1="21" />

There are only 20-25 elements with n children, but the maximum is 4 (/ root / element / child / anotherChild).

+4
1

, . Microsoft https://support.microsoft.com/en-us/kb/815124:

MSXML, 3.0 , . . :

/Child_Element

:

/Child_Element [1]

- WAY , Microsoft.

0

All Articles