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

Samuel Gougeon sgougeon at free.fr
Tue Jun 6 22:25:17 CEST 2017


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170606/06951e3e/attachment.htm>


More information about the users mailing list