0
我正在使用XMLBeans從XSD模式生成Java對象。 該架構的結構如下:XMLBeans嵌套複雜元素實例化失敗
<schema targetNamespace="" xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<element name="Father">
<complexType>
<all>
<element name="Son">
<complexType>
<all>
<element name="Target" type="string" />
</all>
</complexType>
</element>
</all>
</complexType>
</element>
</schema>
該架構還好吧編譯,我能夠通過實例化父:
Father father = Father.Factory.newInstance();
但是,當我嘗試執行:
father.getSon().setTarget("Some String");
我得到一個空指針異常。調試時,我看到Son是空的(因此是例外)。 我需要的是設置「目標」值,但我想不出辦法做到這一點......
有沒有辦法自動構建所有的XSD結構?或者,我可以手動實例化「Son」,然後訪問其「Target」?
非常感謝!
O.J
工程就像一個魔術。這正是我應該做的。謝謝! – 2011-03-23 09:52:52