Monday, 2 September 2013

Text getting repeated without a loop

Text getting repeated without a loop

i've the below xml.
XML Document
and the below xslt.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ntw="Number2Word.uri" exclude-result-prefixes="ntw">
<xsl:variable name="ThisDocument" select="document('')"/>
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE
html&gt;</xsl:text>
<html>
<head>
<title>
<xsl:value-of select="concat('Appendix ',
substring-before(substring-after(part/chapter/title, '
'),' '))"></xsl:value-of>
</title>
<link rel="stylesheet" href="C:\Documents and
Settings\u0138039\Desktop\XML COnversion\Book
5\Book-5(original)\assets\main.css" type="text/css"/>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="part/chapter/title">
<xsl:variable name="check">
<xsl:value-of select="string-length(substring-before(substring-after(.,'
'),' '))"/>
</xsl:variable>
<section class="tr_chapter">
<div class="cha_app chapter">
<xsl:choose>
<xsl:when test="$check=1">
<a name="{concat('CHA_APP_0', substring-before(substring-after(., '
'),' '))}" class="tr_toc_anchor"> </a>
</xsl:when>
<xsl:otherwise>
<a name="{concat('CHA_APP_', substring-before(substring-after(., ' '),'
'))}" class="tr_toc_anchor"> </a>
</xsl:otherwise>
</xsl:choose>
<div class="chapter-title">
<xsl:value-of select="concat('Appendix ',
substring-before(substring-after(., ' '),' '))"></xsl:value-of>
</div>
<div class="chapter-subtitle">
<xsl:value-of select="substring-after(substring-after(.,' '),'
')"></xsl:value-of>
</div>
<div class="chapter-subtitle">
<xsl:value-of select="following-sibling::subtitle"/>
</div>
<xsl:apply-templates select="following-sibling::section"/>
</div>
</section>
</xsl:template>
<xsl:template match="section">
<div class="section-sect1">
<a name="{concat('APP_01-SEC-',substring-before(substring-after(./title,'
'), ' '))}">
</a>
<div class="section-title">
<xsl:value-of select="concat('Chapter
',substring-before(substring-after(./title,' '),' '),' ')"/>
<xsl:text disable-output-escaping="yes">&lt;br/&gt;</xsl:text>
<xsl:value-of select="substring-after(substring-after(./title,' '),' ')"/>
</div>
<xsl:apply-templates select="child::node()[not(self::title)]"/>
</div>
</xsl:template>
<xsl:template match="para">
<div class="para">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template name="orderedlist" match="orderedlist">
<ol class="eng-orderedlist orderedlist">
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template name="orderitem" match="item">
<li class="item">
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template name="orderitempara" match="item/para">
<xsl:choose>
<xsl:when test="parent::item/@num">
<div class="para">
<xsl:choose>
<xsl:when test="position()=1">
<span class="item-num">
<xsl:if test="position()=1">
<xsl:value-of select="parent::item[1]/@num"/>
</xsl:if>
</span>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</div> </xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="content-style">
<xsl:choose>
<xsl:when test="@format='smallcaps'">
<xsl:value-of
select="translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXZ','abcdefghijklmnopqrstuvwxyz')"/>
</xsl:when>
<xsl:when test="@format='superscript'">
</xsl:when>
<xsl:otherwise>
<xsl:variable name="fontStyle">
<xsl:value-of select="concat('font-style-',@font-style)"/>
</xsl:variable>
<span class="{$fontStyle}">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
when i'm running this xslt on my xml. there is content repeating, though
i've not used any loops. i'm really confused and unable to understand
where i'm going wrong. please let me know.
you can use this text to search "This Law is formulated in order to ensure
that economic disputes shall be impartially and promptly arbitrated, to
protect"
Thanks

No comments:

Post a Comment