Selecting a descendant child at arbitrary depth
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
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