1

I have an XQuery script that I want to run against all of the files in a gradle copy task as a filter. I am looking at both XQJ and XProc. Since there is a supported implementation of Calabash in ml-gradle, I decided to go that route.

Is there an example of using XProc as a filter in a gradle copy task?

Here is something that I used for a gradle task for generating xqDoc using the xqDoc java library. I would like some help to do something similar, but using XProc as the filter.

class XQDocFilter extends BaseFilterReader {
  XQDocFilter(Reader input) {
    super(new StringReader(new org.xqdoc.MarkLogicProcessor().process(input.text)))
  }
}

task generateXQDocs(type: Copy) {
  into 'xqDoc'
  from 'src/main/ml-modules'
  include '**/*.xq*'
  rename { it - '.xq*' + '.xml' }
  includeEmptyDirs = false
  eachFile { println it }
  filter XQDocFilter
}
Loren Cahlander
  • 1,257
  • 1
  • 10
  • 24
  • You mean that there is a supported implementation in *gradle*, not *ml-gradle*, correct? I don't see any reference to Calabash in ml-gradle. Assuming you were referring to https://github.com/ndw/xmlcalabash1-gradle ? – Mads Hansen Mar 21 '20 at 15:34
  • I am referring to Norm's Gradle implementation of XML Calabash. – Loren Cahlander Mar 21 '20 at 22:20

1 Answers1

1

I added an XMLCalabashFilter class to xmlcalabash1-gradle starting in version 1.5.0.

Norm
  • 866
  • 1
  • 7
  • 16
  • Hello Norm, Thank you. I am looking forward to your feedback. My alternative would to use XQJ and implement a filter. I do not see a lot of support for XQL. – Loren Cahlander Mar 23 '20 at 17:52
  • I find the gradle docs so hard to use. As near as I can tell, a filter applies to each line in the file. If that's the case, I'm not sure XProc 1.0 is going to be a good fit. I plan to make XProc 3.0 versions as well, and handling text in 3.0 is much easier. – Norm Mar 24 '20 at 09:11
  • The filter applies to each file. If you look at the gradle task that I include above, It runs the filter against each XQuery source file identified and returns an xqDoc XML document. – Loren Cahlander Mar 24 '20 at 13:28
  • So the Gradle documentation has failed me once again. Sigh. I'll look again. If you know where the BaseFileReader API is documented, feel free to point me in the right direction. – Norm Mar 25 '20 at 15:04
  • Check out `import org.apache.tools.ant.filters.BaseFilterReader`. Check out the build.gradle at https://github.com/easymetahub/emh-marklogic-glossary – Loren Cahlander Mar 25 '20 at 15:59
  • Also look at https://docs.gradle.org/current/userguide/working_with_files.html#sec:filtering_files – Loren Cahlander Mar 25 '20 at 16:05
  • Ok. It seems to be possible. I'll see what I can do. – Norm Mar 27 '20 at 10:25
  • Now blocked by https://stackoverflow.com/questions/60898982/how-does-the-gradle-runtime-configuration-for-a-task-differ-from-the-configurati – Norm Mar 28 '20 at 08:39
  • @LorenCahlander I just published version 1.5.0 of the xmlcalabash1-gradle extension which includes a filter. You'll find an example of how to use it in the repo in src/test/resources. Let me know if it works for you. – Norm Mar 29 '20 at 19:58