Reputation: 1100
@XmlElement(nillable=true, required=true)
public String myNillableThing;
...
<myNillableThing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
...
...
<myNillableThing xs:nil="true"/>
<-- note xs, not xsi -->
...
I'll be honest, I don't know what either of those attributes mean, but I am trying to produce a file which replicates a very specific example and those are the tags shown on the example file.
Upvotes: 0
Views: 23
Reputation: 100143
What you have is semantically identical to what you want, I believe.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defines the token xsi
to be that URL. You have to define some prefix. Now, you might have a document in which you see xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
up higher in the structure, and then a reference to xs:nil
down below. But someone has to define the prefix, there are no prefixed provided by default.
To an XML parser, all of this is just syntax around the pair:
http://www.w3.org/2001/XMLSchema-instance, nil
the prefixes have no semantic value. If you are parsing XML without a true parser, and just looking literally for 'xs:nil', you are potentially in for all kinds of problems.
Upvotes: 0