Jump to content
FlecheBleu

XML and SVG and namespace difficulties

Recommended Posts

Hello Community,

I'm stuck on this namespace thing, I think !!!

I would like to read an XML file that contains SVG markup.

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.2" width="149.2mm" height="211.7mm" viewBox="0 0 14920 21170" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:presentation="http://sun.com/xmlns/staroffice/presentation" xmlns:smil="http://www.w3.org/2001/SMIL20/" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xml:space="preserve">
 <defs>...</svg>

I have this piece of code to check the loading of the :

$oXML = ObjCreate('Msxml2.DOMDocument.6.0')

; Setting File IN/OUT

$Fichierin="e:\in.svg"
$Fichierout= StringReplace($Fichierin,".","-maj.")

; Calling  XML File

$oXML.load($Fichierin)
$oXML.setProperty("SelectionLanguage", "XPath")
$strNameSpc = "xmlns:svg='http://www.w3.org/2000/svg'"
$oXML.setProperty("SelectionNamespaces", $strNameSpc)


$oRoot = $oXML.selectSingleNode("//svg:defs")

ConsoleWrite("$oRoot.xml=[" & $oRoot.xml  & "]" & @CRLF)

Result => empty.

On the other hand, if I remove the header from the SVG file like this:

<svg version="1.2" width="149.2mm" height="211.7mm" viewBox="0 0 14920 21170" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:presentation="http://sun.com/xmlns/staroffice/presentation" xmlns:smil="http://www.w3.org/2001/SMIL20/" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xml:space="preserve">
 <defs>... </svg>

it's ok I have the XML file that can be used in Autoit.

Do you have any research leads?

Thanks in advance

Share this post


Link to post
Share on other sites
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

Remove the DOCTYPE line from your svg file and your script should work.

The reason your script fails with the DOCTYPE line is because the .Load method generates an error due to the DTD.  Therefore, you do not have a valid XML document object to work with.  So any statements referencing the XML document object will fail also.

 

Side Note:

Unfortunately the SVG DTDs are a source of so many issues that the SVG WG has decided not to write one for the upcoming SVG 1.2 standard. In fact SVG WG members are even telling people not to use a DOCTYPE declaration in SVG 1.0 and 1.1 documents. Instead always include the 'version' and 'baseProfile' attributes on the root <svg> tag, and assign them appropriate values.

https://dev.w3.org/SVG/profiles/2.0/publish/intro.html

Edited by TheXman
Fixed the content of the side note

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...