[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Transforming HTML to NITF

Subject: RE: Transforming HTML to NITF
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Sat, 17 Feb 2001 09:55:17 -0000
nitf equivilant of b
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.