This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Template Question
- To: "'XSL-List at mulberrytech dot com'" <XSL-List at mulberrytech dot com>
- Subject: Template Question
- From: "Chowdhury, Anisuzzaman" <Anisuzzaman dot Chowdhury at westgroup dot com>
- Date: Thu, 27 Apr 2000 14:36:39 -0500
- Reply-To: xsl-list at mulberrytech dot com
I don't know whether it has been discussed here before but I could not find
any problem similar to mine in XSL-List archive.
Please consider the following XML and XSL:
<XML>
<Book>
<Title> Cat And Dog</Title>
<Chap1>The big<HL>dog</HL> and the little cat</Chap1>
<Chap3>The cat is little and black</Chap3>
<Chap2>The <HL>dog</HL> is big and brown</Chap2>
<Chap4>The big <HL>dog</HL>....</Chap4>
</Book>
</XML>
Stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0'>
<xsl:output method='xml' indent='yes'/>
<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
<xsl:template match="/">
<xml><Xwp>
<Content><xsl:apply-templates/></Content>
</Xwp></xml>
</xsl:template>
<xsl:template match="Book">
<xsl:call-template name="Chap1"/>
<xsl:call-template name="Chap2"/>
<xsl:call-template name="Chap3"/>
<xsl:call-template name="Chap4"/>
</xsl:template>
<xsl:template name="Chap1">
<Chap1Text><xsl:value-of select="."/></Chap1text><BR>
</xsl:template>
<xsl:template name="Chap2">
<Chap2Text><xsl:value-of select="."/></Chap2text><BR>
</xsl:template>
<xsl:template name="Chap3">
<Chap3Text><xsl:value-of select="."/></Chap3text><BR>
</xsl:template>
<xsl:template name="Chap4">
<Chap4Text><xsl:value-of select="."/></Chap4text><BR>
</xsl:template>
<xsl:template match="HL">
<B><xsl:value-of select="."/></B>
</xsl:template>
I would like to display all the texts according to the Stylesheet's
order(e.g. first chap1, then chap2, then chap3....). At the same time I
would like to change all the <HL> tags to <B> tags; <HL> tags can be found
anywhere in the document.
I would like to see the following output:
<xml>
<Xwp>
<Content>
<Chap1text>The big<B>dog</B> and the little cat</Chap1text><BR>
<Chap2text>The <B>dog</B> is big and brown</Chap2text><BR>
<Chap3text>The cat is little and black</Chap3text><BR>
<Chap4text>The big <B>dog</B>....</Chap4text><BR>
</Content>
</Xwp>
</xml>
One way I can possibly do it if I call the template "HL" in every other
template. But it is not reasonable while handling hundreds of templates. Is
there any efficient way of doing this?
Thanks a lot for all your responses in advance.
Thanks,
Anis Chowdhury
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list