[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|