[xsl] need help outputing summary of head elements

Subject: [xsl] need help outputing summary of head elements
From: UlyLee <ulyleeka@xxxxxxxxx>
Date: Mon, 19 Sep 2005 04:52:22 -0700 (PDT)
hi again!

i have this xml file that has a number of head
elements in them and i need to generate a summary
element that contains all the head elements that
starts in a roman numeral.

<summary>I. Head 1 - II. Head 2 - III. Head
3</summary>

so far i was able to search and identify all the head
elements that starts with a roman numeral. but i can't
seem to find a way to insert the in-between separator
(" - "). 

What i did first is catch all the head elements:

<xsl:if test="name(.)='info'">
<xsl:call-template name="InsertSummary">
<xsl:with-param name="ParentInfo"
select="./ancestor::art"/>
</xsl:call-template>
</xsl:if>

i need to insert the summary element right after the
info element. i'm assigning the art ancestor of info
to the ParentInfo parameter in which i will use to get
all the head elements.

<xsl:template name="InsertSummary">
<xsl:param name="ParentInfo"/>
<xsl:if test="not(count($ParentInfo//head)=0)">
<xsl:element name="summary">
<xsl:for-each select="$ParentInfo//div/head">
<xsl:variable name="roman">
<xsl:call-template name="chkRoman">
<xsl:with-param name="str1">
<xsl:value-of select="."/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$roman">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:if>
</xsl:template>

<xsl:variable name="strRoman" as="xs:string">I. II.
III. IV. V. VI. VII. VIII. IX. X. XI. XII. XIII. XIV.
XV.</xsl:variable>

<xsl:template name="chkRoman">
<xsl:param name="str1"/>
<xsl:param name="bool"/>
<xsl:choose>
<xsl:when test="contains($str1,' ')">
<xsl:if
test="contains($strRoman,substring-before(normalize-space($str1),'
'))">
<xsl:value-of select="bool">true</xsl:value-of>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="contains($strRoman,$str1)">
<xsl:value-of
select="bool">true</xsl:value-of></xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

what i need now i a way to determine whether the last
head that i inserted in the summary element is the
last head with roman numeral so i'll no longer insert
a separator.

any suggestions on how to do that???

UlyLee


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread