User:Dr pda/extractClass.stx







    

  

  

  </stx:template>

<stx:variable name="page-title"/> <stx:variable name="page-text"/> <stx:variable name="page-id"/>

<stx:template match="m:title"> <stx:assign name="page-title" select="string(.)"/> </stx:template>

<stx:template match="m:text"> <stx:assign name="page-text" select="string(.)"/> </stx:template>

<stx:variable name="first-revision" select="true"/>

<stx:template match="m:revision"> <stx:if test="$first-revision"> <stx:assign name="first-revision" select="false"/> <stx:process-children/> </stx:if> </stx:template>

<stx:buffer name="parsed"/> <stx:variable name="article-count" select="0"/> <stx:variable name="found-something"/> <stx:variable name="fa-class"/> <stx:variable name="fl-class"/> <stx:variable name="a-class"/> <stx:variable name="ga-class"/> <stx:variable name="b-class"/> <stx:variable name="c-class"/> <stx:variable name="start-class"/> <stx:variable name="stub-class"/> <stx:variable name="list-class"/>

<stx:template match="m:id"> <stx:if test="$first-revision"> <stx:assign name="page-id" select="normalize-space(.)"/> </stx:if> </stx:template>

<stx:template match="m:page"> <stx:assign name="first-revision" select="true"/> <stx:process-children /> <stx:variable name="prefix" select="substring-before($page-title,':')"/> <stx:variable name="skip" select="false"/> <stx:if test="not(starts-with($prefix,'Talk'))"> <stx:assign name="skip" select="true"/> </stx:if> <stx:if test="not($skip)"> <stx:assign name="found-something" select="false"/> <stx:assign name="article-count" select="$article-count+1"/> <stx:assign name="fa-class" select="0"/> <stx:assign name="fl-class" select="0"/> <stx:assign name="a-class" select="0"/> <stx:assign name="ga-class" select="0"/> <stx:assign name="b-class" select="0"/> <stx:assign name="c-class" select="0"/> <stx:assign name="start-class" select="0"/> <stx:assign name="stub-class" select="0"/> <stx:assign name="list-class" select="0"/> <stx:result-buffer name="parsed" clear="yes"> <stx:variable name="text" select="$page-text"/> <stx:while test="string-length($text) &gt; 0"> <stx:assign name="text" select="substring-after($text,'')"/> <stx:assign name="temp" select="substring-after($temp,'lass')"/> <stx:if test="string-length($temp) &gt; 0"> <stx:call-procedure name="template"> <stx:with-param name="content" select="string-join(($temp,'}}'),'')"/> </stx:call-procedure> <stx:assign name="text" select="substring-after($text,'}}')"/> </stx:if> </stx:if> </stx:while> <stx:value-of select="$fa-class"/> <stx:value-of select="$fl-class"/> <stx:value-of select="$a-class"/> <stx:value-of select="$ga-class"/> <stx:value-of select="$b-class"/> <stx:value-of select="$c-class"/> <stx:value-of select="$start-class"/> <stx:value-of select="$stub-class"/> <stx:value-of select="$list-class"/> </stx:result-buffer> <stx:if test="$found-something"> <stx:message> <stx:value-of select="$article-count"/> </stx:message> <stx:text>&#xA;</stx:text> <stx:value-of select="$page-title"/> <id><stx:value-of select="$page-id"/></id> <stx:text>&#xA;</stx:text> <stx:process-buffer name="parsed" group="copy"/> <stx:text>&#xA;</stx:text> <stx:text>&#xA;</stx:text> </stx:if> </stx:if> </stx:template>

<stx:group name="copy"> <stx:template match="*"> <stx:element name="{name(.)}"> <stx:process-attributes/> <stx:process-children/> </stx:element> </stx:template> <stx:template match="@*"> <stx:attribute name="{name(.)}" select="."/> </stx:template> <stx:template match="text"> <stx:value-of select="."/> </stx:template> </stx:group>

<stx:procedure name="template"> <stx:param name="content" required="yes"/> <stx:choose> <stx:when test="matches($content,'\s?=\s?fa\s?[|}]','i')"> <stx:assign name="fa-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?fl\s?[|}]','i')"> <stx:assign name="fl-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?a\s?[|}]','i')"> <stx:assign name="a-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?ga\s?[|}]','i')"> <stx:assign name="ga-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?b\s?[|}]','i')"> <stx:assign name="b-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?c\s?[|}]','i')"> <stx:assign name="c-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?start\s?[|}]','i')"> <stx:assign name="start-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?stub\s?[|}]','i')"> <stx:assign name="stub-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> <stx:when test="matches($content,'\s?=\s?list\s?[|}]','i')"> <stx:assign name="list-class" select="1"/> <stx:assign name="found-something" select="true"/> </stx:when> </stx:choose> </stx:procedure>

</stx:transform>