Thanks for the response. <br><br>1. Is there a particular XSL list you refer to?<br><br>2. In our application, we process hundreds of thousands of SVG images. Individual teams are responsible for providing an stylesheet that produces a 'cleaned' SVG; this is for space savings (we're talking on the order of 100 GB here, so a 50% reduction is a big deal). To know that their stylesheets have not 'broken' the SVG, the publishing process has an in-bult check for well-formedness, and validates against the SVG spec; those attributes do not prevent rendering, but they do prevent validation. Which means we can not check that other errors are not present.<br>
<br>3. We use Saxon-EE, as that is what oXygen uses, and we wanted to deploy with the same. So we've licensed Saxon.<br><br>4. Ya, I originally had the SVG as an element, but that caused me some other grief I can't remember.<br>
<br>5. I'm not an XSLT programmer, so this is not surprising, even though it is unfortunate. All I can do is try something, see if it has a positive result (makes my output more like I want it), and go from there. I'll study your changes, and try to incorporate them.<br>
<br>Thanks!<br><br><div class="gmail_quote">On Thu, Jun 23, 2011 at 2:16 PM, Syd Bauman <span dir="ltr"><<a href="mailto:Syd_Bauman@brown.edu">Syd_Bauman@brown.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
1) This is probably more appropriate for the XSL-list than here. You<br>
would likely find that if you followed the (stringent) posting<br>
guidelines for that list, you'd have your answer before you post.<br>
At least, I usually do :-)<br>
<br>
2) Out of curiosity, why do you care? There is really no harm done<br>
having extra namespace declarations on the SVG root element, is<br>
there? (I agree it is ugly as sin, and often run the output of my<br>
transforms through an editing step to strip 'em off:<br>
$ saxon style.xslt in.xml | perl -pe 's, xmlns:duck="<a href="http://www.example.org/ns/" target="_blank">http://www.example.org/ns/</a>",,;' > out.xml<br>
<br>
3) What processor are you using?<br>
<br>
4) I can take a crack at reducing the namespace declarations on the<br>
output <svg> node by making it an explicit literal result element<br>
instead of using <copy>. The i prefix is still there, though. (I<br>
presume because it's tested for in the code). See below.<br>
<br>
5) This strikes me as very non-XSLT-like code, and very inefficient.<br>
(You are testing every attribute, comment, or processing<br>
instruction to see if it is in the sequence of every metadata,<br>
switch, etc.)<br>
<br>
Here is a rewrite that takes care of all but 1 extra namespace, and I<br>
think does the same job in a clearer and more efficient manner:<br>
<br>
---------<br>
<br>
<?xml version="1.0" encoding="UTF-8"?><br>
<div class="im"><xsl:stylesheet xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform" target="_blank">http://www.w3.org/1999/XSL/Transform</a>"<br>
xmlns:xs="<a href="http://www.w3.org/2001/XMLSchema" target="_blank">http://www.w3.org/2001/XMLSchema</a>"<br>
xmlns:xd="<a href="http://www.oxygenxml.com/ns/doc/xsl" target="_blank">http://www.oxygenxml.com/ns/doc/xsl</a>"<br>
xmlns:i="<a href="http://ns.adobe.com/AdobeIllustrator/10.0/" target="_blank">http://ns.adobe.com/AdobeIllustrator/10.0/</a>"<br>
xmlns:a="<a href="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" target="_blank">http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/</a>"<br>
xmlns:graph="<a href="http://ns.adobe.com/Graphs/1.0/" target="_blank">http://ns.adobe.com/Graphs/1.0/</a>"<br>
xmlns:x="<a href="http://ns.adobe.com/Extensibility/1.0/" target="_blank">http://ns.adobe.com/Extensibility/1.0/</a>"<br>
exclude-result-prefixes="xs xd a x graph"<br>
xpath-default-namespace="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>"<br>
version="2.0"><br>
<br>
</div> <xsl:template match="/"><br>
<div class="im"> <svg xmlns="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>"><br>
</div> <xsl:apply-templates select="svg/*"/><br>
</svg><br>
</xsl:template><br>
<br>
<xsl:template match="*"><br>
<div class="im"> <xsl:copy><br>
<xsl:apply-templates select="@*|node()"/><br>
</xsl:copy><br>
</div> </xsl:template><br>
<xsl:template match="comment()|processing-instruction()|text()"><br>
<xsl:copy/><br>
</xsl:template><br>
<xsl:template match="@*"><br>
<xsl:if test="namespace-uri() ne<br>
'<a href="http://ns.adobe.com/AdobeIllustrator/10.0/" target="_blank">http://ns.adobe.com/AdobeIllustrator/10.0/</a>'"><br>
<xsl:copy/><br>
</xsl:if><br>
</xsl:template><br>
<br>
<xsl:template match="i:pgf | metadata | foreignObject"/><br>
<br>
<xsl:template match="switch"><br>
<div class="im"> <xsl:apply-templates select="node()"/><br>
</div> </xsl:template><br>
<br>
</xsl:stylesheet><br>
---------<br>
<br>
HTH.<br>
<div><div></div><div class="h5"><br>
> I'm applying a transform to SVG documents, to make them validate<br>
> against the SVG RNG schema. I have everything working EXCEPT the<br>
> name spaces on the SVG element itself. These SVG documents where<br>
> edited in Adobe Illistrator, and the original SVG element is:<br>
><br>
> <svg xmlns="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>" xmlns:a="<br>
> <a href="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" target="_blank">http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/</a>" xmlns:graph="<br>
> <a href="http://ns.adobe.com/Graphs/1.0/" target="_blank">http://ns.adobe.com/Graphs/1.0/</a>" xmlns:i="<br>
> <a href="http://ns.adobe.com/AdobeIllustrator/10.0/" target="_blank">http://ns.adobe.com/AdobeIllustrator/10.0/</a>" xmlns:x="<br>
> <a href="http://ns.adobe.com/Extensibility/1.0/" target="_blank">http://ns.adobe.com/Extensibility/1.0/</a>" xmlns:xlink="<br>
> <a href="http://www.w3.org/1999/xlink" target="_blank">http://www.w3.org/1999/xlink</a>"><br>
><br>
> and what I want is:<br>
><br>
> <svg xmlns="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>" xmlns:xlink="<br>
> <a href="http://www.w3.org/1999/xlink" target="_blank">http://www.w3.org/1999/xlink</a>"><br>
><br>
> The stylesheet starts:<br>
> <xsl:stylesheet xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform" target="_blank">http://www.w3.org/1999/XSL/Transform</a>"<br>
> xmlns:xs="<a href="http://www.w3.org/2001/XMLSchema" target="_blank">http://www.w3.org/2001/XMLSchema</a>"<br>
> xmlns:xd="<a href="http://www.oxygenxml.com/ns/doc/xsl" target="_blank">http://www.oxygenxml.com/ns/doc/xsl</a>"<br>
> xmlns:i="<a href="http://ns.adobe.com/AdobeIllustrator/10.0/" target="_blank">http://ns.adobe.com/AdobeIllustrator/10.0/</a>"<br>
> xmlns:a="<a href="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" target="_blank">http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/</a>"<br>
> xmlns:graph="<a href="http://ns.adobe.com/Graphs/1.0/" target="_blank">http://ns.adobe.com/Graphs/1.0/</a>"<br>
> xmlns:x="<a href="http://ns.adobe.com/Extensibility/1.0/" target="_blank">http://ns.adobe.com/Extensibility/1.0/</a>"<br>
> exclude-result-prefixes="xs xd a x graph"<br>
> xpath-default-namespace="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>"<br>
> version="2.0"><br>
><br>
> My understanding is that 'exclude-result-prefixes="xs xd a x<br>
> graph"' should not copy over the namespaces identified, but a, x,<br>
> and graph are still there in the output. My main template is below,<br>
> and it keeps the namespace & extensions off of the child elements<br>
> of SVG, just not the SVG node itself.<br>
><br>
> <xsl:template match="@*|node()"><br>
> <xsl:choose><br>
> <xsl:when test=". = //i:pgf"/> <!-- This is the BLOB --><br>
> <xsl:when test=". = //@i:*" /> <!-- These three are all of the<br>
> Adobe extensions --><br>
> <xsl:when test=". = //metadata"/><br>
> <xsl:when test=". = //foreignObject"/><br>
> <xsl:when test=". = //switch"> <!-- We do not want the switch<br>
> elements, just their text nodes. --><br>
> <xsl:apply-templates select="node()"/><br>
> </xsl:when><br>
> <xsl:otherwise><br>
> <xsl:copy><br>
> <xsl:apply-templates select="@*|node()"/><br>
> </xsl:copy><br>
> </xsl:otherwise><br>
> </xsl:choose><br>
> </xsl:template><br>
><br>
> Any ideas?<br>
</div></div>_______________________________________________<br>
oXygen-user mailing list<br>
<a href="mailto:oXygen-user@oxygenxml.com">oXygen-user@oxygenxml.com</a><br>
<a href="http://www.oxygenxml.com/mailman/listinfo/oxygen-user" target="_blank">http://www.oxygenxml.com/mailman/listinfo/oxygen-user</a><br>
</blockquote></div><br>