xlink

SVG Absolute Pathing for `xlink:href` Attribute Not Working

送分小仙女□ 提交于 2019-12-11 01:54:36
问题 So I have a single SVG file that holds a collection of different paths: <!-- icons.svg --> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="foo" .../> <path id="bar" .../> ... </svg> and within my webpages, I use these SVG icons: <!-- index.html --> <svg viewBox="0 0 256 256"> <use xlink:href="icons.svg#foo"> </svg> and this works just fine and exactly how I intend -- we select the SVG with the id foo from the icons.svg file. Now, if I try to give

XML: How to load the contents of one xml file into another

ε祈祈猫儿з 提交于 2019-12-10 11:30:45
问题 I would just like to be able to dynamically write the contents of an xml file from another xml file. A.XML contains: <?xml version="1.0"?> <node> -Include Contents of b.xml </node> B.XML contains: <anode> a </anode> is there any way to do this in xml? End product looks like this: <?xml version="1.0"?> <node> <anode> a </anode> </node> Update from comments : In xml alone. so that when i view the xml file in a browser it renders correctly 回答1: Use an external (parsed) general entity to

Dynamic creation of SVG links in JavaScript

淺唱寂寞╮ 提交于 2019-12-09 18:20:29
问题 I am dynamically creating SVG elements from JavaScript. It's working fine for visual objects like a rectangle, but I'm having trouble producing functioning xlinks. In the example below the first rectangle (which is statically defined) works correctly when clicked on, but the other two (created in JavaScript) ignore clicks... even though inspecting the elements in Chrome seems to show the same structure. I've seen multiple similar questions come up, but none that exactly address this. The

Ampersands (&) in xlink:href attributes of SVG images?

我是研究僧i 提交于 2019-12-07 01:26:35
问题 I'm building an SVG document which contains various image tags. The xlink:href (source URL) attributes for the images contain query strings with ampersands. If I escape them as %26 or the ascii encoding ? they're not valid query strings and the server won't deliver the image. I can't escape them with CDATA because they're attributes (not nodes). I've tried creating an xlink:href node within the image tag but that get's ignored by the SVG parser. I want to use pure SVG (not SVG within HTML) so

XML: How to load the contents of one xml file into another

你说的曾经没有我的故事 提交于 2019-12-06 11:54:08
I would just like to be able to dynamically write the contents of an xml file from another xml file. A.XML contains: <?xml version="1.0"?> <node> -Include Contents of b.xml </node> B.XML contains: <anode> a </anode> is there any way to do this in xml? End product looks like this: <?xml version="1.0"?> <node> <anode> a </anode> </node> Update from comments : In xml alone. so that when i view the xml file in a browser it renders correctly Use an external (parsed) general entity to reference b.xml from a.xml . <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE node [ <!ENTITY b SYSTEM "b.xml"> ]>

XML: How to read one file into another

亡梦爱人 提交于 2019-12-02 04:15:38
问题 I have a file: A.xml containing something like this: <?xml version="1.0"?> <headernode> </headernode> Inside of the headernode i need to be able to dynamically load the contents of another xml file called B.xml containing the following <?xml version="1.0"?> <token> <a>0</a> </token> My question is how do i get the contents of B.xml inside the header node of a.xml? Thanks! 回答1: This seems to work: var header = XDocument.Load("a.xml"); var token = XElement.Load("b.xml"); var headerNode = header

XML: How to read one file into another

自古美人都是妖i 提交于 2019-12-02 03:01:45
I have a file: A.xml containing something like this: <?xml version="1.0"?> <headernode> </headernode> Inside of the headernode i need to be able to dynamically load the contents of another xml file called B.xml containing the following <?xml version="1.0"?> <token> <a>0</a> </token> My question is how do i get the contents of B.xml inside the header node of a.xml? Thanks! This seems to work: var header = XDocument.Load("a.xml"); var token = XElement.Load("b.xml"); var headerNode = header.Elements("headernode").First(); headerNode.Add(token); Console.WriteLine(header.ToString()); /* The above

Dynamic creation of SVG links in JavaScript

梦想与她 提交于 2019-11-29 07:27:23
I am dynamically creating SVG elements from JavaScript. It's working fine for visual objects like a rectangle, but I'm having trouble producing functioning xlinks. In the example below the first rectangle (which is statically defined) works correctly when clicked on, but the other two (created in JavaScript) ignore clicks... even though inspecting the elements in Chrome seems to show the same structure. I've seen multiple similar questions come up, but none that exactly address this. The closest I found was [ adding image namespace in svg through JS still doesn't show me the picture ] but that

SVG Image Not Loading in Firefox

◇◆丶佛笑我妖孽 提交于 2019-11-28 11:10:28
问题 Here is a codepen and at the bottom of this question is the actual code. Although the code works fine in Chrome, for some reason image elements in an svg element are not loading in Firefox. I've tested it on Firefox versions 64 and 64.0.2 . Neither loads the images. Based on an SO answer I came across, and the documentation itself, I've tried a number of different things, none of which worked. Some of the things I've tried are... <svg xmlns:xlink="http://www.w3.org/1999/xlink" ... > <image

Is it possible to use HTML's .querySelector() to select by xlink attribute in an SVG?

雨燕双飞 提交于 2019-11-27 04:21:52
Given: <body> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <a xlink:href="url"></a> </svg> </body> Is it possible to use the HTML DOM's .querySelector() or .querySelectorAll() to select the link inside the SVG by the contents of its xlink:href attribute? This works: document.querySelector('a') // <a xlink:href="url"/> These don't: document.querySelector('[href="url"]') // null document.querySelector('[xlink:href="url"]') // Error: not a valid selector document.querySelector('[xlink\:href="url"]') // Error: not a valid selector document.querySelector('