Subject: [xsl] Selecting a descendant child at arbitrary depth From: "Peter McEvoy" <pmcevoy@xxxxxxxx> Date: Wed, 14 Mar 2001 09:20:41 -0000 |
I seem to be going mad today, but I can't seem to do this basic thing: xml is something like <mainDisplay> <document> **XHTML tags here - arbitrary levels deep <table> <tr> <td> <docBody> **More XHTML tags in here** </docBody> </td> </tr> </table> **More XHTML tags, but no more docBody tags** </document> </mainDisplay> Now, the mainDisplay element is actually a child of a bigger tree, but it only occurs once. My stylesheet can successfully do all it needs to do to set the mainDisplay as the context node. The <document> element is the only child of mainDisplay (I know, that's redundant, but its a legacy thing (wow, I said "legacy" when refering to XML!!)). The children of <document> are then any XHTML tags (in all cases, the first child is a <html> element). Now, I have invented a tag called <docBody> which surrounds the XHTML that I am actually interested in. What I want to do is copy the contents of the <docBody> to the output, but ignore anything else that surrounds it: mainDisplay +--document +--html <--ignore +---... <--ignore ... <--ignore +--docBody <--ignore +--copy the contents of this to output ... <--ignore Because docBody can be at any level below mainDisplay, once I have successfully got to mainDisplay as the context node I am trying a rule like this: <xsl:template match="mainDisplay"> <xsl:apply-templates select=".//docBody" /> </xsl:template> and then using the template: <xsl:template match="docBody"> <xsl:copy-of select="*" /> </xsl:template> I've tried: <xsl:apply-templates select="descendant::docBody" /> as well, but to no avail. I know I have got to the mainDisplay template as I've inserted debugging messages and they come up on the output. But debugging messages in the docBody template do not. Can someone give me a hand? I feel like I'm bashing my head off a wall!! BTW, using Saxon 5.5.1 C Ya, Peter McEvoy Senior Technical Analyst IONA Technologies XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Resend: Is there a way .., Jeni Tennison | Thread | Re: [xsl] Selecting a descendant ch, David Carlisle |
Re: [xsl] Removing duplicates for u, Jeni Tennison | Date | Re: [xsl] evaluate(), Jeni Tennison |
Month |