maven-plugins/faq/plugin.jelly

89 lines
2.2 KiB
XML

<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:x="jelly:xml"
xmlns:html="jelly:html"
xmlns:maven="jelly:maven"
xmlns:log="jelly:log"
xmlns:util="jelly:util"
xmlns:doc="doc"
xmlns:m="maven">
<goal name="faq"
description="Generates an FAQ xdoc file from an FAQ XML document">
<j:set var="destfile" value="${maven.faq.dest.file}"/>
<j:if test="${empty(destfile)}">
<j:set var="destfile" value="${maven.build.dir}/generated-xdocs/faq.xml"/>
</j:if>
<mkdir dir="${maven.build.dir}/generated-xdocs"/>
<j:set var="srcfile" value="${maven.faq.src.file}"/>
<j:if test="${empty(srcfile)}">
<j:set var="srcfile" value="xdocs/faq.fml"/>
</j:if>
<util:file var="srcfileFile" name="${srcfile}"/>
<j:set var="srcfile" value="${srcfileFile.getCanonicalPath()}"/>
<util:file var="destfileFile" name="${destfile}"/>
<j:set var="destfile" value="${destfileFile.getCanonicalPath()}"/>
<j:set var="outputencoding" value="${maven.docs.outputencoding}"/>
<x:parse var="doc" xml="${srcfileFile}"/>
<x:set var="root" select="$doc/*"/>
<j:file name="${destfile}" encoding="${outputencoding}" outputMode="xml">
<document>
<properties>
<title><x:expr select="$root/title"/></title>
</properties>
<body>
<section name="Frequently Asked Questions">
<x:forEach select="$root/part">
<p>
<strong><x:expr select="title"/></strong>
</p>
<ol>
<x:forEach select="faq">
<li>
<x:element name="a">
<x:attribute name="href">#<x:expr select="@id"/></x:attribute>
<x:copyOf select="question/node()"/>
</x:element>
</li>
</x:forEach>
</ol>
</x:forEach>
</section>
<x:forEach select="$root/part">
<x:element name="section">
<x:attribute name="name"><x:expr select="title"/></x:attribute>
<x:forEach select="faq">
<dl>
<dt>
<x:element name="a">
<x:attribute name="name"><x:expr select="@id"/></x:attribute>
<x:copyOf select="question/node()"/>
</x:element>
</dt>
<dd>
<x:copyOf select="answer/node()"/>
</dd>
</dl>
</x:forEach>
</x:element>
</x:forEach>
</body>
</document>
</j:file>
</goal>
</project>