xsl-list
[Top] [All Lists]

[xsl] Test for child node categories

2007-07-04 06:03:14
I have the following element definition (I've cut it down slightly for
reasons of space but the principle is clear):

  <!ENTITY % simple "#PCDATA">
  <!ENTITY % markup "em|sub|sup">
  <!ENTITY % textcontent "%simple;|%markup;">
  <!ENTITY % lists "define|list|ul|ol">
  <!ENTITY % blockcontent "para|note|warning|table|img|%lists;">
  <!ENTITY % complexcontent "%textcontent;|%blockcontent;">
  
  <!ELEMENT answer (%complexcontent;)*>

I am writing an XSL transform to output HTML, and the template for <answer>
needs to take into consideration whether
a) all the children of answer are textcontent;
b) all the children of answer are blockcontent;
c) there is a mixture of textcontent and blockcontent children

So my first question is: how could I write these tests in XSL 1?

In the output HTML an <answer> element is going to generate a <div>, and
case (a) will require a <div><p>...</p></div>, while in case (b) a simple
<div>...</div> will suffice.

Case (c) is evidence of a poorly structured document, but the XML is defined
by/validated against a DTD not a schema and so I live with the possibility.
This will require my stylesheet to generate <div>...</div> while wrapping
any sequences of consecutive 'textcontent' children in a <p>...</p>.

That leads to the second question: is there a construct that will do this,
comprehensible by a bear with very little brain, again in XSL 1?

Thanks if you can help

Cheers
Trevor



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