Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is namespace checking in xml string or URI based?

Tags:

namespaces

xml

I always wondered how an XML parser handle the check of a URI namespace. is it string based, or URI based? in other words, this is the standard URI for SVG

xmlns="http://www.w3.org/2000/svg"

suppose that I write instead

xmlns="http://www.w3.org/2000/../2000/svg"

or

xmlns="http://www.w3.org/2000/svg/"

or even

xmlns="http://www.w3.org:8000/2000/svg"

Will these cases be recognized as svg namespaces (URI based) or not (string based)?

Thanks

Edit : the fact that you can use URNs (like a uuid) makes me feel like it's string based, because you cannot apply the proper URL/URI considerations to a non URL-like URI. But maybe in that case it will just work as a string ?

Edit: As Tormod points out it is made with a string comparison. This prompts me to wonder if there are recommendations for defining URIs (like: no slash at the end, all lowercase, etc...). Or is it just a free-for-all ?

like image 600
Stefano Borini Avatar asked Feb 02 '26 17:02

Stefano Borini


1 Answers

They are string based. All your sample URIs resolve to different namespaces.

http://www.w3.org/TR/REC-xml-names/#NSNameComparison

URI references identifying namespaces are compared when determining whether a name belongs to a given namespace, and whether two names belong to the same namespace. [Definition: The two URIs are treated as strings, and they are identical if and only if the strings are identical, that is, if they are the same sequence of characters. ] The comparison is case-sensitive, and no %-escaping is done or undone.

like image 183
Tormod Fjeldskår Avatar answered Feb 04 '26 05:02

Tormod Fjeldskår



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!