xs:anyType issue – ElementNSImpl Vs Node
XSD is having element like this
<xs:element name="companyname" type="xs:anyType" minOccurs="0"/>
JAXB Generated Class is having code like this
protected Object companyname;
To fetch the data we are using
final ElementNSImpl element = (ElementNSImpl)atGiven;
To resolve this element we can use either of this.
If we use this import, it is working in Eclipse. But failing in osgi.
import org.apache.xerces.dom.ElementNSImpl;
java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to org.apache.xerces.dom.ElementNSImpl
If we use this import, paxrunner with Equinox is failing to do boot delegation com.sun.*
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
We have two solutions:
replace xs:anyType to xs:string if permits.
or
Make sure that boot delegation works.
Final Solution:
It is better not to use code specific to implementation.
It is better to use interface. Due to this used Node and resolved the issue.
import org.w3c.dom.Node;
-o-



