StefH / XPath2.Net

Lightweight XPath2 for .NET
Microsoft Public License
36 stars 14 forks source link

ns:number function does not operate on a node #15

Closed wjgerritsen-0001 closed 5 years ago

wjgerritsen-0001 commented 5 years ago

According to XPath specification number(string(/node)) and number(/node) should behave identical, but that does not work. I agree that the spec is not very concise.

        [Fact]
        public void XPath2_number()
        {
            var xml = new XmlDocument
            {
                InnerXml = @"
                    <root num='134'>
                        <numeric>456</numeric>
                    </root>"
            };

            // asserts below succeed currently
            Assert.Equal((double)134, xml.XPath2Evaluate("number(string(/root/@num))")); 
            Assert.Equal((double)456, xml.XPath2Evaluate("number(string(/root/numeric))"));

            // asserts below fail currently
            Assert.Equal((double)134, xml.XPath2Evaluate("number(/root/@num)"));
            Assert.Equal((double)456, xml.XPath2Evaluate("number(/root/numeric)"));
        }
wjgerritsen-0001 commented 5 years ago

See for suggested fix: Fork

wjgerritsen-0001 commented 5 years ago

Thanks!