Re: [Simple-support] elementFormDefault
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2009-01-28 19:20:48
|
Hi,
The XML
<pfx:MyRoot xmlns:pfx="namespace">
<SubElement/>
</pfx:MyRoot>
is equal to
<pfx:MyRoot xmlns:pfx="namespace">
<pfx:SubElement/>
</pfx:MyRoot>
I realise that the prefixes are redundant but the qualification is identical. If you want you can do this.
@Root
@NamespaceList({@Namespace(reference="default")})
@Namespace(prefix="pfx", reference="namespace")
class MyRoot {
@Element
@Namespace(reference="default")
private SubElement subElement;
}
Which will give you.
<pfx:MyRoot xmlns:pfx="namespace" xmlns="default">
<SubElement/>
</pfx:MyRoot>
But this has a difference qualification to the XML you provide.
Niall
--- On Wed, 1/28/09, Wetmiller, Eric <ewe...@ha...> wrote:
> From: Wetmiller, Eric <ewe...@ha...>
> Subject: RE: [Simple-support] elementFormDefault
> To: gal...@ya...
> Date: Wednesday, January 28, 2009, 10:55 AM
> I tried that and I got the following while serializing my
> Object:
>
> <pfx:MyRoot xmlns:pfx="namespace">
> <SubElement xmlns=""/>
> </pfx:MyRoot>
>
> This is what I was expecting:
>
> <pfx:MyRoot xmlns:pfx="namespace">
> <SubElement/>
> </pfx:MyRoot>
>
> -----Original Message-----
> From: Niall Gallagher [mailto:gal...@ya...]
> Sent: Wednesday, January 28, 2009 1:49 PM
> To: sim...@li...; Wetmiller, Eric
> Subject: Re: [Simple-support] elementFormDefault
>
>
> Just use @Namespace without anything and all children of
> that object
> will be unqualified. You can put it on @Elements or
> @Attributes as well
> as @Root. And even on @Version. No need so keep specifying.
>
>
> --- On Wed, 1/28/09, Wetmiller, Eric
> <ewe...@ha...> wrote:
>
> > From: Wetmiller, Eric <ewe...@ha...>
> > Subject: [Simple-support] elementFormDefault
> > To: sim...@li...
> > Date: Wednesday, January 28, 2009, 10:46 AM
> > I am using SimpleXML version 2.0.2 and was wondering
> if
> > there is a way
> > to set elementFormDefault="unqualified" on
> my
> > schema. It appears that I
> > have to qualify all of the sub-elements in my schema.
> So,
> > in other
> > words, when I set my root element namespace, ie
> > @Namespace("pfx",
> > "namespace"), I have to use prefix for all
> > sub-elements also. Any help
> > would be appreciated.
> >
> >
> >
> > -Eric
> >
> >
> ------------------------------------------------------------------------
> ------
> > This SF.net email is sponsored by:
> > SourcForge Community
> > SourceForge wants to tell your story.
> >
> http://p.sf.net/sfu/sf-spreadtheword____________________________________
> ___________
> > Simple-support mailing list
> > Sim...@li...
> >
> https://lists.sourceforge.net/lists/listinfo/simple-support
|