Bir makroyu Ant'deki hata ayıklamaya çalışıyorum. Bir öğe olarak gönderilen bir parametrenin içeriğini görüntülemek için bir yol bulamıyorum.Ant makrodef: Bir eleman parametresinin içeriğini almanın bir yolu var mı?
$ ant works
...
works:
[echo] Sure, the attribute is easy to debug: contents of attribute
[echo] The element works only in restricted cases: contents of elem
...
$ ant does.not.work
...
does.not.work:
[echo] Sure, the attribute is easy to debug: contents of attribute
BUILD FAILED
.../build.xml:21: The following error occurred while executing this line:
.../build.xml:7: echo doesn't support the nested "sub.elem" element.
...
Yani ben bir şekilde (bazı genişletilmiş macrodef uygulaması buna sahip olabilir) bir mülkte <elem />
içeriğini almak için bir yol ya da ihtiyaç tahmin yoksa bir ihtiyaç:
<project name='debug.macrodef'>
<macrodef name='def.to.debug'>
<attribute name='attr' />
<element name='elem' />
<sequential>
<echo>Sure, the attribute is easy to debug: @{attr}</echo>
<echo>The element works only in restricted cases: <elem /> </echo>
<!-- This works only if <elem /> doesn't contain anything but a
textnode, if there were any elements in there echo would
complain it doesn't understand them. -->
</sequential>
</macrodef>
<target name='works'>
<def.to.debug attr='contents of attribute'>
<elem>contents of elem</elem>
</def.to.debug>
</target>
<target name='does.not.work'>
<def.to.debug attr='contents of attribute'>
<elem><sub.elem>contents of sub.elem</sub.elem></elem>
</def.to.debug>
</target>
</project>
Örnek çalıştırmak İçine koyduğunuz XML ağacını yazdırabilen <element-echo><elem /></element-echo>
türünde. Bunlardan herhangi birinin uygulanmasını bilen var mı? Verileri elde etmenin üçüncü, beklenmedik bir yolu da elbette hoş karşılanır.
verir Öğe tam olarak aradığım şeydi, teşekkür ederim! – clacke
Bir bonus olarak, ' ', XML başlıklarını eklemek için ekstra işlem yapılmadan bile çalışır (karınca 1.8.4'te test edilmiştir). –