An advanced example

You may probably be willing to have a simple dependency declaration directly on the Xslts and Xprocs. We didn’t choose that approach because that means that we would have to declare every small dependency between each file. That would also exclude from the artifacts graphic or web resources, specially the binary ones.

If you have a very specific context where you work mainly with Xslts and Xprocs we could adjust the solution to manage dependencies directly.

In the advanced-configuration example we have added two projects, one that publishes an xslt and other that depends on it. We have added a namespace alias (“arimp”) to identify the dependency declarations in both xslts. The “build-tasks-report.xsl” has an element that indicates that the xslt should be published.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    version="3.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:arimp="http://www.vionta.net/schemas/arousa-import/
                                      v1.0/arousa-import.xsd"
    exclude-result-prefixes="arimp"
>
 <arimp:publication artifact-name="build-tasks-report"   />
  <xsl:template match="/">
...

On the target project the actual report file has a similar declaration indicating the dependency.

<xsl:stylesheet
    version="3.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:arimp="http://www.vionta.net/schemas/arousa-import/
                                      v1.0/arousa-import.xsd"
    exclude-result-prefixes="arimp"
    >
  <arimp:dependency
      component="lineal-fods" org="net.vionta.
                                  transformation.spreadsheet"
      rev="1.0" artifact="build-tasks-report" />
  <xsl:template match="/">
...

Both projects are Xproc capable and include an xproc on the conf folder called generate-ivy-dependency-file.xpl.

<p:declare-step 
    xmlns:p="http://www.w3.org/ns/xproc"  
    version="3.0">

 <p:input port="source" primary="true" > <p:inline> <documento/> 
                                          </p:inline> </p:input>
 <p:output port="result" primary="true" pipe="result@final-list" />
 <p:load name="load-ivy-file"  >
   <p:with-option name="href" select="'./arousa-ivy.xml'" />
 </p:load>
 <p:directory-list name="xslt-directory-list"
       include-filter=".xsl"  exclude-filter=".xsl~" >
   <p:with-option name="path" select="'../src/xsl/'" />
 </p:directory-list>

 <p:for-each name="xsl-files" >
   <p:with-input select="//*:file[@*:name]"  />
   <p:load name="load-file-content"  >
     <p:with-option name="href" 
          select="concat('../src/xsl/', .//@*:name)" />
   </p:load>
 </p:for-each>
 <p:wrap-sequence name="xslt-imports" wrapper="xsl-files" >
 </p:wrap-sequence>
 <p:insert name="merge" position="first-child" >
   <p:with-input port="insertion"  pipe="result@load-ivy-file" />
 </p:insert>
  
  <p:xslt name="final-list">  
      <p:with-input port="stylesheet" 
            href="./extract-import-elements.xsl"/>
  </p:xslt>

   <p:store name="final-serialization" >
     <p:with-option name="href" select="'./arousa-ivy.xml'" />
   </p:store>
 </p:declare-step>

As you can see, the Xproc lists the xslts from the src/xsl folder and wraps them with the current arousa-ivy file. The xslt merges the organization and configuration options from the existing ivy file with the imports extracted from the xslts.

As a result, the script populates the Ivy dependency file with the dependency relations.

<?xml version="1.0" encoding="utf-8"?>
<ivy-module version="1.1">
 <info organisation="org.markupuk.examples.arousa"
       module="sample-fods-report"/>
  <dependencies defaultconf="default">
      <dependency org="net.vionta.transformation.spreadsheet"
                  name="lineal-fods" rev="1.0">
         <artifact name="build-tasks-report"
                   type="transformation" ext="xsl"/>
      </dependency>
   </dependencies>
</ivy-module>

Both the xsl publishing and retrieval works with the same commands as the rest of examples (publish-dependency and update-dependencies).