xml version="1.0" encoding="utf-8"
<xslstylesheet expand-text='yes' version="3.0"
xmlnsxlink="http://www.w3.org/1999/xlink"
xmlnsaw="http://www.abisource.com/awml.dtd"
xmlns="http://www.abisource.com/awml.dtd"
xmlnsxsl="http://www.w3.org/1999/XSL/Transform"
xmlnsups="http://www.uplawski.eu"
xmlnsxs="http://www.w3.org/2001/XMLSchema">
<xsloutput method="text" encoding="UTF-8"/>
<xslstrip-space elements="*"/>
<xslfunction name="ups:increment" as="xs:integer">
<xslparam name="in" as="xs:integer"/>
<xslsequence select="$in + 1"/>
</xslfunction>
<xslvariable name="tab" select="'	'"/>
<xslvariable name="lowercase"
select="'abcdefghijklmnopqrstuvwxyz'" />
<xslvariable name="uppercase"
select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsltemplate match="/*">
<xslmessage>root found </xslmessage>
<xslapply-templates/>
</xsltemplate>
<xsltemplate match="aw:metadata"/>
<xsltemplate match="aw:section">
<xslapply-templates/>
</xsltemplate>
<xsltemplate match="aw:p[@style='Document Title']">
<xslmessage>Found document title</xslmessage>
<xsliterate select="1 to string-length()">
<xsltext>=</xsltext>
</xsliterate>
<xsltext> </xsltext>
<xslvalue-of select="."/>
<xsltext> </xsltext>
<xsliterate select="1 to string-length()">
<xsltext>=</xsltext>
</xsliterate>
<xsltext> </xsltext>
</xsltemplate>
<xsltemplate match="aw:p[@style='Sub Doc Title']">
<xsliterate select="1 to string-length()">
<xsltext>-</xsltext>
</xsliterate>
<xsltext> </xsltext>
<xslvalue-of select="."/>
<xsltext> </xsltext>
<xsliterate select="1 to string-length()">
<xsltext>-</xsltext>
</xsliterate>
<xsltext> </xsltext>
</xsltemplate>
<xsltemplate match="aw:p[starts-with(@style, 'TOC')]">
<xsltext></xsltext>
</xsltemplate>
<xsltemplate match="aw:p[@style='Section Header']">
<xslmessage>Section: <xslvalue-of select="."/></xslmessage>
<xsltext>.. _</xsltext>
<xslvalue-of select="."/>
<xsltext>: </xsltext>
<xslvalue-of select="."/>
<xsltext> </xsltext>
<xsliterate select="1 to string-length()">
<xsltext>=</xsltext>
</xsliterate>
<xsltext> </xsltext>
</xsltemplate>
<xsltemplate match="aw:p[@style='Header 1' and string-length() > 0]">
<xslmessage><xsltext> </xsltext>Header: <xslvalue-of select="."/></xslmessage>
<xsltext>.. _</xsltext>
<xslvalue-of select="."/>
<xsltext>: </xsltext>
<xslfor-each select="aw:bookmark[@type='end']">
<xslmessage select="concat('	bookmark? ', @name)"/>
<xslif test="string(@name) != string()">
<xsltext>.. _</xsltext>
<xslvalue-of select="@name"/>
<xsltext>:</xsltext>
<xsltext> </xsltext>
</xslif>
</xslfor-each>
<xslapply-templates/>
<xsltext> </xsltext>
<xsliterate select="1 to string-length()">
<xsltext>-</xsltext>
</xsliterate>
<xsltext> </xsltext>
</xsltemplate>
<xsltemplate match="aw:p[@style='Bullet List 1' and string-length() > 0]">
<xslmessage><xsltext> </xsltext>Bullet List</xslmessage>
<xsltext>* </xsltext>
<xslapply-templates/>
<xsltext> </xsltext>
</xsltemplate>
<xsltemplate match="aw:p[@style='Numbered List 1'][not(preceding-sibling::aw:p[@style='Numbered List 1'][@listid = current()/@listid])]">
<xslmessage> Numbered List {@listid}</xslmessage>
<xslif test="self::aw:p">
<xslvariable name="listid" select="@listid"/>
<xslmessage> Current listid: {$listid}</xslmessage>
<xslmessage> Following siblings with same listid: {count(following-sibling::aw:p[@listid = $listid])}</xslmessage>
<xslmessage> Total in sequence: {count((., following-sibling::aw:p[@listid = $listid]))} </xslmessage>
<xslfor-each select="(., following-sibling::aw:p[@listid = $listid])">
<xslmessage> Processing item {position()} {@xid}</xslmessage>
<xslvariable name="content" select="normalize-space(string-join(aw:c[@type='list_label'][normalize-space(.) != '']/text(), ' '))"/>
<xslmessage> content: {substring($content, 1, 20)} (...)</xslmessage>
<xslif test="$content != ''">
<xslvalue-of select="position()"/>
<xsltext>. </xsltext>
<xslvalue-of select="$content"/>
<xsltext> </xsltext>
</xslif>
</xslfor-each>
</xslif>
<xslmessage> - End Numbered List -</xslmessage>
</xsltemplate>
<xsltemplate match="aw:p[@style='Numbered List 1'][preceding-sibling::aw:p[@style='Numbered List 1'][@listid = current()/@listid]]"/>
<xsltemplate match="aw:p[@style='Definition List' and child::aw:c[@style='Definition Item']]">
<xslapply-templates/>
</xsltemplate>
<xsltemplate match="aw:p[@style='Definition List' and string-length > 0]">
<xsltext> </xsltext>
<xslapply-templates/>
</xsltemplate>
<xsltemplate match="aw:c[@style='Definition Item']">
<xslif test="normalize-space() != ''">
<xslmessage select="concat('	', 'definition item ', string())"/>
<xslvariable name="item"
select="normalize-space(string-join(text(), ''))"/>
<xsltext> </xsltext>
<xsltext> .. _</xsltext>
<xslvalue-of select="$item"/>
<xsltext>:</xsltext>
<xsltext> </xsltext>
<xslfor-each select="following-sibling::aw:bookmark[@type='end'] | preceding-sibling::aw:bookmark[@type='start']">
<xslmessage select="concat('		bookmark? ', @name)"/>
<xslif test="string(@name) != $item">
<xsltext>.. _</xsltext>
<xslvalue-of select="@name"/>
<xsltext>:</xsltext>
<xsltext> </xsltext>
</xslif>
</xslfor-each>
<xsltext> **</xsltext>
<xslvalue-of select="$item"/>
<xsltext>** </xsltext>
</xslif>
</xsltemplate>
<xsltemplate match="aw:c[@style='Definition Text']">
<xslvariable name="content" select="normalize-space(translate(., '	', ''))"/>
<xslchoose>
<xslwhen test="substring($content, 1, 7) = ('DEFAULT', 'CONTENT', 'EXAMPLE')">
<xsltext> </xsltext>
</xslwhen>
<xslotherwise>
<xsltext>	</xsltext>
</xslotherwise>
</xslchoose>
<xslapply-templates/>
<xslif test="../following-sibling::aw:p[@style='Multiline Example' and position() = 1]">
<xsltext>:</xsltext>
</xslif>
</xsltemplate>
<xsltemplate match="aw:p[@style='Multiline Example']">
<xslmessage>		multiline example</xslmessage>
<xsltext> </xsltext>
<xslfor-each-group select="node()" group-starting-with="aw:br">
<xslvariable name="part" select="current-group()[not(self::aw:br)]"/>
<xslmessage>
		substring: <xslvalue-of select="normalize-space(string-join($part, ''))"/>
</xslmessage>
<xsltext> 	 </xsltext>
<xslvalue-of select="normalize-space(string-join($part, ''))"/>
</xslfor-each-group>
</xsltemplate>
<xsltemplate match="aw:p[@style='Normal']">
<xslapply-templates/>
<xsltext> </xsltext>
</xsltemplate>
<xsltemplate match="aw:br">
<xsltext> </xsltext>
</xsltemplate>
<xsltemplate match="aw:pbr">
<xsltext></xsltext>
</xsltemplate>
<xsltemplate match="aw:c[@style='Command']">
<xsltext>	</xsltext>
<xslapply-templates/>
</xsltemplate>
<xsltemplate match="aw:c[@props='font-weight:bold' and string-length() > 0]">
<xsltext>**</xsltext>
<xslapply-templates/>
<xsltext>**</xsltext>
</xsltemplate>
<xsltemplate match="aw:c[@props='font-style:italic' and string-length() > 0]">
<xsltext>*</xsltext>
<xslapply-templates/>
<xsltext>*</xsltext>
</xsltemplate>
<xsltemplate match="aw:a[@xlink:href]">
<xslchoose>
<xslwhen test="contains(@xlink:href, '@')">
<xslchoose>
<xslwhen test="starts-with(@xlink:href, 'mailto:')">
<xslvalue-of select="substring(@xlink:href, 8)"/>
</xslwhen>
<xslotherwise>
<xslvalue-of select="@xlink:href"/>
</xslotherwise>
</xslchoose>
</xslwhen>
<xslotherwise>
<xsltext>`</xsltext>
<xslvalue-of select="."/>
<xslif test = "starts-with(@xlink:href, 'http')">
<xsltext> <</xsltext>
<xslvalue-of select="@xlink:href"/>
<xsltext>></xsltext>
</xslif>
<xsltext>`_</xsltext>
</xslotherwise>
</xslchoose>
</xsltemplate>
<xsltemplate match="text()[normalize-space() = '']"/>
</xslstylesheet>