> > I must add some constraints not supported by XML Schema. I thought to do
it
> > by derive generated classes,write own validators and add to class
> > descriptors. But how to do it?
> >
>
> When you derive a class, you must also create a class descriptor by
> extending the class descriptor for the parent class.
>
> For example...if you have a generate class "Foo" with descriptor
> "FooDescriptor", and you want to extend "Foo" as "MyFoo" then you also
> need to extend "FooDescriptor" as "MyFooDescriptor".
>
I know it. I wrote own validator (extends
org.exolab.castor.xml.FieldValidator) and set it in constructor of
MyFooDescriptor:

    public MyFooDescriptor() {
        super();

        //name is element of foo
        XMLFieldDescriptorImpl fd =
(XMLFieldDescriptorImpl)getFieldDescriptor("name", null);
        fd.setValidator(new CustomValidator());
    }

But what to do to force validator, unmarshaler and marshaler to use MyFoo
instead of Foo (or Foo with MyFooDescriptor)? Foo is not root element!!

I tried:

            ClassDescriptorResolverImpl cdr = new
ClassDescriptorResolverImpl();
            cdr.associate(Foo.class, new MyFooDescriptor());

            Unmarshaller un = new Unmarshaller(Document.class);
            un.setResolver(cdr);

but it doesn't work.

And another problem. I must check value of another object in tree to check
is object validate. Is there any way to get parent object of field or
attribute?

thanks a lot
Marcin




-- 

Okresl Swoje potrzeby - my znajdziemy oferte za Ciebie!
[ http://oferty.onet.pl ]

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to