Hello,

xmlNS is not able to create an XML namespace without a prefix, although this is completely correct in XML, as it allows inheritance of it. Example:

<a xmlns="http://name.space";>
   <b>1</b>
</a>

here the "b" element is in the "http://name.space"; namespace. The only workaround I have found is the following :

s = "<root><a xmlns=""http://name.space""/><b/></root>"
doc = xmlReadStr(s)
ns=xmlGetNsByHref(doc.root.children(1), "http://name.space";)
xmlAddNs(doc.root.children(2),ns);
xmlDump(doc)

Scilab (correct) output is :

 ans  =

!<?xml version="1.0"?>             !
!                                  !
!<root>                            !
!                                  !
!  <a xmlns="http://name.space"/>  !
!                                  !
!  <b xmlns="http://name.space"/>  !
!                                  !
!</root>                           !


But if I use xmlNS, Scilab (incorrect) output is :

s = "<root><a/><b/></root>"
doc = xmlReadStr(s)
ns=xmlNs(doc.root,"","http://name.space";);
xmlAddNs(doc.root.children(1),ns);
xmlAddNs(doc.root.children(2),ns);
xmlDump(doc)
 ans  =

!<?xml version="1.0"?>              !
!                                   !
!<root xmlns:="http://name.space";>  !
!                                   !
!  <a xmlns:="http://name.space"/>  !
!                                   !
!  <b xmlns:="http://name.space"/>  !
!                                   !
!</root>

xmlNs should interpret and empty string as prefix, as no prefix for the namespace.

S.
_______________________________________________
dev mailing list
dev@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/dev

Reply via email to