sankeyr |
Newbie |
|
Wyoming |
|
|
None Specified |
|
Friday, May 26, 2017 |
Friday, May 26, 2017 10:53:48 PM |
1 [0.01% of all post / 0.00 posts per day] |
|
Here is the XML:
Code: <svg xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <text id="b376"> <tspan x="59" y="156" font-size="13px" font-family="Arial">80</tspan> </text> <use xlink:href="#b376" fill="#000000"/> <text id="b374"> <tspan x="59" y="204" font-size="13px" font-family="Arial">60</tspan> </text> <use xlink:href="#b374" fill="#000000"/> <defs>testDef</defs> </g> </svg>
Here is my XSL input:
Code: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="g"> <g> <xsl:apply-templates select="use|defs"/> <defs> <xsl:apply-templates select="*[name() != 'use' and name() != 'defs']"/> </defs> </g> </xsl:template> </xsl:stylesheet>
I want to wrap all nodes in a <defs> tag EXCEPT <use> tags and <defs> tags. So the 2 <text> nodes would be wrapped in <defs> tags but <defs> and <use> would not.
Here is what I am getting
Code: <?xml version="1.0"?> <svg xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <use xlink:href="#b376" fill="#000000"/> <use xlink:href="#b374" fill="#000000"/> <defs>testDef</defs> <defs> <text id="b376"> <tspan x="59" y="156" font-size="13px" font-family="Arial">80</tspan> </text> <text id="b374"> <tspan x="59" y="204" font-size="13px" font-family="Arial">60</tspan> </text> </defs> </g> </svg>
This is what I want:
Code:<?xml version="1.0"?> <svg xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <use xlink:href="#b376" fill="#000000"/> <use xlink:href="#b374" fill="#000000"/> <defs>testDef</defs> <defs> <text id="b376"> <tspan x="59" y="156" font-size="13px" font-family="Arial">80</tspan> </text> </defs> <defs> <text id="b374"> <tspan x="59" y="204" font-size="13px" font-family="Arial">60</tspan> </text> </defs> </g> </svg>
Thanks!
|
|