saving destroys xml source code with namespace prefixes

  • Author
    Posts
  • #196686

    ronnyrubber
    Member

    Hi,

    I’ve chosen WordPress to start a technical blog because of its support for source code syntax highlighting (http://faq.wordpress.com/2007/09/03/how-do-i-post-source-code/). However, when I enter XML source code containing namespace prefixes, this gets all cluttered when saving. For example, after saving, following fragment:

    [sourcecode language="xml"]
    <test:test xmlns:test="test">
    <test:hello>world</test:hello>
    </test:test>
    [/sourcecode]

    is mutilated to:

    [sourcecode language="xml"]
    <test :test xmlns:test="http://www.test.me">
    </test><test :hello>world</test>
    [/sourcecode]

    Note that this is *not* a highlighting issue; the problem occurs when saving a post, and only with namespace-prefixed XML source code. Is there any workaround?

    Kind regards,

    Ron Van den Branden

    #196791

    ronnyrubber
    Member

    Sigh,

    The issue isn’t limited to namespace prefixes: it is triggered as well when XML elements have hyphens in their name.


    [sourcecode language="xml"]
    <test-test>
    <test-hello>world</test-hello>
    </test-test>
    [/sourcecode]

    is saved as

    [sourcecode language="xml"]
    <test -test>
    </test><test -hello>world</test>
    [/sourcecode]

    …which turns marking up XML source code examples on my blog into a pretty useless exercise… I hope it can be fixed?

    Kind regards,

    Ron

    #196792

    ronnyrubber
    Member

    Aha,

    I have found the cause: the formatting option “WordPress should correct invalidly nested XHTML automatically” was responsible. If I disable this option, all goes well.

    Quite a relief for me (since WP generally seems a great tool), and hopefully WP developers know where to look now.

    Cheers,

    Ron Van den Branden

    #196948

    nsaunders
    Member

    Thanks so much for this tip. I experienced a similar problem when trying to include regexes for HTML (such as <\/b&#gt;) in source code: a space was introduced into the tag. Disabling the XHTML correction worked for me.

The topic ‘saving destroys xml source code with namespace prefixes’ is closed to new replies.