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

Tag with no data or missing tag - supply default

Subject: Tag with no data or missing tag - supply default
From: "Mila P. Mitra" <pmitra@xxxxxxxxxxxxxxxxx>
Date: Thu, 16 Sep 2004 15:48:45 -0700
missing tag
Hello,
 I would like some help on how to use a stylesheet to supply a default value
if there is a certain element tag with no data within it, or if the element
is missing altogether. For example, here is an xml document extract.

I would like the output to always have a tag for <test> and if it doesnt
find a value to insert a default value of 'fail' in it. This is bacause my
output file will become input to another program which needs that tag and a
default value.

I would appreciate it if someone could please help me with the xsl code that
could do this transformation (formatting, i.e. whether output is HTML or XML
or text does ot matter, I can do that part):
<record1>
	<test>pass</test>
	<data>zzz</data>
<record1>
<record2>
	<test></test>
	<data>xxx</data>
</record2>
<record3>
	<data>yyy</data>
</record3>

Desired output:
record1:
pass
zzz

record2:
xxx
fail

record3:
yyy
fail

Thanks in advance,
Mila


---------------------------------------------
Mila (Patralekha) Mitra
650.604.1814
Northrop Grumman IT, NASA Ames, CA


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--

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.