Subject: Re: [xsl] xsl:value-of select : how to make some tags printed and others not From: Mukul Gandhi <mukulgw3@xxxxxxxxx> Date: Tue, 7 Oct 2003 08:10:58 -0700 (PDT) |
Hi Judith, Taking hint from David Carlisle's answer, I have written this XSL -- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="//text" /> </xsl:template> <xsl:template match="//text"> <xsl:copy> <xsl:apply-templates select="node()" /> </xsl:copy> </xsl:template> <xsl:template match="sw"> <xsl:value-of select="." /> </xsl:template> <xsl:template match="sub"> <sub> <xsl:value-of select="." /> </sub> </xsl:template> </xsl:stylesheet> You may want to avoid the XPATH expression //text. I have used it to illustrate the concept. David, please correct me if I am wrong. Regards, Mukul --- Judith Rog <Judith.Rog@xxxxx> wrote: > Hi, > Could anyone help me with the following? > > Suppose I have the following XML: > > <book> > <title>My first book</title> > <chapter> > <nr>1</nr> > <text> This is the <sw>content</sw> of my first > book, where > <sub>I</sub> would like to leave in the sub-tag, but > leave out the > sw-tag.</text> > </chapter> > </book> > > Is it possible to make an xsl statement that would > print the content of > the <text> tag and all sub tags (<xsl:value of > select="text"/>) but then > somehow leave the html formatting tags <sub> in the > output? So: > This is the content of my first book, where > <sub>I</sub> would like to > leave in the sub-tag, but leave out the sw-tag. > instead of: > This is the content of my first book, where I would > like to leave in > the sub-tag, but leave out the sw-tag. > > Thanks for your help. > Judith > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:value-of select : how, David Carlisle | Thread | Re: [xsl] xsl:value-of select : how, Wendell Piez |
[xsl] linefeed to <br/> template, Flemming Jønsson | Date | Re: [xsl] hierarchical sorting prob, Andy_Freeman |
Month |