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

How to output partial elements?

Subject: How to output partial elements?
From: Jem Clear <jem@xxxxxxxxxxxxxx>
Date: Tue, 20 Aug 2002 10:42:07 +0100
jem clear
I have been bashing my brain for days over this and I need help.
Here is the (style of) input I have:

  <record n="1" type="normal">
    <foo> <x>... <y>...</y> ...</x> </foo>
    <bar> <things> ... </things> </bar>
  </record>
  <record n="2" type="normal">
    <foo> <x>... <y>...</y> ...</x> </foo>
  </record>
  <record n="3" type="continuation">
    <bar> <things> ... </things> </bar>
  </record>
  <record n="4" type="normal">
    <foo> <x>... <y>...</y> ...</x> </foo>
    <bar> <things> ... </things> </bar>
  </record>

The problem is <record>s 2 and 3: they need to be concatenated. (The 'n'
attribute is irrelevant: I only put it there for easy reference in
illustration.)

At first I thought this was easy: 

   have a template to match <record>
   if (@type != "continuation") {
     write "</record>" to the output
   }
   write "<record>" to output
   copy all child nodes to output   

But XSLT won't allow partial (malformed) XML to be written to the
output tree from a <xsl:template> -- so I can't do this!
*Everyone* tells me XSLT is "the right tool" for this sort of task:
but if I'd followed my natural inclination and hacked it up in Perl
it'd be trivial to chop the offending two lines out! :)

Any ideas how to make the output look like this:

  <record type="normal">
    <foo> <x>... <y>...</y> ...</x> </foo>
    <bar> <things> ... </things> </bar>
  </record>
  <record type="normal">
    <foo> <x>... <y>...</y> ...</x> </foo>
    <bar> <things> ... </things> </bar>
  </record>
  <record type="normal">
    <foo> <x>... <y>...</y> ...</x> </foo>
    <bar> <things> ... </things> </bar>
  </record>

Thanks

Jem Clear
29 School Road, Moseley, Birmingham, B13 9TF, UK
Tel & Fax: +44 (0)121 689 3637
Email:     jem@xxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.