[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSLT, Namespaces & SVG

Subject: XSLT, Namespaces & SVG
From: "Kane, David" <David_Kane@xxxxxxx>
Date: Mon, 4 Dec 2000 09:15:16 -0500
svg 20000303 stylable.dtd
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.  SVG
(or at least the implementation I am working with) appears to specify a
default namespace using a parameter entity in the DTD.  When I define an
namespace for the svg prefix in my stylesheet, Xalan never appears to be
able to match any nodes by name from the SVG document.  The default
namespace is defined dynamically in the SVG DTD, and that may be causing
part of the problem, or it may be that Xalan's mechanism for binding the a
namespace dynamically is not functioning correctly.   I found a workaround
by stripping the namespace reference using the local-name() function, but
even here, the namespace parameter entity is not correctly resolved..  I
tested this particular solution with Saxon, and there it appeared to work
correctly.

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.

I'm using Xalan 1.2.1 and Saxon 5.5.1 as my XLST processors.  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 one of the implementations?

Thanks!

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.dtd"
[
	<!ENTITY st11
"fill-rule:evenodd;clip-rule:evenodd;fill:none;stroke-width:4;stroke-linecap
: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"
      xmlns:svg="http://www.w3.org/2000/svg-20000303-stylable"
      xmlns="http://www.w3.org/2000/svg-20000303-stylable"
     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-2000030
3-stylable.dtd"
  		doctype-public="-//W3C//DTD SVG 20000303 Stylable//EN"/>
	    indent="yes"/>     
  
<!--
    Workaround that appears to work in Xalan
    <xsl:template match="*[local-name()='path']">
  -->
     
       <xsl:template match="svg: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.dtd"
>

<!--
    Note that the namespace parameter entity is not resolved.
  -->

<svg xmlns="%SVGNamespace;">
	<g>
	    <addTag><path/></addTag>
	</g>
    <g>	
	    <addTag><path/></addTag>
	</g>
</svg>





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.