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

Re: Grouping to Separate Out Block Level Elements from

Subject: Re: Grouping to Separate Out Block Level Elements from Mixed Content
From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 5 Feb 2022 15:50:53 -0000
Re:  Grouping to Separate Out Block Level Elements from
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]

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.