<command name="paraToFormalpara"> <macro> <sequence> <command name="selectNode" parameter="ancestorOrSelf[implicitElement] para" /> <command name="toFormalpara" /> <command name="paste" parameter="to %_" /> </sequence> </macro> </command> <command name="toFormalpara"> <process showProgress="false"> <copyDocument selection="true" to="in.xml" /> <transform stylesheet="toFormalpara.xsl" cacheStylesheet="true" file="in.xml" to="out.xml" /> <read file="out.xml" encoding="UTF-8" /> </process> </command>
In the above example, toFormalpara.xsl
is simply:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" /> <xsl:template match="/para"> <formalpara> <xsl:for-each select="@*"> <xsl:copy/> </xsl:for-each> <title></title> <para> <xsl:apply-templates select="node()"/> </para> </formalpara> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
The above macro may be implemented much more efficiently by replacing the invocation of process command |