K
Ken Larson
I have a question about using XSL to extract information from an SVG
(XML) file that has a DOCTYPE/DTD declaration. I am able to do this
successfully if I write my own SVG files without such a declaration.
However, I would like to extract some parts of an SVG file exported by
illustrator. When I try this, my XSL file is no longer able to access
the nodes in the SVG document properly - somehow related to the
DOCTYPE/DTD declaration.
My SVG is as follows (I stripped out all of the actual contents for
testing). If I remove the entire DOCTYPE/DTD declaration, everything
works fine.
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 11.0, SVG Export Plug-In . SVG
Version: 6.0.0 Build 78) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
<!ENTITY ns_extend "http://ns.adobe.com/Extensibility/1.0/">
<!ENTITY ns_ai "http://ns.adobe.com/AdobeIllustrator/10.0/">
<!ENTITY ns_graphs "http://ns.adobe.com/Graphs/1.0/">
<!ENTITY ns_vars "http://ns.adobe.com/Variables/1.0/">
<!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/">
<!ENTITY ns_sfw "http://ns.adobe.com/SaveForWeb/1.0/">
<!ENTITY ns_custom "http://ns.adobe.com/GenericCustomNamespace/1.0/">
<!ENTITY ns_adobe_xpath "http://ns.adobe.com/XPath/1.0/">
<!ENTITY ns_svg "http://www.w3.org/2000/svg">
<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
<svg>
<style type="text/css">
</style>
</svg>
My XSL follows. It simply prints "Found SVG" if it finds the svg node.
Like I said, it finds it if the SVG doesn't have the whole DOCTYPE/DTD
declaration. But if I leave the DOCTYPE/DTD declaration in, it only
finds the root.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
Found Root
<xsl:apply-templates select="svg" />
</xsl:template>
<xsl:template match="svg">
Found SVG
</xsl:template>
Thanks,
Ken Larson
(XML) file that has a DOCTYPE/DTD declaration. I am able to do this
successfully if I write my own SVG files without such a declaration.
However, I would like to extract some parts of an SVG file exported by
illustrator. When I try this, my XSL file is no longer able to access
the nodes in the SVG document properly - somehow related to the
DOCTYPE/DTD declaration.
My SVG is as follows (I stripped out all of the actual contents for
testing). If I remove the entire DOCTYPE/DTD declaration, everything
works fine.
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 11.0, SVG Export Plug-In . SVG
Version: 6.0.0 Build 78) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
<!ENTITY ns_extend "http://ns.adobe.com/Extensibility/1.0/">
<!ENTITY ns_ai "http://ns.adobe.com/AdobeIllustrator/10.0/">
<!ENTITY ns_graphs "http://ns.adobe.com/Graphs/1.0/">
<!ENTITY ns_vars "http://ns.adobe.com/Variables/1.0/">
<!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/">
<!ENTITY ns_sfw "http://ns.adobe.com/SaveForWeb/1.0/">
<!ENTITY ns_custom "http://ns.adobe.com/GenericCustomNamespace/1.0/">
<!ENTITY ns_adobe_xpath "http://ns.adobe.com/XPath/1.0/">
<!ENTITY ns_svg "http://www.w3.org/2000/svg">
<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
<svg>
<style type="text/css">
</style>
</svg>
My XSL follows. It simply prints "Found SVG" if it finds the svg node.
Like I said, it finds it if the SVG doesn't have the whole DOCTYPE/DTD
declaration. But if I leave the DOCTYPE/DTD declaration in, it only
finds the root.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
Found Root
<xsl:apply-templates select="svg" />
</xsl:template>
<xsl:template match="svg">
Found SVG
</xsl:template>
Thanks,
Ken Larson