This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Generic Select again


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]