Skip to main content

Getting rid of repetitive namespace URI prefixes

1 reply [Last post]
michaljakob
Offline
Joined: 2005-05-18

Hi,

I'm not an expert on XML, so this questions might be a bit confused. When marshalling a List containing String and Float object, the resulting XML looks as follows:

<br />
<?xml version="1.0" encoding="UTF-8" standalone="yes"?></p>
<p>text</p>
<p>3.141</p>
<p>

(I put an extra space above between ':' and 'x' to supress stupid smileys appearing otherwise)

Is there any way to get rid of the repetitive namespace URI prefixes (xmlns: xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns: xs="http://www.w3.org/2001/XMLSchema")? I intend to use XML files as manually editable configuration files, so maximum simplicity is important.

Thanks for any suggestions,
Michal

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09

You can use NamespacePrefixMapper to put those two namespaces at the root element.

Another way to avoid having xsi:type altogether is to annotate your List

as: [code] @XmlElements({ @XmlElement(type=String.class,name="string"), @XmlElement(type=Float.class,name="float") }) List data; [/code] This makes your XML somethling like: [code] text 3.141 [/code]