Subject: Re: [xsl] [XSL 1.0] How to use apply-templates to process a sub-node From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 07 Feb 2011 16:53:05 -0500 |
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?
-- Contact us for world-wide XML consulting & instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] [XSL 1.0] How to use apply-te, Keith Gilbert | Thread | [xsl] 1st previous node(), Karl Stubsjoen |
[xsl] [XSL 1.0] How to use apply-te, Keith Gilbert | Date | [xsl] 1st previous node(), Karl Stubsjoen |
Month |