Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > <?standalone yes?>

Reply
Thread Tools

<?standalone yes?>

 
 
Lonnie, SRC employee
Guest
Posts: n/a
 
      09-22-2003
*** 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! =-----

 
Reply With Quote
 
 
 
 
Andrew Clover
Guest
Posts: n/a
 
      09-23-2003
Lonnie, SRC employee <(E-Mail Removed)> 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
(E-Mail Removed)
http://www.doxdesk.com/
 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      09-23-2003
"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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments