Thanks
I was thinking to make it short. So I used classes instead of packages.
context = JAXBContext.newInstance(RuleSet.class, UnknownBooleanPermission.class, ProvideDevicePermission.class, ProvidePersonPermission.class, ProvideServicePermission.class, ProvideAllAttributes.class);
But I was looking a solution to make it even shorter as I have the last 5 class in the same package.
It is any way cosmetic! Or programming by default! I have only implemented my solution for the UnknownBooleanPermission.class. It will work without problem when implementing other classes that are in the same package.
I have tested the following and it works fine.
context = JAXBContext.newInstance(RuleSet.class.getPackage().getName() + ":" + UnknownBooleanPermission.class.getPackage().getName());
lulseged
-----Original Message-----
From: jyoti chhabra [mailto:jyoti.chhabra_at_gmail.com]
Sent: den 26 juni 2009 08:28
To: users_at_jaxb.dev.java.net
Subject: Re: Re: Marshalling from two shemas
You could give multiple package names, separated by ':'
Something like this:
context = JAXBContext.newInstance(RuleSet.class.getPackage().getName() + ":" +
UnknownBooleanPermission.class.getPackage().getName() + ":" +
ProvideServicePermission.class.getPackage().getName());
More information could be found here :
http://java.sun.com/javaee/5/docs/api/javax/xml/bind/JAXBContext.html
Regards,
Jyoti
On Fri, Jun 26, 2009 at 11:45 AM, Lulseged Zerfu<lulseged.zerfu_at_ericsson.com> wrote:
> Hi
>
> I have used only one class in the context.
>
> context = JAXBContext.newInstance(RuleSet.class);
>
> But now I have added more classes and it looks like:
>
> context = JAXBContext.newInstance(RuleSet.class,
> UnknownBooleanPermission.class, ProvideServicePermission.class);
>
> And it works!
>
> But can I give only packages names instead of classes?
>
> I will try!
>
> Thanks as always.
>
> Lulseged
>
> -----Original Message-----
> From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
> Sent: den 26 juni 2009 07:55
> To: users_at_jaxb.dev.java.net
> Subject: Re: Marshalling from two shemas
>
> How do you create the context? Are you passing in both package names?
> -W
>
>
> On 6/26/09, Lulseged Zerfu <lulseged.zerfu_at_ericsson.com> wrote:
>> Hi
>>
>> One more question regarding marshalling:
>>
>> My document is made up of two standard schemas: (schemas attached)
>>
>> urn:ietf:params:xml:ns:pres-rules imports
>> urn:ietf:params:xml:ns:common-policy.
>>
>> There are two ObjectFactory.java class created when compiling with
>> xjc, one for each schema:
>>
>> Marshalling a java representation of a document made up up of this
>> two
>
>> schemas is not working. Complains about
>> ietf.params.xml.ns.pres.rules.ProvideServicePermission is not known
>> to
>
>> this context
>>
>> When trying to marshall so that the output xml document looks like as
>> follows:
>>
>> <?xml version="1.0" encoding="UTF-8"?> <cr:ruleset
>> xmlns="urn:ietf:params:xml:ns:pres-rules"
>> xmlns:pr="urn:ietf:params:xml:ns:pres-rules"
>> xmlns:cr="urn:ietf:params:xml:ns:common-policy">
>> <cr:rule id="a">
>> <cr:conditions>
>> <cr:identity>
>> <cr:one id="sip:user_at_example.com" />
>> </cr:identity>
>> </cr:conditions>
>> <cr:actions>
>> <pr:sub-handling>allow</pr:sub-handling>
>> </cr:actions>
>> <cr:transformations>
>> <pr:provide-services>
>>
>> <pr:service-uri-scheme>sip</pr:service-uri-scheme>
>>
>> <pr:service-uri-scheme>mailto</pr:service-uri-scheme>
>> </pr:provide-services>
>> <pr:provide-activities>true</pr:provide-activities>
>> <pr:provide-user-input>bare</pr:provide-user-input>
>> </cr:transformations>
>> </cr:rule>
>> </cr:ruleset>
>>
>> The red part of this xml document comes from the second schema. But
>> how do marshall so that this become output.
>>
>>
>>
>> Lulseged
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net