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

Conditional extraction of data

Subject: Conditional extraction of data
From: "Bradley, Peter" <PBradley@xxxxxxxxxx>
Date: Mon, 8 Nov 2004 13:28:12 -0000
xsl conditional like
It pays to be honest, so I'll be up-front about this.  The question arises
from an assignment on a course I'm doing.

However, I don't want to cheat, so I'll try to form the question in the most
general way that I can:

The purpose of the exercise is to convert some xml to html.  I have a
repeating element under the root - let's call it anElement.  Initially, the
requirement was to output all its contents, unchanged.  So I could do this:

<xsl:for-each select="anElement">
	<xsl:value-of select="." />
</xsl:for-each>

The anElement element has mixed content and would be described in a DTD as
follows:

<!ELEMENT anElement (#PCDATA | tag1 | tag2 | tag3 | tag4)* >

All the child tags contain #PCDATA only.

The new requirement is to print all the content as before, but to print the
contents of tag2 (say) in italics - i.e. surround its contents with <i></i>
html tags.

I've sweated over this all weekend and can't work out how to solve it.  If I
treat each tag individually in a for-each or an apply-templates/template
combination (if that makes sense), I can't see how to output the #PCDATA in
anElement.

Any help would be appreciated - especially a pointer to a resource that will
let me work it out for myself.  I've tried the obvious places like w3c
schools.

Thank for your attention


Peter

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.