Subject: [xsl] Test for child node categories From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx> Date: Thu, 5 Jul 2007 01:02:46 +1200 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] suppress missing dtd in docty, Jacques Couzteau | Thread | Re: [xsl] Test for child node categ, David Carlisle |
Re: [xsl] inserting page-break afte, Andreas Peter | Date | Re: [xsl] inserting page-break afte, AAS Contractor |
Month |