SVG, XSLT and Namespaces

> Folks,
> 
> I have been trying to write XSLT stylesheets to transform SVG documents,
> and I have encountered some challenges regarding SVG's use of namespaces.
> The problem is that SVG (or at least the implementation I am working with)
> appears to specify a default namespace using a parameter entity in the
> DTD.  The problem is that because the default namespace is defined
> dynamically, and XLST does not have a mechanism for binding the default
> namespace dynamically, I appear to be forced to strip the namespace
> reference using the local-name() function.  If the namespace was define
> with a prefix, I don't think there would be a problem.
> 
> The following is a representative example of the problem. I have a simple
> SVG document, and a stylesheet that adds some tags and removes  some
> attributes from the existing document. Note too, that the namespace
> parameter entity gets passed into the resulting document.
> 
> I'm using Xalan 1.2.1 as my XLST processor.  The SVG document is adapted
> from one generated from Adobe Illustrator 9.0. 
> 
> Am I missing something about how SVG should operate with XSLT?  Is this a
> flaw in one (or both) of the specifications, or implementations?
> 
> Sincerely,
> David Kane
> 
> SVG DOCUMENT:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!-- Generator: Adobe Illustrator 9.0, SVG Export Plug-In  -->
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
> "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dt
> d" [
> 	<!ENTITY st11
> "fill-rule:evenodd;clip-rule:evenodd;fill:none;stroke-width:4;stroke-linec
> ap:square;">
> 	<!ENTITY st28 "font-family:'Helvetica';">
> 	<!ENTITY st33 "font-size:18;">
> 	<!ENTITY st38
> "fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:4;">
> ]>
> <svg id="nsexample" width="100pt" height="100pt" viewBox="0 0 100 100"
> xml:space="preserve">
> 	<g id="layer1" style="&st38; &st28; &st33;">
> 	    <path style="&st11;" d="M43,44.196h2280v1452H43v-1452z"/>
> 	</g>
>     <g id="layer2" style="&st38; &st28; &st33;">	
> 	    <path style="&st11;" d="M23,24.196h2280v1452H43v-1452z"/>
> 	</g>
> </svg>
> 
> XLST STYLESHEET:
> 
> <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   version="1.0">
> 
>    <xsl:output method="xml"  
>         media-type="text/xml"
>         omit-xml-declaration="no"
> 	
> doctype-system="http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000
> 303-stylable.dtd"
>   		doctype-public="-//W3C//DTD SVG 20000303 Stylable//EN"/>
> 	    indent="yes"/>     
>   
> <!--
>     What I would expect to work, but doesn't
>     <xsl:template match="path">
>   -->
>      
>    <xsl:template match="*[local-name()='path']">
>        <addTag>
> 		 <xsl:copy>
>     		<xsl:apply-templates 
>      			select="*|processing-instruction()|text()"/>
>   		  </xsl:copy>
> 	   </addTag>
>    </xsl:template>
> 
>    <xsl:template match="*[local-name()!='path']">
> 		 <xsl:copy>
>     		<xsl:apply-templates 
>      			select="*|processing-instruction()|text()"/>
>   		  </xsl:copy>
>    </xsl:template>
> 	   
> </xsl:stylesheet>
> 
> RESULTING DOCUMENT:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
> "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dt
> d">
> <svg xmlns="%SVGNamespace;">
> 	<g>
> 	    <addTag><path/></addTag>
> 	</g>
>     <g>	
> 	    <addTag><path/></addTag>
> 	</g>
> </svg>
> 
> 

Received on Wednesday, 29 November 2000 10:09:59 UTC