I'm trying to follow the recommendations for svg writing at http://jwatt.org/svg/authoring/ and I am generating my svg with xslt. I had some problem with namespaces, and although I think I solved it, I don't really understand how.
My first try at writing svg introduced the svg with
<svg:svg xmlns:svg="http://www.w3.org/2000/svg" width="600px" height="400px" viewBox="-10 -10 620 420">
and all subsequent svg (e.g. rect, circle..) elements had svg: namespace prefixes. In order to get no errors in my editor (oXygen), I had to also declare the svg namespace in the stylesheet header :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:svg="http://www.w3.org/2000/svg">
something about this seemed redundant so I started trimming..
eventually I have ended up with the stylesheet declaration as:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/2000/svg">
and all my svg elements don't need prefixes any more.
Now my questions:
Is this a correct method, i.e. standards compliant, robust What have I done? Have I changed the default namespace to svg? What's the difference between this and using the 'base' attribute in the stylesheet element?
I looked on the web but don't find this use of xmlns (with no namespace element) documented.
thanks
shaun
My first try at writing svg introduced the svg with
<svg:svg xmlns:svg="http://www.w3.org/2000/svg" width="600px" height="400px" viewBox="-10 -10 620 420">
and all subsequent svg (e.g. rect, circle..) elements had svg: namespace prefixes. In order to get no errors in my editor (oXygen), I had to also declare the svg namespace in the stylesheet header :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:svg="http://www.w3.org/2000/svg">
something about this seemed redundant so I started trimming..
eventually I have ended up with the stylesheet declaration as:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/2000/svg">
and all my svg elements don't need prefixes any more.
Now my questions:
Is this a correct method, i.e. standards compliant, robust What have I done? Have I changed the default namespace to svg? What's the difference between this and using the 'base' attribute in the stylesheet element?
I looked on the web but don't find this use of xmlns (with no namespace element) documented.
thanks
shaun