开发者

How can I force a JDOM XMLOutputter to write namespace prefixes on all elements?

I'm writing XML that will be consumed by the Windows WebFolder (for mounting a WebDAV volume). WebFolder requires that all elements have a prefix on them, so instead of this:

<one xmlns="DAV:">
    <two /&开发者_开发知识库gt;
    <three />
</one>

I need to do this:

<D:one xmlns:D="DAV:">
    <D:two />
    <D:three />
</D:one>

This is ugly and should be unnecessary, but it's Microsoft, and they do it their way, so whatever. The question is, how can I tell JDOM to write the XML this way?


Found the answer: the JDOM Namespace class has a 3-arg version that takes a local name, namespace, and prefix. If you use that version with the desired prefix, it works as desired. Sorry for the dumb question, maybe this will help somebody else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜