2009-07-24 65 views
0

我有一个关于南特查询生成脚本,我是相当新的nant创建,如果我想在一个XML文件中运行某些条件的作风基地说nant创建脚本如果条件,

计数($ {skinFolder} /screens.temp.xml//ActionCollection/Item)> 0

有没有办法实现这个?

在此先感谢, Sidhartha的

回答

0

添加project节点的恶性脚本在以下:

<script language="c#" prefix="custom"> 
    <code> 
     <![CDATA[ 
     [Function("evaluate-xpath")] 
     public static string EvaluateXPath(string xpath, string info) 
     { 
     System.Xml.XPath.XPathDocument xml = new System.Xml.XPath.XPathDocument(info); 
     return xml.CreateNavigator().Evaluate(xpath).ToString(); 
     } 
     ]]> 
    </code> 
</script> 

然后你可以用下面的表达来实现你想要的:

if="${int::parse(custom::evaluate-xpath('count(//ActionCollection/Item)', path::combine(skinFolder 'screens.temp.xml'))) &gt; 0}" 

请注意,如果您的XML文件具有给定名称空间的节点,那么这将不起作用。