次の出力が必要です。
<?xml version="1.0" encoding="UTF-8"?>
<structure:structuralDataRoot xmlns:register="http://www.test.ch/register/1" xmlns:structure="http://test.ch/structure/1" >
<structure:tester>ZH</structure:tester>
<structure:surveyYear>2001</structure:surveyYear>
<structure:surfaceData>
<structure:houseSurfaceData>
<structure:creationDate>2001-01-01</structure:creationDate>
<structure:localFarmId>
<register:houseIdCategory>token</register:houseIdCategory>
<register:houseId>token</register:houseId>
</structure:localFarmId>
</structure:houseSurfaceData>
</structure>
次のように名前空間を xml に追加できます。
xml.records('xmlns:structure' :"http://test.ch/structure/1" ...
しかし、どうすれば xml 要素に名前空間プレフィックスを作成できますか? 私が見つけた唯一の解決策はこれでした:
tester('xmlns:structure' :"http://test.ch/structure/1", 'ZH')
しかし、これにより次の出力が得られます。
<tester xmlns:structure='http://test.ch/structure/1'>ZH</tester>
構文的には正しいですが、多くのノードがある場合は読みにくいです。