我想使用XQuery從我的XML文檔生成Java源代碼,例如:XQuery - 是否可以生成非XML文檔?
<configuration package="my.package.name">
<property>
<name>First</name>
<value>0</value>
<description>First description</description>
</property>
<property>
<name>Second</name>
<value>2</value>
<description>Second description</description>
</property>
...
應該產生:
package my.package.name;
class MyClass {
// First description
private String first;
// Second description
private String second;
}
我試圖像這樣開頭:
xquery version "1.0";
"package "+$doc/@package
"class "+$doc/@classname
{
for $property in $doc//property
return {
"private String "+$property/name::text()
}
}
語法顯然不正確,我不知道它是否可行。謝謝!