Why does the link to the same document in SVG affect the HTML <base> tag?

I have an HTML page with a <base> that also contains SVG. Links to the same document, such as below in the SVG, then end:

 <html> <head> <base href="http://my/server/basedir"> </head> <body> <svg> <g> <path d="M100,100 L150,150" id="path"/> <text> <textpath xlink:href="#path"/> </text> </g> </svg> </body> </html> 

xlink:href="#path" cannot be resolved. This works fine without an HTML base element. It also works if I replace the href attribute on the textpath element textpath an absolute IRI, followed by the fragment identifier.

It seems to me that SVG should handle the IRI of the same document in different ways and regardless of the HTML base . Http://www.w3.org/TR/xmlbase/#same-document says that "dereferencing links to the same document is handled specifically", although it is provided in the context of xml:base . By the way, I played with putting xml:base in the svg element in the hope of overriding the HTML base setting, because I could not figure out how to do this.

+6
source share
1 answer

Case 1: without xml:base

Works in IE (Edge), Chrome, but not in Firefox.

 <html> <head> <base href="http://my/server/basedir"> </head> <body> <svg width="300" height="300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <path d="M100,100 L150,150" id="path"/> <text> <textpath xlink:href="#path">Hello</textpath> </text> </g> </svg> </body> </html> 

Case 2: with xml:base

Works in IE (Edge), Chrome, Firefox.

If this URL is http://my/thisfile.htm , then set xml:base="http://my/thisfile.htm" to the svg tag or textpath tag.

 <html> <head> <base href="http://my/server/basedir"> </head> <body> <svg width="300" height="300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:base="http://my/thisfile.htm"> <g> <path d="M100,100 L150,150" id="path"/> <text> <textpath xlink:href="#path">Hello</textpath> </text> </g> </svg> </body> </html> 
0
source

Source: https://habr.com/ru/post/902431/


All Articles