Subject: RE: [xsl] Transforming HTML to NITF From: "Michael Kay" <mhkay@xxxxxxxxxxxx> Date: Sat, 17 Feb 2001 09:55:17 -0000 |
> the NITF has a <content.body> tag which is equivilant to > HTMLs <body> tag. > However, its children are far more rigidly defined in that it > only allows elements as children. > > > I need to get the line: > this is <em>emphasis</em> some more <b>text</b></br></br> > > to end up wrapped in <p> tags (preferably without the <br>s) > > > > For clarity, the children of the body are: > p > ul > | text() > | em > | text() > | b > | br > | br > p > > > I need to work with thos tags that have the | beside them > as a single > > block so that I can wrap the entire thing in a <p> tag. > An interesting positional grouping problem. My first thought is a two-pass approach. First wrap the offending elements individually in a <merge> tag, then do a positional grouping to merge adgacent <merge> elements into a single <p> element. The first stage is easy: <xsl:template match="content.body/text() | content.body/em | ..."> <merge><xsl:copy-of select="."/></merge> </xsl:template> The second pass is trickier (positional grouping always is); I naturally do it with saxon:leading(), which selects all the nodes in a node-set that satisfy some condition, stopping at the first one that doesn't: <xsl:template match="merge[not(preceding-sibling::*[1][self::merge])]"> <p> <xsl:copy-of select="saxon:leading(following-sibling::*, saxon:expression('self::merge'))"/> </p> </xsl:template> The alternative is a recursive template that continues processing successive elements until it finds one that isn't a <merge> element. This might be a good one to add to the grouping use cases for XSLT 2.0 Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Transforming HTML to NITF, Adam Van Den Hoven | Thread | Re: [xsl] Transforming HTML to NITF, Jeni Tennison |
RE: [xsl] Re: [ANNOUNCE] XSLT-proce, Michael Kay | Date | Re: [xsl] XSLT 1.1 comments (portab, Tobias Reif |
Month |