Hi,

Before trying to address your question(s) one by one, I have got a
question. Given you have an XML schema instance that you want to use for
validation, how come you are not generating the domain and descriptor
classes from the XML schema ? This way, you'd get validation for free.

Regards
Werner

Pokidov Dmitriy wrote:
> Hello, all
> 
> I have simple example that illustrate problem:
> 
> 
> 
> Mapping file:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "
> http://castor.org/mapping.dtd";>
> 
> 
> 
> <mapping>
> 
>             <class name="test2.OrderItem">
> 
>                         <map-to xml="orderitem" ns-uri="
> http://www.otr.ru/sufd/document/desc/"/>
> 
> 
> 
>                         <field name="orderItem" type="test2.OrderItem">
> 
>                                    <bind-xml name="orderitem"
> node="element"/>
> 
>                         </field>
> 
> 
> 
>                         <field name="id" type="string">
> 
>                                    <bind-xml name="identity"
> node="attribute"/>
> 
>                         </field>
> 
> 
> 
>                         <field name="orderQuantity" type="integer">
> 
>                                    <bind-xml name="quantity"
> node="element"/>
> 
>                         </field>
> 
>             </class>
> 
> </mapping>
> 
> 
> 
> Schema file:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
> targetNamespace="http://jopa.org"; xmlns:xs="http://www.w3.org/2001/XMLSchema
> ">
> 
>   <xs:element name="item" type="itemType"/>
> 
>   <xs:complexType name="itemType">
> 
>     <xs:sequence>
> 
>       <xs:element type="xs:string" name="quantity"/>
> 
>     </xs:sequence>
> 
>     <xs:attribute type="xs:string" name="identity"/>
> 
>   </xs:complexType>
> 
> </xs:schema>
> 
> 
> 
> And xml that I want to unmarshall:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <orderitem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> 
>                         xsi:schemaLocation="
> http://www.otr.ru/sufd/document/desc/
> http://otr-sufd/xmlschema/docschema.xsd";
> 
>                         xmlns="http://www.otr.ru/sufd/document/desc/";
> identity="12">
> 
>                         <quantity>100</quantity>
> 
>                         <orderitem
> identity="13"><quantity>100</quantity></orderitem>
> 
> </orderitem>
> 
> 
> 
> And class OrderItem:
> 
> public class OrderItem {
> 
>             private String id;
> 
>             private Integer orderQuantity;
> 
>             private OrderItem orderItem;
> 
> 
> 
>             public OrderItem getOrderItem() {
> 
>                         return orderItem;
> 
>             }
> 
> 
> 
>             public void setOrderItem(OrderItem orderItem) {
> 
>                         this.orderItem = orderItem;
> 
>             }
> 
> 
> 
>             public OrderItem() {
> 
>             }
> 
> 
> 
>             public OrderItem(String id, Integer orderQuantity) {
> 
>                         this.id = id;
> 
>                         this.orderQuantity = orderQuantity;
> 
>             }
> 
> 
> 
>             public String getId() {
> 
>                         return id;
> 
>             }
> 
> 
> 
>             public void setId(String id) {
> 
>                         this.id = id;
> 
>             }
> 
> 
> 
>             public Integer getOrderQuantity() {
> 
>                         return orderQuantity;
> 
>             }
> 
> 
> 
>             public void setOrderQuantity(Integer orderQuantity) {
> 
>                         this.orderQuantity = orderQuantity;
> 
>             }
> 
> }
> 
> 
> 
> And when I unmarshall xml, I get exception:
> 
> java.lang.NoClassDefFoundError: test2/Orderitem (wrong name:
> test2/OrderItem)
> 
>             at java.lang.ClassLoader.defineClass1(Native Method)
> 
>             at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> 
>             at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
> 
>             at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> 
>             at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> 
>             at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> 
>             at java.security.AccessController.doPrivileged(Native Method)
> 
>             at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 
>             at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> 
>             at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
> 
>             at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> 
>             at
> org.exolab.castor.xml.util.resolvers.ResolveHelpers.loadClass(ResolveHelpers.java:140)
> 
>             at
> org.exolab.castor.xml.util.resolvers.ByIntrospection.internalResolve(ByIntrospection.java:87)
> 
>             at
> org.exolab.castor.xml.util.resolvers.AbstractResolverClassCommand.resolve(AbstractResolverClassCommand.java:55)
> 
>             at
> org.exolab.castor.xml.util.resolvers.CastorXMLStrategy.getDescriptor(CastorXMLStrategy.java:137)
> 
>             at
> org.exolab.castor.xml.util.resolvers.CastorXMLStrategy.resolveClass(CastorXMLStrategy.java:82)
> 
>             at
> org.exolab.castor.xml.util.XMLClassDescriptorResolverImpl.resolve(XMLClassDescriptorResolverImpl.java:241)
> 
>             at
> org.exolab.castor.xml.MarshalFramework.searchInheritance(MarshalFramework.java:502)
> 
>             at
> org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1865)
> 
>             at
> org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1418)
> 
>             at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
> 
>             at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:878)
> 
>             at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
> 
>             at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 
>             at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 
>             at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 
>             at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 
>             at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 
>             at
> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:715)
> 
>             at
> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616)
> 
>             at Test2.testUnmarshalItem(Test2.java:61)
> 
>             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
>             at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
>             at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
>             at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
> 
>             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
>             at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
>             at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
>             at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> 
> 
> 
> When I set ns-prefix and write xml with prefix, all work correctly, but I
> need xml without prefixes. Please help me.
> 
> 

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to