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

Test for child node categories

Subject: Test for child node categories
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Jul 2007 01:02:46 +1200
 Test for child node categories
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

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.