[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Template Question

Subject: Template Question
From: "Chowdhury, Anisuzzaman" <Anisuzzaman.Chowdhury@xxxxxxxxxxxxx>
Date: Thu, 27 Apr 2000 14:36:39 -0500
template question
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.