By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,206 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,206 IT Pros & Developers. It's quick & easy.

<?standalone yes?>

P: n/a
*** post for FREE via your newsreader at post.newsfeed.com ***

I can figure out how to set the standalone attribute in the <? xml
version="1.0 ?> tag eg <?xml version="1.0" standalone="yes" ?>

closest I have got to what I need is:
<?xml version="1.0" ?>
<?standalone yes?>
<xpg creator="crusher" version="1.0">
<etr>
<rebmun>

using minidom in this code(snippet):
xmldoc = Document()
pi = xmldoc.createProcessingInstruction("standalone","y es")
xmldoc.appendChild(pi)
xmlroot = xmldoc.createElement("xpg")
xmlroot.setAttribute("version","1.0")
xmlroot.setAttribute("creator","crusher")
xmldoc.appendChild(xmlroot)

thx
Lonnie Souder

-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lonnie, SRC employee <lo*****@tgf.tc.faa.gov> wrote:
I can figure out how to set the standalone attribute in the <? xml
version="1.0 ?> tag eg <?xml version="1.0" standalone="yes" ?>


To set this in DOM terms you would need to use the DOM Level 3 Core
property 'xmlStandalone' on the Document object, see:

http://www.w3.org/TR/DOM-Level-3-Cor...nt3-standalone

However, DOM3 is still in Working Draft (though hopefully not for
much longer), and it's not yet supported by minidom. If you don't mind
trying a different DOM implementation, this one supports it:

http://www.doxdesk.com/software/py/pxdom.html

--
Andrew Clover
mailto:an*@doxdesk.com
http://www.doxdesk.com/
Jul 18 '05 #2

P: n/a
"Lonnie, SRC employee" wrote:

*** post for FREE via your newsreader at post.newsfeed.com ***

I can figure out how to set the standalone attribute in the <? xml
version="1.0 ?> tag eg <?xml version="1.0" standalone="yes" ?>


Simplest approach might be to manually munge the <?xml ?> tag
as you write the output to a file. You could do a simple re.sub()
or something like this, which we've used from time to time with no
ill effects to date (pseudo-code, not executable as-is):

xml = '<?xml version="1.0"?><doc><somestuff/></doc>'

xmlEnd = xml.find('?>') + 2

file.write('<?xml standalone="yes" version="1.0"?>' + xml[xmlEnd:])

In other words, find the end of the original <?xml?> tag, strip it,
substitute your own, continue on with life.

Simplest thing that could possibly work...

-Peter
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.