Re: [xsl] Grouping to Separate Out Block Level Elements from Mixed Content

Subject: Re: [xsl] Grouping to Separate Out Block Level Elements from Mixed Content
From: "Don Smith dsmith_lockesmith@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 5 Feb 2022 16:01:11 -0000
Hi Chris.
Thanks very much. I look forward to reviewing.
Don

Sent from Yahoo Mail on Android

  On Sat, Feb 5, 2022 at 9:50 AM, Chris Papademetrious
christopher.papademetrious@xxxxxxxxxxxx<xsl-list-service@xxxxxxxxxxxxxxxxxxxx
om> wrote:   #yiv4756972860 #yiv4756972860 -- _filtered {} _filtered {}
_filtered {} _filtered {}#yiv4756972860 #yiv4756972860 a:link, #yiv4756972860
span.yiv4756972860MsoHyperlink
{color:blue;text-decoration:underline;}#yiv4756972860
p.yiv4756972860MsoPlainText, #yiv4756972860 li.yiv4756972860MsoPlainText,
#yiv4756972860 div.yiv4756972860MsoPlainText
{margin:0in;font-size:11.0pt;font-family:sans-serif;}#yiv4756972860
span.yiv4756972860EmailStyle19
{font-family:sans-serif;color:windowtext;}#yiv4756972860
span.yiv4756972860PlainTextChar {font-family:sans-serif;}#yiv4756972860
.yiv4756972860MsoChpDefault {font-size:10.0pt;} _filtered {}#yiv4756972860
div.yiv4756972860WordSection1 {}#yiv4756972860 _filtered {} _filtered {}
_filtered {} _filtered {} _filtered {} _filtered {} _filtered {} _filtered {}
_filtered {} _filtered {} _filtered {} _filtered {} _filtered {} _filtered {}
_filtered {} _filtered {} _filtered {} _filtered {} _filtered {} _filtered
{}#yiv4756972860 ol {margin-bottom:0in;}#yiv4756972860 ul
{margin-bottom:0in;}#yiv4756972860
Hi Don,

 B 

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.

 B 

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.

 B 

Note the following:

 B 

   - 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.

 B 

My template matches like this:

 B 

<xsl:template match="*[mine:disallow-inline(.)][node()[mine:is-inline(.)]]">

B  ...

</xsl:template>

 B 

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.

 B 

So youbll probably need something more like this:

 B 

<xsl:template match="*[mine:disallow-block(.)][node()[mine:is-block(.)]]">

B  ...

</xsl:template>

 B 

As for what to include in the lists, I used the content_mode.pl script at

 B 

https://github.com/chrispy-snps/DITA-plugin-utilities

 B 

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.

 B 

   - Chris

 B 

 B 
 XSL-List info and archiveEasyUnsubscribe(by email)

Current Thread