metatools/sysdeftools/lib/usage.xsl
changeset 624 f70b728ea30c
equal deleted inserted replaced
621:96fee2635b19 624:f70b728ea30c
       
     1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       
     2 <xsl:output method="text"/>
       
     3 <xsl:param name="usage"/>
       
     4 
       
     5 <xsl:template match="node()|@*"><xsl:copy-of select="."/></xsl:template>
       
     6 <xsl:template match="/*">
       
     7 	<xsl:apply-templates select="." mode="desc"/>
       
     8 
       
     9 	<xsl:variable name="in">
       
    10 		<xsl:call-template name="input"/>
       
    11 	</xsl:variable>
       
    12 	<xsl:variable name="out">
       
    13 		<xsl:call-template name="output"/>
       
    14 	</xsl:variable>
       
    15 
       
    16 	<xsl:if test="$usage != ''">
       
    17 		<xsl:text>&#xa;usage: </xsl:text><xsl:value-of select="$usage"/>
       
    18 	</xsl:if>
       
    19 	<xsl:if test="$usage != '' and contains($out,'&gt;')"> [<xsl:value-of select="substring-before($out,'&gt;')"/>&gt;]  [params ...] <xsl:value-of select="substring-before($in,'&gt;')"/>&gt;</xsl:if>
       
    20 		<xsl:choose>
       
    21 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-c' ">
       
    22 The input file must be last. Other arguments can be in any order. 
       
    23 Parameters are case-sensitive. Text parameter values must be in single quotes.
       
    24 </xsl:when>
       
    25 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-j' ">
       
    26 Arguments can be in any order. 
       
    27 Parameters are case-sensitive.
       
    28 </xsl:when>
       
    29 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xmlsoft.org/XSLT/' ">
       
    30 The input file must be last. Other arguments can be in any order. 
       
    31 Parameters are case-sensitive.
       
    32 </xsl:when>
       
    33 		</xsl:choose>
       
    34 
       
    35 	<xsl:text>&#xa;&#9;</xsl:text>
       
    36 		<xsl:call-template name="input"/>
       
    37 	<xsl:text>&#xa;&#9;</xsl:text>
       
    38 		<xsl:call-template name="output"/>
       
    39 	<xsl:apply-templates select="." mode="params"/>
       
    40 </xsl:template>
       
    41 
       
    42 
       
    43 <xsl:template match="/*" mode="desc">
       
    44 	<xsl:value-of select="substring-after(comment()[starts-with(.,'Description:')],':')"/>
       
    45 	<xsl:apply-templates select="document(xsl:import/@href | xsl:include/@href,.)/*" mode="desc"/>
       
    46 </xsl:template>
       
    47 
       
    48 <xsl:template match="/*" mode="params">
       
    49 	<xsl:for-each select="xsl:param">
       
    50 		<xsl:text>&#xa;&#9;</xsl:text>
       
    51 		<xsl:choose>
       
    52 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-c' ">
       
    53 				<xsl:text>-p </xsl:text>			
       
    54 			</xsl:when>
       
    55 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-j' ">
       
    56 				<xsl:text>-param </xsl:text>			
       
    57 			</xsl:when>
       
    58 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xmlsoft.org/XSLT/' ">
       
    59 				<xsl:text>--string-param </xsl:text>			
       
    60 			</xsl:when>
       
    61 		</xsl:choose>
       
    62 		<xsl:value-of select="concat(@name,' ')"/>
       
    63 		<xsl:for-each select="following-sibling::node()[self::* or self::comment()][1]">
       
    64 			<xsl:if test="self::comment()">
       
    65 			<xsl:value-of select="."/>
       
    66 			</xsl:if>
       
    67 		</xsl:for-each>
       
    68 		<xsl:text>&#xa;</xsl:text>
       
    69 		<xsl:if test="not(*) and normalize-space(.)!='' ">&#9;&#9;Defaults to <xsl:choose>
       
    70 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-c' ">'<xsl:value-of select="."/>'</xsl:when>
       
    71 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-j' ">"<xsl:value-of select="."/>"</xsl:when>
       
    72 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xmlsoft.org/XSLT/' ">"<xsl:value-of select="."/>"</xsl:when>
       
    73 		</xsl:choose></xsl:if>
       
    74 	</xsl:for-each>
       
    75 	<xsl:apply-templates select="document(xsl:import/@href | xsl:include/@href,.)/*" mode="params"/>
       
    76 </xsl:template>
       
    77 
       
    78 
       
    79 <xsl:template name="string"><xsl:param name="look">Description</xsl:param>
       
    80 	<xsl:variable name="s">
       
    81 		<xsl:value-of select="substring-after(comment()[starts-with(.,concat($look,':'))],':')"/>
       
    82 	</xsl:variable>
       
    83 	<xsl:choose>
       
    84 		<xsl:when test="$s != ''"><xsl:value-of select="$s"/></xsl:when>
       
    85 		<xsl:otherwise>
       
    86 			<xsl:for-each select="document(xsl:import/@href | xsl:include/@href,.)/*">
       
    87 				<xsl:call-template name="string">
       
    88 					<xsl:with-param name="look" select="$look"/>
       
    89 				</xsl:call-template>
       
    90 			</xsl:for-each>
       
    91 		</xsl:otherwise>
       
    92 	</xsl:choose>
       
    93 </xsl:template>
       
    94 
       
    95 <xsl:template name="input">
       
    96 	<xsl:variable name="p">
       
    97 		<xsl:call-template name="string">
       
    98 			<xsl:with-param name="look" select="'Input'"/>
       
    99 		</xsl:call-template>
       
   100 	</xsl:variable>
       
   101 		<xsl:choose>
       
   102 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-c' "/>
       
   103 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xmlsoft.org/XSLT/' "/>
       
   104 			<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-j' ">
       
   105 				<xsl:text>-in </xsl:text>			
       
   106 			</xsl:when>
       
   107 		</xsl:choose>
       
   108 	<xsl:if test="$p =''  ">&lt;xml&gt; - (required) The input XML file</xsl:if>
       
   109 	<xsl:if test="$p !=''  "><xsl:value-of select="$p"/></xsl:if>
       
   110 	<xsl:text>&#xa;</xsl:text>
       
   111 </xsl:template>
       
   112 
       
   113 <xsl:template name="output">
       
   114 	<xsl:variable name="p">
       
   115 		<xsl:call-template name="string">
       
   116 			<xsl:with-param name="look" select="'Output'"/>
       
   117 		</xsl:call-template>
       
   118 	</xsl:variable>
       
   119 	<xsl:choose>
       
   120 		<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-c' ">
       
   121 			<xsl:text>-o </xsl:text>			
       
   122 		</xsl:when>
       
   123 		<xsl:when test="system-property('xsl:vendor-url') = 'http://xml.apache.org/xalan-j' ">
       
   124 			<xsl:text>-out </xsl:text>			
       
   125 		</xsl:when>
       
   126 		<xsl:when test="system-property('xsl:vendor-url') = 'http://xmlsoft.org/XSLT/' ">
       
   127 			<xsl:text>-o </xsl:text>			
       
   128 		</xsl:when>
       
   129 	</xsl:choose>
       
   130 	<xsl:if test="$p =''  ">&lt;file&gt; - (optional) The <xsl:value-of select="xsl:output/@method"/> file to save the output as. If not present it will write to stdout.</xsl:if>
       
   131 	<xsl:if test="$p !=''  "><xsl:value-of select="$p"/></xsl:if>
       
   132 	<xsl:text>&#xa;</xsl:text>
       
   133 </xsl:template>
       
   134 
       
   135 </xsl:stylesheet>