First cut at supporting wadls in random dirs, wadls with same name etc.

This commit is contained in:
dcramer
2011-09-14 09:44:02 -05:00
parent 0820ec28f2
commit b91d51171e
3 changed files with 93 additions and 22 deletions

View File

@@ -270,6 +270,9 @@ public abstract class PDFMojo extends AbstractFoMojo {
File imageDirectory = getImageDirectory();
File calloutDirectory = new File (imageDirectory, "callouts");
transformer.setParameter("docbook.infile",sourceDocBook.getAbsolutePath());
transformer.setParameter("source.directory",sourceDirectory);
transformer.setParameter ("admon.graphics.path", imageDirectory.getAbsolutePath()+File.separator);
transformer.setParameter ("callout.graphics.path", calloutDirectory.getAbsolutePath()+File.separator);

View File

@@ -24,6 +24,9 @@ import com.agilejava.docbkx.maven.FileUtils;
public abstract class WebHelpMojo extends AbstractWebhelpMojo {
private File sourceDirectory;
private File sourceDocBook;
/**
* @parameter expression="${project.build.directory}"
*/
@@ -149,6 +152,11 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
transformer.setParameter("trim.wadl.uri.count",trimWadlUriCount);
}
sourceDocBook = new File(sourceFilename);
sourceDirectory = sourceDocBook.getParentFile();
transformer.setParameter("docbook.infile",sourceDocBook.getAbsolutePath());
transformer.setParameter("source.directory",sourceDirectory);
}
protected TransformerBuilder createTransformerBuilder(URIResolver resolver) {

View File

@@ -8,6 +8,20 @@
<!-- <xsl:output indent="yes"/> -->
<xsl:param name="project.build.directory">../../target</xsl:param>
<xsl:param name="docbook.infile"/>
<xsl:param name="source.directory"/>
<xsl:param name="docbook.partial.path">
<xsl:call-template name="getUrl">
<xsl:with-param name="path" select="substring-after($docbook.infile,$source.directory)"/>
</xsl:call-template>
</xsl:param>
<xsl:param name="docbook.partial.path.adjusted">
<xsl:choose>
<xsl:when test="$docbook.partial.path=''">/</xsl:when>
<xsl:otherwise><xsl:value-of select="$docbook.partial.path"/></xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="trim.wadl.uri.count">0</xsl:param>
<xsl:variable name="root" select="/"/>
@@ -66,12 +80,12 @@
</xsl:template>
<xsl:template match="wadl:resources[wadl:resource[not(./wadl:method)]]" mode="preprocess">
<section xml:id="{generate-id()}">
<title>FOOBAR</title>
<xsl:call-template name="wadl-resources"/>
</section>
</xsl:template>
<!-- <xsl:template match="wadl:resources[wadl:resource[not(./wadl:method)]]" mode="preprocess"> -->
<!-- <section xml:id="{generate-id()}"> -->
<!-- <title>FOOBAR</title> -->
<!-- <xsl:call-template name="wadl-resources"/> -->
<!-- </section> -->
<!-- </xsl:template> -->
<xsl:template match="wadl:resources" name="wadl-resources" mode="preprocess">
<!-- Make a summary table then apply templates to wadl:resource/wadl:method (from wadl) -->
@@ -100,12 +114,19 @@
<xsl:with-param name="path" select="@href"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="href" select="wadl:method/@href"/>
<xsl:choose>
<xsl:when test="@href">
<xsl:apply-templates
select="document($wadl.path,$root)//wadl:resource[@id = substring-after(current()/@href,'#')]/wadl:method[@rax:id = current()/wadl:method/@href]"
mode="method-rows"/>
<xsl:apply-templates mode="method-rows">
<xsl:with-param name="wadl.path" select="$wadl.path"/>
<xsl:with-param name="resourceId" select="substring-after(current()/@href,'#')"/>
</xsl:apply-templates>
<!-- <xsl:apply-templates -->
<!-- select="document(concat('file:///', $wadl.path))//wadl:resource[@id = substring-after(current()/@href,'#')]/wadl:method" -->
<!-- mode="method-rows"/> --> <!--[@rax:id = $href]-->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="wadl:method" mode="method-rows"/>
@@ -113,6 +134,31 @@
</xsl:choose>
</xsl:template>
<xsl:template match="wadl:method[@href]" mode="method-rows">
<xsl:param name="wadl.path"/>
<xsl:param name="resourceId"/>
<xsl:apply-templates
select="document(concat('file:///', $wadl.path))//wadl:resource[@id = $resourceId]/wadl:method[@rax:id = current()/@href]"
mode="method-rows"/>
<xsl:message>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<xsl:value-of
select="$wadl.path"
/>
.="<xsl:copy-of select="."/>"
-----------------------------
<xsl:apply-templates
select="document(concat('file:///', $wadl.path))//wadl:resource[@id = $resourceId]/wadl:method[@rax:id = current()/@href]"
mode="method-rows"/>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
</xsl:message>
</xsl:template>
<xsl:template match="wadl:resource" mode="preprocess">
<xsl:variable name="wadl.path">
<xsl:call-template name="wadlPath">
@@ -123,7 +169,7 @@
<xsl:choose>
<xsl:when test="@href">
<xsl:apply-templates
select="document($wadl.path,$root)//wadl:resource[@id = substring-after(current()/@href,'#')]/wadl:method[@rax:id = current()/wadl:method/@href]"
select="document(concat('file:///', $wadl.path))//wadl:resource[@id = substring-after(current()/@href,'#')]/wadl:method[@rax:id = current()/wadl:method/@href]"
mode="preprocess">
<xsl:with-param name="sectionId" select="ancestor::d:section/@xml:id"/>
</xsl:apply-templates>
@@ -431,19 +477,19 @@
<xsl:with-param name="path" select="substring-before($path,'#')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path,'\')">
<xsl:call-template name="wadlPath">
<xsl:with-param name="path" select="substring-after($path,'\')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path,'/')">
<xsl:call-template name="wadlPath">
<xsl:with-param name="path" select="substring-after($path,'/')"/>
</xsl:call-template>
</xsl:when>
<!-- <xsl:when test="contains($path,'\')"> -->
<!-- <xsl:call-template name="wadlPath"> -->
<!-- <xsl:with-param name="path" select="substring-after($path,'\')"/> -->
<!-- </xsl:call-template> -->
<!-- </xsl:when> -->
<!-- <xsl:when test="contains($path,'/')"> -->
<!-- <xsl:call-template name="wadlPath"> -->
<!-- <xsl:with-param name="path" select="substring-after($path,'/')"/> -->
<!-- </xsl:call-template> -->
<!-- </xsl:when> -->
<xsl:otherwise>
<xsl:value-of
select="concat($project.build.directory, '/generated-resources/xml/xslt/',$path)"
select="concat($project.build.directory, '/generated-resources/xml/xslt',$docbook.partial.path.adjusted,$path)"
/>
</xsl:otherwise>
</xsl:choose>
@@ -472,4 +518,18 @@
</xsl:choose>
</xsl:template>
<xsl:template name="getUrl">
<xsl:param name="path" />
<xsl:choose>
<xsl:when test="contains($path,'/')">
<xsl:value-of select="substring-before($path,'/')" />
<xsl:text>/</xsl:text>
<xsl:call-template name="getUrl">
<xsl:with-param name="path" select="substring-after($path,'/')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise />
</xsl:choose>
</xsl:template>
</xsl:stylesheet>