RE: [xsl] Generic Select again

Subject: RE: [xsl] Generic Select again
From: "Oleg Tkachenko" <olegt@xxxxxxxxxxxxx>
Date: Mon, 6 Aug 2001 22:47:46 +0200
Hello Sriharsha !

> My XML looks something like this
> 
> <Books>
> <Book id = "1">
>      <TITLE> XML </Title>
Huh, rather strange xml - it's not well-formed, do you mean <TITLE> XML </TITLE> ?

>      <Author> ABC </Author>
>      <Desc> wonderful </Description>
? The same again.

>      <ISBN> 15151161 </ISBN>
> </Book>

> Now I need a generic template wherein I can specify the output to only 
> contain Title or TITLE and Author or TITLE, AUTHOR Description or TITLE, 
> AUTHOR, Description, ISBN. Put in another way, if I can somehow say  dont 
> include ISBN or DONT include ISBN and desc.
> Then finally I want the same thing to apply to the entire data.

What about the following not too generic template:

<xsl:template match="Book">
	<xsl:param name="output-title"/>
	<xsl:param name="output-author"/>
	<xsl:param name="output-desc"/>
	<xsl:param name="output-isbn"/>
	<xsl:if test="$output-title"><xsl:apply-templates select="Title"/></xsl:if>
	<xsl:if test="$output-author"><xsl:apply-templates select="Author"/></xsl:if>
	<xsl:if test="$output-desc"><xsl:apply-templates select="Desc"/></xsl:if>
	<xsl:if test="$output-isbn"><xsl:apply-templates select="ISBN"/></xsl:if>
</xsl:template>

Then you can use it this way to output Title and Author only:

<xsl:apply-templates select="Book[@id='1']">
	<xsl:with-param name="output-title" select="true()"/>
	<xsl:with-param name="output-author" select="true()"/>
</xsl:apply-templates>

---
Oleg Tkachenko,
Multiconn International 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread