Project

Profile

Help

Bug #4389 » skeletonCommenter.xsl

Ken Holman, 2019-11-18 02:32

 
<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type="text/xsl" href="../xslstyle/xslstyle-docbook.xsl"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.CraneSoftwrights.com/ns/xslstyle"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:c="urn:X-Crane"
exclude-result-prefixes="xs xsd c"
version="2.0">

<xs:doc info="$Id$"
filename=".xsl" vocabulary="DocBook">
<xs:title>Create a commented skeleton of a BDNDR document model</xs:title>
<para>
For illustrative purposes to help the reader understand the markup
</para>
</xs:doc>

<!--========================================================================-->
<xs:doc>
<xs:title>Invocation parameters and input file</xs:title>
<para>
Input file is a BDNDR document model expressed in genericode.
</para>
</xs:doc>

<!--<xs:param ignore-ns='yes'>
<para>
</para>
</xs:param>
<xsl:param name="" select="''" as="xsd:string"/>-->

<!--========================================================================-->
<xs:doc>
<xs:title>Basic processing</xs:title>
</xs:doc>

<xs:function>
<para>
Access a row's column's value by its name
</para>
<xs:param name="c:row">
<para>The row of the model describing the BIE</para>
</xs:param>
<xs:param name="c:colName">
<para>The column value desired from that row</para>
</xs:param>
</xs:function>
<xsl:function name="c:col" as="xsd:string?">
<xsl:param name="c:row" as="element(Row)"/>
<xsl:param name="c:colName" as="xsd:string"/>
<xsl:sequence select="$c:row/Value[@ColumnRef=$c:colName]/SimpleValue"/>
</xsl:function>

<xs:key>
<para>Track items by their Dictionary Entry Name</para>
</xs:key>
<xsl:key name="c:bieByDEN" match="Row"
use="c:col(.,'DictionaryEntryName')"/>

<xs:key>
<para>Track ABIEs by their class name</para>
</xs:key>
<xsl:key name="c:bieByClass"
match="Row[not(c:col(.,'ComponentType')='ABIE')]
[not(c:col(.,'BPCML')=('','0'))]"
use="c:col(.,'ObjectClass')"/>

<xs:key>
<para>Track ABIEs by their class name</para>
</xs:key>
<xsl:key name="c:abieByClass"
match="Row[c:col(.,'ComponentType')='ABIE']"
use="c:col(.,'ObjectClass')"/>

<xs:key>
<para>Track ABIEs by their class name</para>
</xs:key>
<xsl:key name="c:abieByModel"
match="Row[c:col(.,'ComponentType')='ABIE']"
use="c:col(.,'ModelName')"/>

<xs:template>
<para>
The identity template is used to copy all nodes not already being handled
by other template rules.
</para>
</xs:template>
<xsl:template match="/">
<!--from the Document ABIE-->
<xsl:apply-templates select="/*/SimpleCodeList/Row
[count(key('c:abieByModel',c:col(.,'ModelName')))=1]"/>
</xsl:template>

<xs:template>
<para>
Process an ASBIE by working with its ABIE
</para>
<xs:param name="c:definition">
<para>An overriding ASBIE definition compared to the ABIE definition</para>
</xs:param>
<xs:param name="c:ancestors">
<para>A sequence of ancestor rows used to prevent infinite recursion</para>
</xs:param>
<xs:param name="c:indent">
<para>The running indentation based on ancestry</para>
</xs:param>
</xs:template>
<xsl:template match="Row[c:col(.,'ComponentType')='ABIE']">
<xsl:param name="c:definition" as="xsd:string?"
select="c:col(.,'Definition')"/>
<xsl:param name="c:ancestors" as="element(Row)*"/>
<xsl:param name="c:indent" as="xsd:string" select="''"/>
<xsl:variable name="c:prefix"
select="if( exists( $c:ancestors ) ) then 'cac:' else ''"/>
<xsl:choose>
<xsl:when test="some $c:a in $c:ancestors satisfies $c:a is .">
<!--avoid infinite loops-->
<xsl:comment select="'Recursive use of ',c:col(.,'ObjectClass)')"/>
<xsl:text>&#xa;</xsl:text>
</xsl:when>
<xsl:otherwise>
<!--start tag-->
<xsl:value-of select="
concat($c:indent,'&lt;',$c:prefix,c:col(.,'ComponentName'),'>&#xa;')"/>
<!--documentation-->
<xsl:value-of select="concat(' ',$c:indent)"/>
<xsl:comment select="$c:definition"/>
<xsl:text>&#xa;</xsl:text>
<!--children-->
<xsl:apply-templates select="key('c:bieByClass',c:col(.,'ObjectClass'))">
<xsl:with-param name="c:ancestors" select="$c:ancestors,."/>
<xsl:with-param name="c:indent" select="concat(' ',$c:indent)"/>
</xsl:apply-templates>
<!--end tag-->
<xsl:value-of select="
concat($c:indent,'&lt;/',$c:prefix,c:col(.,'ComponentName'),'>&#xa;')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xs:template>
<para>
Process an ASBIE by working with its ABIE
</para>
</xs:template>
<xsl:template match="Row[c:col(.,'ComponentType')='ASBIE']">
<xsl:apply-templates
select="key('c:abieByClass',c:col(.,'AssociatedObjectClass'))">
<xsl:with-param name="c:definition" select="c:col(.,'Definition')"/>
</xsl:apply-templates>
</xsl:template>

<xs:template>
<para>
Process a BBIE by working with its ABIE
</para>
</xs:template>
<xsl:template match="Row">
<xsl:param name="c:ancestors" as="element(Row)*"/>
<xsl:param name="c:indent" as="xsd:string"/>
<!--start tag-->
<xsl:value-of select="
concat($c:indent,'&lt;','cbc:',c:col(.,'ComponentName'),'>')"/>
<!--definition-->
<xsl:comment select="c:col(.,'Definition')"/>
<!--end tag-->
<xsl:value-of select="
concat($c:indent,'&lt;/','cbc:',c:col(.,'ComponentName'),'>&#xa;')"/>
</xsl:template>

</xsl:stylesheet>
(1-1/2)