<?standalone yes?>

Discussion in 'Python' started by Lonnie, SRC employee, Sep 22, 2003.

  1. *** 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","yes")
    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! =-----
    Lonnie, SRC employee, Sep 22, 2003
    #1
    1. Advertising

  2. Lonnie, SRC employee <> 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-Core/core.html#Document3-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:
    http://www.doxdesk.com/
    Andrew Clover, Sep 23, 2003
    #2
    1. Advertising

  3. Lonnie, SRC employee

    Peter Hansen Guest

    "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
    Peter Hansen, Sep 23, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike John

    Yes, it's running in explorer

    Mike John, Jul 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    312
    Kevin Spencer
    Jul 9, 2003
  2. John
    Replies:
    6
    Views:
    49,348
    JohnPantoo
    Sep 23, 2011
  3. teo
    Replies:
    3
    Views:
    533
  4. tah

    standalone="yes"

    tah, Oct 24, 2006, in forum: XML
    Replies:
    7
    Views:
    771
  5. Jamie Herre
    Replies:
    1
    Views:
    193
    why the lucky stiff
    Jan 7, 2005
Loading...

Share This Page