Hi Don,
I recently had to solve the opposite problem b inline content in <li> *not*
being wrapped in <p>. But itbs a similar problem b wrap some stuff but not
other stuff. Ibm attaching the code I used.
The basic approach is to use helper functions to identify elements as
block/inline, then <for-each-group group-adjacent=...> to wrap inline element
sequences in the current element but not block element sequences.
Note the following:
* My code has some heuristics to wrap <indexterm> elements only when
theybre along with real inline content; you might not need that.
* My code uses <xsl:next-match/> because itbs extracted from a larger
XSLT file that does other stuff; you might not need that.
* My helper functions use a series of [self::A or self::B or b&] that is
a bit inelegant. I should rewrite it to use the template-based approach
suggested in the recent bUsing node-set variables in predicatesb
discussion on this list, as I now prefer that style for element-class helper
functions.
* Because youbre solving the reverse problem (breaking content out of an
existing context rather than wrapping it in a new context), be sure to copy
any <p @props/@audience/@product/...> attributes to block elements you push
out of the <p> context.
My template matches like this:
<xsl:template match="*[mine:disallow-inline(.)][node()[mine:is-inline(.)]]">
...
</xsl:template>
which says, bmatch any element that contains inline content (is-inline()),
but *I* donbt want it to (disallow-inline()). The important distinction is,
disallow-inline() means *I* donbt want it to contain inline content; it has
nothing to do with what DITA itself allows.
So youbll probably need something more like this:
<xsl:template match="*[mine:disallow-block(.)][node()[mine:is-block(.)]]">
...
</xsl:template>
As for what to include in the lists, I used the content_mode.pl script at
https://github.com/chrispy-snps/DITA-plugin-utilities
to dump out our content models, then did some analysis based on which elements
are permitted in <body>, which elements are permitted in <p>, and so on. That
was a manual effort; maybe some day Ibll script it up so I can regenerate
the element lists as adjust our specializations.
* Chris
[demime 1.01d removed an attachment of type text/xml which had a name of wrap-inline-content-in-p.xsl]
|