|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How to output 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








