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

RE: How to output partial elements?

Subject: RE: How to output partial elements?
From: Stuart Brown <sbrown@xxxxxxxxxxxxx>
Date: Tue, 20 Aug 2002 11:04:09 +0100
xpath partial elements
Hi Jem,

> 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.)

What you actually want to do here is to include in a type="normal" record
the children of a subsequent type="continuation" record, so something like
this would be required:

<!-- Limit match to normal records only -->
<xsl:template match="record[@type='normal']">
  <record n="{@n}">
    <!-- Handle the contents of this record -->
    <xsl:apply-templates/>
    <!-- If the first following sibling is a record of type continuation,
handle its children -->
    <xsl:apply-templates
select="following-sibling::record[1][@type='continuation']/*"/>
  </record>
</xsl:template>

This assumes that you only ever have one continuation: if there are
potentially more then the XPath will be more complicated. 

Hope this helps,

Stuart
> 

 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.