xsl-list
[Top] [All Lists]

[xsl] picking apart mixed content

2008-05-13 11:47:38
Hello,

My DTD allows mixed content in my paragraphs.

e.g.
<!ELEMENT paragraph (#PCDATA | emph | listU)*>

The HTML DTD does not allow lists within paragraphs.

I have, using <xsl:text disable-output-escaping="yes"> been able to *cheat* and 
end my open paragraph in my output when an embedded listU starts (I have this 
logic in my listU template). I have used the same trick to restart the 
paragraph once the listU was complete allowing the original paragraph to be 
ended in my paragraph template rule.

This isn't pretty, but works although a side effect is an empty paragraph 
following the listU when the input has no text, within the paragraph, following 
the list.

Sample input: (with text following the list)
<paragraph>Mary had a <emph>little</emph> lamb 
<listU><item>male</item><item>female</item></listU> its fleece ...</paragraph>

Sample HTML output:
<p>Mary had a <b>little</b> lamb</p>
<ul>
  <li>male</li>
  <li>female</li>
</ul>
<p>its fleece ...</p>

Sample input: (with NO text following the list)
<paragraph>Mary had a <emph>little</emph> lamb 
<listU><item>male</item><item>female</item></listU></paragraph>

Sample HTML output:
<p>Mary had a <b>little</b> lamb</p>
<ul>
  <li>male</li>
  <li>female</li>
</ul>
<p></p>

I've tried various combinations of normalize-space() and text() in both my 
paragraph and listU template rules but haven't come up with a reliable way to 
determine when text proceeds or follows an embedded list.

If there's a way to catch the text then I should be able to come up with a way 
to output the correct HTML without resorting to the "disable-output-escaping" 
cheat. Of course any way of identifying the presents of the text should also 
work when there are multiple lists within a single paragraph.

I am still using XSL 1.0 and can't change anytime soon. Also I can't change our 
DTD.

Thanks for any help.
  Craig Sampson



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>