Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

href vs xlink:href #334

Open
Mbodin opened this issue Jan 19, 2024 · 0 comments
Open

href vs xlink:href #334

Mbodin opened this issue Jan 19, 2024 · 0 comments

Comments

@Mbodin
Copy link
Contributor

Mbodin commented Jan 19, 2024

This is an issue that will probably disappear by itself when moving to SVG 2. I think that it can still be useful to document it in the meantime.

From what I understand, in SVG 1.1, one should use xlink:href for the <use> tag, but in SVG 2, it has been replaced by href. Some people ( https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/href ) argue that one could use both just in case, but I feel that this solution would not be in the spirit of TyXML (as such a document would not strictly follow neither SVG 1.1 nor SVG 2).

Currently in TyXML, there are two functions a_href and a_xlink_href. The a_xlink_href function produces xlink:href and is marked as depreciated, whilst a_href produces href.

The issue is that the doctype that TyXML produces indicates SVG 1.1:

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink">

The link http://www.w3.org/2000/svg seems to be mutable (so I guess that it currently means SVG 2?).

If I open such an SVG file with Inkscape, by default (there might be an option to change this behaviour), the <use href> are simply ignored, which is frustrating.

In order to generated SVG files that can be opened in Inkscape, I have to use a_xlink_href instead of a_href. In practise I just do the following to just use a_href without thinking too much about it:

let module Svg = struct
  include Svg
  let a_href = a_xlink_href
end

The generated files are then understood by Inkscape. (And I get warning messages about a_xlink_href being depreciated.)

In Tyxml_js, there is no generated doctype when adding the SVG within the DOM using Html.svg, so Firefox assumes that we are in SVG 2 and xlink:href won't be recognised: for the <use> tags to work, I need to use href instead.

It's a bit frustrating. Now that I understand the issue, I can work around this, but it took me some time. This issue will solve itself when TyXML will follow SVG 2, but I feel that a_xlink_href shouldn't be marked as depreciated in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant