ANT:用文件名本身替换文件中的字符串
我遇到的情况是,我需要扫描大量 .xsd 文件,并根据正在检查的当前架构的文件名将一个字符串实例替换为另一个字符串。
例如: 我希望将 file1.xsd 中的字符串:“DataSet”替换为字符串“file1DataSet” 我希望将 file2.xsd 中的字符串:“DataSet”替换为字符串“file2DataSet” 依此类推,直到所有模式都被修改。
我想知道是否有办法在不使用 ant-contrib for 循环的情况下执行此操作。
I have a situation where I need to scan through a large number of .xsd files, and replace an instance of a string with another string based on the file name of the current schema being examined.
For example:
I wish to replace the string: 'DataSet' in file1.xsd with the string 'file1DataSet'
I wish to replace the string: 'DataSet' in file2.xsd with the string 'file2DataSet'
and so on until all schemas have been modified.
I would like to know if there is anyway to do this without using the ant-contrib for loops.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您大致了解如何执行,则可以尝试 任务你有很多模式。 可能能够在不循环的情况下完成此操作。
Ant 并不是一种真正可以循环的编程语言。如果您可以一次完成所有事情,那就太好了,但是一旦您开始真正操作文件,Ant 就会遇到限制。
You could try the <replace> task if you have a generally good idea how many schemas you have. The <replaceRegex> might be able to do it without looping.
Ant isn't really a programming language where you can loop. If you can do everything in one pass, that's great, but once you start really manipulating files, Ant runs into limitations.