Tongue, Steve wrote:
> Hoping someone here may be able to help me.
> 
> I'm trying to see if a file exists in my subversion repository before trying
> to create a new file and see that there is a java command but I can't seem
> to get it to work. I'm not a java user so would be grateful for any help.
> 
> The command I've tried is
> 
> <command name="urltest">
>   <macro>
>       <sequence>
> 
>        <choice>
>                <sequence>
>                     <test xmlns:url="java:java.net.URL
> "expression="url:exists('http://www.xmlmind.com/xmleditor/index.html') =
> true" />
>                     <command name="alert" parameter="Found"/>
>                </sequence>
>                <sequence>
>                  <test xmlns:sys="java:java.lang.System"
> expression="sys:exists('http://www.xmlmind.com/xmleditor/index.html') =
> false" /> 
>                     <command name="alert" parameter="Doesn't exists"/>
>                </sequence>
> 
> 
>         </choice>
>       </sequence>
>     </macro>
>  </command>

The Java runtime has no java.net.URL.exists() method. You need to write
such method yourself or use the one contained in xxe.jar.

I've tested what follows and it seems to work fine:

---
<command name="urltest">
  <macro>
     <choice>
       <sequence>
         <test xmlns:url="java:java.net.URL"
               xmlns:uu="java:com.xmlmind.xmledit.util.URLUtil"

expression="uu:exists(url:new('http://www.xmlmind.com/xmleditor/index.html'))"
/>
         <command name="alert" parameter="Found"/>
       </sequence>
       <command name="alert" parameter="Doesn't exist"/>
     </choice>
  </macro>
 </command>

<binding>
  <keyPressed code="F2" />
  <command name="urltest" />
</binding>
---

See
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmledit/util/URLUtil.html#exists(java.net.URL)

Reply via email to