[Scilab-users] xmlns attribute cancels counting <= Re: xmlXPath with count

Jens Simon Strom j.s.strom at hslmg.de
Wed Jun 7 09:49:10 CEST 2017


Hallo Samuel,
So I better count with something like this:

wpt_pos=grep(XmlDump,'<wpt');
wpt_n=length(wpt_pos);

Thanks again, Jens
--------------------------------------------------

Am 06.06.2017 22:25, schrieb Samuel Gougeon:
> Hello Jens,
>
> Le 05/06/2017 à 02:12, Jens Simon Strom a écrit :
>> Hi,
>> Ex. 0 and 2 are o.k.. But what I want is Ex. 1.  What is wrong there?
>>
>>
>> //Ex. 0
>> doc = xmlRead("http://www.w3.org/TR/2009/REC-xml-names-20091208/xml-names-10-3e.xml");
>> // Count the nodes with name equal to"note"
>> xp0 = xmlXPath(doc, "count(//note)")
>> xmlDelete(doc)
>>
>> //Ex. 1
>> t=['<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>'+..
>> '<gpx xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.topografix.com/GPX/1/1"" creator=""WTracks"" version=""1.1"" xsi:schemaLocation=""http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"">'+..
>> '<wpt lat=""52.0"" lon=""8.0"">'+..
>> '<sym>City (Small)</sym>'+..
>> '</wpt>'+..
>> '</gpx>']
>> doc = xmlReadStr(t);
>> xmlDump(doc)
>> xp1 = xmlXPath(doc, "count(//wpt)")
>> xmlDelete(doc)
>
> Apparently, the xmlns attribute (alone) is not supported out of the 
> <?xml ?> initial header.
> When we remove it, tags are counted as expected:
>
> t=['<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>'+..
> '<gpx xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" 
> creator=""WTracks"" version=""1.1"" '+..
> '     xsi:schemaLocation=""http://www.topografix.com/GPX/1/1 
> http://www.topografix.com/GPX/1/1/gpx.xsd"">'+..
> '<wpt lat=""52.0"" lon=""8.0"">'+..
> '<sym>City (Small)</sym>'+..
> '</wpt>'+.. '</gpx>'];
> doc = xmlReadStr(t);
> xp1 = xmlXPath(doc, "count(//wpt)")
> xmlDelete(doc);
>
> --> xp1 = xmlXPath(doc, "count(//wpt)")
>  xp1  =
>    1.
>
> Since this attribute looks to be legal here 
> (https://www.w3schools.com/xml/xml_namespaces.asp), the wrong result 
> is likely a bug:
> http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab 
> software&component=XML
>
> Best regards
> Samuel Gougeon
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170607/4ff8e19f/attachment.htm>


More information about the users mailing list