Hi there,

 

I have a problem concerning namespaces. I have a very simple XML file like this:

 

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="">

<Person xmlns="http://www.iese.fhg.de/Person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iese.fhg.de/Person Person.xsd">

            <lastname>Mustermann</lastname>

            <firstname>Karl</firstname>

            <author type="association" href="">

            <employee type="association" href="">

</Person>

 

which is based on the following xsd schema:

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<xs:schema targetNamespace="http://www.iese.fhg.de/Person" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.iese.fhg.de/Person" elementFormDefault="qualified" attributeFormDefault="unqualified">

            <xs:element name="Person" type="PersonType"/>

            <xs:complexType name="PersonType">

                        <xs:sequence>

                                   <xs:element name="lastname" type="xs:string"/>

                                   <xs:element name="firstname" type="xs:string"/>

                                   <xs:element name="author" minOccurs="0" maxOccurs="unbounded">

                                               <xs:complexType>

                                                           <xs:attribute name="type" type="xs:string" use="required" fixed="association"/>

                                                           <xs:attribute name="href" type="xs:anyURI" use="required"/>

                                               </xs:complexType>

                                   </xs:element>

                                   <xs:element name="employee" minOccurs="0" maxOccurs="unbounded">

                                               <xs:complexType>

                                                           <xs:attribute name="type" type="xs:string" use="required" fixed="association"/>

                                                           <xs:attribute name="href" type="xs:anyURI" use="required"/>

                                               </xs:complexType>

                                   </xs:element>

                        </xs:sequence>

            </xs:complexType>

</xs:schema>

 

I want to use castor to manipulate the XML file an marshall it back into absolutly the same file structure. I was using mapping file:

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE databases PUBLIC

  "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"

  "http://castor.exolab.org/mapping.dtd">

<mapping>

    <class name="bindtest.Person">

        <map-to xml="Person"/>

                        <field name="_lastname" type="string">

            <bind-xml name="lastname"/>

        </field>       

        <field name="firstname" type="string">

            <bind-xml name="firstname"/>

        </field>

        <field collection="array" name="author" type="bindtest.Author">

            <bind-xml name="author"/>

        </field>

        <field collection="array" name="employee" type="bindtest.Employee">

            <bind-xml name="employee"/>

        </field>

    </class>

    <class name="bindtest.Author">

        <field name="type" type="string">

            <bind-xml name="type" node="attribute"/>

        </field>

        <field name="href" type="string">

            <bind-xml name="href" node="attribute"/>

        </field>

    </class>

    <class name="bindtest.Employee">

        <field name="type" type="string">

            <bind-xml name="type" node="attribute"/>

        </field>

        <field name="href" type="string">

            <bind-xml name="href" node="attribute"/>

        </field>

    </class>

</mapping>

 

The resulting XML file looked almost the same as the input XML file but no namespace declarations and no stylesheet definition. When I use the namespace attribute in the map-to element I can only define 1 single namespace but not several. Any suggestions?

 

Best regards,

Nick

Reply via email to