Subject: [xsl] [XSL 1.0] How to use apply-templates to process a sub-node From: Keith Gilbert <kgilbert@xxxxxxxxxxxxxxxxxxxxx> Date: Mon, 7 Feb 2011 15:51:21 -0600 |
This is a real basic question, I think, but I can't get my head around it. Given this XML: <root> <story> <Head>This is the title</Head> <Body>This is the body <Big>some of it is bold</Big> and some isn't</Body> <Body>This is some more body text.</Body> </story> </root> And this XSL: <xsl:stylesheet> <xsl:template match="/"> <html> <body> <xsl:apply-templates select="Root" /> </body> </html> </xsl:template> <xsl:template match="Head"> <h1><xsl:value-of select="."/></h1> </xsl:template> <xsl:template match="Body"> <p><xsl:value-of select="."/></p> </xsl:template> <xsl:template match="Big"> <bold><xsl:value-of select="."/></bold> </xsl:template> </xsl:stylesheet> I'm trying to convert the XML to HTML with XSL. I've got it all figured out and working, except for the <Big> text. I don't understand how to recursively get to the <Big> element when it is a sub-element of <Body>. All the examples I've read about in all my books expect the XML to be: <Body> <Big>text here</Big> </Body> But this is a different structure, where the <Big> element is in the middle of the Body element. Can anyone shed some light on how I get to the <Big> element with apply-templates? Thanks! ~ Keith
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Trouble positioning "fo:b, G. Ken Holman | Thread | Re: [xsl] [XSL 1.0] How to use appl, G. Ken Holman |
Re: [xsl] Trouble positioning "fo:b, G. Ken Holman | Date | Re: [xsl] [XSL 1.0] How to use appl, G. Ken Holman |
Month |