如果第一个标签在解组时具有命名空间,则无法读取数据

时间:2013-09-10 18:38:33

标签: java namespaces unmarshalling castor

我有以下xml,其中<first>标记中包含名称空间。 我无法获取<second>代码数据。

<first xmlns= "url" xmlns:xsi="url" xsi:schemaLocation="url">
    <second> hello world </second>
</first>

我写的映射文件:

<mapping>
    <description>A mapping file</description>
    <class name="com.example.data.First">
           <field name="xmlns" type="string" >
               <bind-xml name="xmlns" node="attribute" />
           </field>
           <field name="xmlnsxsi" type="string" >
               <bind-xml name="xmlns:xsi" node="attribute" />
          </field>
          <field name="xsischemaLocation" type="string" >
              <bind-xml name="xsi:schemaLocation" node="attribute" />
          </field>
        <field name="second" type="String"/>
    </class>
</mapping>

我应该在映射文件中更改什么才能获得值?

我正在

org.exolab.castor.xml.MarshalException: The namespace associated with the prefix: 'xmlns' is null.

0 个答案:

没有答案