xsl-list
[Top] [All Lists]

Tag with no data or missing tag - supply default

2004-09-16 15:48:45
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



<Prev in Thread] Current Thread [Next in Thread>