Hi Tim,

It was definately related to the matches="*". I've checked in a patch to
the CVS to fix the problem. If you're already using the code from the
CVS, just do an update. If not, Castor is pretty straight forward to
build. Just do a CVS checkout per the instructions on the website and
then run the build script from the "castor" directory.

Thanks,

--Keith

"Bardzil, Timothy J (Timothy)" wrote:
> 
> Keith,
> 
> I tried adding the 'ns-uri' attribute to each of my class definitions in the mapping 
> file but that didn't seem to help.  The problem seems to have something to do with 
> the 'matches=*' attribute that I have used to unmarshall a variety of tags into a 
> heterogenious collection.
> 
> Below is my complete mapping file and example XML.  Last time it was abbreviated.
> 
> Thanks,
> Tim
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <paths xmlns="http://avaya.com/services/elat/paths/2.0";>
> 
>     <route from="10.1.1.1" to="10.1.2.0/24">
>         <path id="10.1.2.1">
>             <agent target="10.1.1.1"/>
> 
>             <router target="10.1.1.254">
>                 <ingress ifIndex="1"/>
>                 <egress ifIndex="2"/>
>             </router>
> 
>             <host target="10.1.2.1"/>
>         </path>
>     </route>
> 
>     <route from="10.1.1.1" to="10.1.5.0/24">
>         <path id="10.1.6.1">
>             <agent target="10.1.1.1"/>
> 
>             <router target="10.1.1.254">
>                 <ingress ifIndex="1"/>
>                 <egress ifIndex="3"/>
>             </router>
> 
>             <router target="10.1.3.254">
>                 <ingress ifIndex="3"/>
>                 <egress ifIndex="5"/>
>             </router>
> 
>             <router target="10.1.5.254">
>                 <ingress ifIndex="5"/>
>                 <egress ifIndex="6"/>
>             </router>
> 
>             <host target="10.1.6.1"/>
>         </path>
> 
>         <path id="10.1.6.2">
>             <agent target="10.1.1.1"/>
> 
>             <router target="10.1.1.254">
>                 <ingress ifIndex="1"/>
>                 <egress ifIndex="3"/>
>             </router>
> 
>             <router target="10.1.3.254">
>                 <ingress ifIndex="3"/>
>                 <egress ifIndex="4"/>
>             </router>
> 
>             <router target="10.1.4.254">
>                 <ingress ifIndex="4"/>
>                 <egress ifIndex="6"/>
>             </router>
> 
>             <host target="10.1.6.2"/>
>         </path>
>     </route>
> 
>     <route from="10.1.1.1" to="10.1.7.0/24">
>         <path id="10.1.10.1">
>             <agent target="10.1.1.1"/>
> 
>             <router target="10.1.1.254">
>                 <ingress ifIndex="1"/>
>             </router>
> 
>             <cloud reason="load-balancing">
>                 <nexthop>10.1.7.253</nexthop>
>                 <nexthop>10.1.8.253</nexthop>
>                 <nexthop>10.1.9.253</nexthop>
>             </cloud>
> 
>             <host target="10.1.10.1"/>
> 
>         </path>
>     </route>
> 
>     <route from="10.1.1.1" to="10.1.12.0/24">
>         <path id="10.1.12.1">
>             <agent target="10.1.1.1"/>
> 
>             <router target="10.1.1.254">
>                 <ingress ifIndex="1"/>
>                 <egress ifIndex="11"/>
>             </router>
> 
>             <router target="10.1.11.254">
>                 <ingress ifIndex="11"/>
>                 <egress ifIndex="12"/>
> 
>                 <asymmetry type="detected">
>                     <dest>10.1.1.0/24</dest>
>                     <nexthop>10.1.10.253</nexthop>
>                 </asymmetry>
>             </router>
> 
>             <host target="10.1.12.1"/>
>         </path>
>     </route>
> 
> </paths>
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <mapping>
> 
>     <class name="com.avaya.cirs.model.path.Topology">
>         <description>
>         Top level mapping.  Maps a complete path file to a Topology object
>         </description>
>         <map-to xml="paths" ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>         <field name="routes" type="com.avaya.cirs.model.path.Route" 
> collection="arraylist">
>             <bind-xml name="route" node="element" />
>         </field>
>     </class>
> 
>     <class name="com.avaya.cirs.model.path.Route">
>         <description>Mapping for a route</description>
>         <map-to ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>         <field name="from" type="string">
>             <bind-xml node="attribute" name="from" />
>         </field>
>         <field name="to" type="string">
>             <bind-xml node="attribute" name="to" />
>         </field>
>         <field name="paths" type="com.avaya.cirs.model.path.Path" 
> collection="arraylist">
>             <bind-xml name="path" node="element" />
>         </field>
>     </class>
> 
>     <class name="com.avaya.cirs.model.path.Path">
>         <description>Mapping for a path</description>
>         <map-to ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>         <field name="elements" type="other" collection="arraylist">
>             <bind-xml node="element" matches="*"/>
>         </field>
>         <field name="pathId" type="string">
>             <bind-xml node="attribute" name="id"/>
>         </field>
>     </class>
> 
>     <class name="com.avaya.cirs.model.path.Hop">
>         <description>Base mapping for all hops to the abstract Hop 
> class</description>
>         <map-to ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>         <field name="targetId" type="string">
>             <bind-xml node="attribute" name="target" />
>         </field>
>         <field name="ttl" type="integer">
>             <bind-xml node="attribute" name="ttl" />
>         </field>
>     </class>
> 
>    <class name="com.avaya.cirs.model.path.AgentHop"
>           extends="com.avaya.cirs.model.path.Hop">
>        <description>Extends the hop mapping for an agent hop</description>
>        <map-to xml="agent" ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>    </class>
> 
>    <class name="com.avaya.cirs.model.path.HostHop"
>           extends="com.avaya.cirs.model.path.Hop">
>        <description>Extends the hop mapping for an agent hop</description>
>        <map-to xml="host" ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>    </class>
> 
>    <class name="com.avaya.cirs.model.path.RouterHop"
>           extends="com.avaya.cirs.model.path.Hop">
>        <description>Extends the hop mapping for a router hop</description>
>        <map-to xml="router" ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>        <field name="ingress" type="com.avaya.cirs.model.target.Interface">
>            <bind-xml node="element" name="ingress"/>
>        </field>
>        <field name="egress" type="com.avaya.cirs.model.target.Interface">
>            <bind-xml node="element" name="egress"/>
>        </field>
>        <field name="asymmetry" type="com.avaya.cirs.model.path.Asymmetry">
>            <bind-xml node="element" name="asymmetry"/>
>        </field>
>    </class>
> 
>    <class name="com.avaya.cirs.model.target.Interface">
>        <description>
>        Default mapping for Interface.  Acts as a placeholder until the actual
>        Interface object is applied from the Targets information post-marshalling.
>        See com.avaya.cirs.model.path.PathUnmarshalListener
>        </description>
>        <map-to ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>        <field name="ifIndex" type="integer">
>            <bind-xml name="ifIndex" node="attribute"/>
>        </field>
>    </class>
> 
>    <class name="com.avaya.cirs.model.path.Asymmetry">
>        <description>Mapping for asymmetry information on a router</description>
>        <map-to xml="asymmetry" ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>        <field name="type" type="string">
>            <bind-xml name="type" node="attribute"/>
>        </field>
>        <field name="dest" type="string">
>            <bind-xml name="dest" node="element"/>
>        </field>
>        <field name="nexthop" type="string">
>            <bind-xml name="nexthop" node="element"/>
>        </field>
>    </class>
> 
>    <class name="com.avaya.cirs.model.path.Cloud">
>        <description>Mapping for a cloud</description>
>        <map-to xml="cloud" ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>        <field name="reason" type="string">
>            <bind-xml node="attribute" name="reason"/>
>        </field>
>        <field name="nexthops" type="string" collection="arraylist">
>             <bind-xml node="element" name="nexthop"/>
>        </field>
>    </class>
> 
> </mapping>
> 
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 23, 2003 12:50 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Problem unmarshalling document with namespace
> 
> If you add a namespace to your XML instance, then effectively, you have
> changed the "scoping" of your XML names. You must also now use
> namespaces in your mapping file.
> 
> For example:
> 
> <class name="...">
> 
>    <map-to ns-uri="http://avaya.com/services/elat/paths/2.0"/>
>    ...
> </class>
> 
> --Keith
> 
> > "Bardzil, Timothy J (Timothy)" wrote:
> >
> > I am having some trouble unmarshalling XML using a mapping file.
> > Everything works fine until I add a default namespace attribute to the
> > root of the document.
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <path id="10.1.12.1" xmlns="http://avaya.com/services/elat/paths/2.0";>
> >       <agent target="10.1.1.1" ttl="0"/>
> >
> >       <router target="10.1.1.254" ttl="1">
> >         <ingress ifIndex="1"/>
> >         <egress ifIndex="11"/>
> >       </router>
> >
> >       <router target="10.1.11.254" ttl="2">
> >         <ingress ifIndex="11"/>
> >         <egress ifIndex="12"/>
> >       </router>
> >
> >       <host target="10.1.12.1" ttl="3"/>
> > </path>
> >
> > I then get the following error:
> >
> > 1)
> > testSinglePath(com.avaya.cirs.model.path.test.TestElementMapping)org.xml.sax.SAXException:
> > unable to find FieldDescriptor for 'agent' in ClassDescriptor of path
> >  at
> > org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1224)
> >  at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> > Source)
> >  at
> > org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
> > Source)
> >  at
> > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> > Source)
> >  at
> > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> > Source)
> >  at
> > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> > Source)
> >  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
> >  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
> >  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> >  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> >  at
> > org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555)
> >  at
> > org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:487)
> >  at
> > com.avaya.cirs.model.path.test.TestElementMapping.assertMapping(TestElementMapping.java:48)
> >  at
> > com.avaya.cirs.model.path.test.TestElementMapping.testSinglePath(TestElementMapping.java:86)
> >  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.TextTestRunner.main(TextTestRunner.java:12)
> > Without the namespace attribute everything works just fine.  Any
> > ideas?  The mapping file is below:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <mapping>
> >         <class name="com.avaya.cirs.model.path.Path">
> >         <description>Mapping for a path</description>
> >         <map-to xml="path"/>
> >         <field name="elements" type="java.lang.Object"
> > collection="arraylist">
> >             <bind-xml node="element" matches="*"/>
> >         </field>
> >         <field name="pathId" type="string">
> >             <bind-xml node="attribute" name="id"/>
> >         </field>
> >     </class>
> >
> >     <class name="com.avaya.cirs.model.path.Hop">
> >         <description>Base mapping for all hops to the abstract Hop
> > class</description>
> >         <field name="targetId" type="string">
> >             <bind-xml node="attribute" name="target" />
> >         </field>
> >         <field name="ttl" type="integer">
> >             <bind-xml node="attribute" name="ttl" />
> >         </field>
> >     </class>
> >
> >    <class name="com.avaya.cirs.model.path.AgentHop"
> >           extends="com.avaya.cirs.model.path.Hop">
> >        <description>Extends the hop mapping for an agent
> > hop</description>
> >        <map-to xml="agent"/>
> >    </class>
> >
> >    <class name="com.avaya.cirs.model.path.HostHop"
> >           extends="com.avaya.cirs.model.path.Hop">
> >        <description>Extends the hop mapping for an agent
> > hop</description>
> >        <map-to xml="host"/>
> >    </class>
> >
> >    <class name="com.avaya.cirs.model.path.RouterHop"
> >           extends="com.avaya.cirs.model.path.Hop">
> >        <description>Extends the hop mapping for a router
> > hop</description>
> >        <map-to xml="router"/>
> >        <field name="ingress"
> > type="com.avaya.cirs.model.target.Interface">
> >            <bind-xml node="element" name="ingress"/>
> >        </field>
> >        <field name="egress"
> > type="com.avaya.cirs.model.target.Interface">
> >            <bind-xml node="element" name="egress"/>
> >        </field>
> >        <field name="asymmetry"
> > type="com.avaya.cirs.model.path.Asymmetry">
> >            <bind-xml node="element" name="asymmetry"/>
> >        </field>
> >    </class>
> >
> >    <class name="com.avaya.cirs.model.target.Interface">
> >        <description>
> >        Default mapping for Interface.  Acts as a placeholder until the
> > actual
> >        Interface object is applied from the Targets information
> > post-marshalling.
> >        See com.avaya.cirs.model.path.PathMarshalListener
> >        </description>
> >        <field name="ifIndex" type="integer">
> >            <bind-xml name="ifIndex" node="attribute"/>
> >        </field>
> >    </class>
> > </mapping>
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

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

Reply via email to