I bet this is a simple question.
Im trying to style my xml file with XSL. And the thing I am trying to do is that when an element in my XML file is missing, I want the xsl to output ” Missin Element”
I manage to create an string that says no data in element, but thats when I don’t have any data in the element but the element still exist.
I pasting my xml file to explain better
<autoads>
<ad>
<type>1</type>
<name>Honda</name>
<model>XL 1000 V</model>
<regyear>2001</regyear>
<price>129900</price>
<adtext>2001 Honda XL 1000 V, 8.900 km. hög vindruta. Pris 129.900kr,-. </adtext>
<addate>20020115</addate>
<volume>1000</volume>
</ad>
<ad>
<type>2</type>
<name>Nissan</name>
<model>Almera 1.4S</model>
<regyear>1997</regyear>
<price>119000</price>
<adtext>1997 Nissan Almera 1.4S, 5 dörrar, met, 70.000 km. el.spegel/fönster, galv. kaross, c.lås, startspärr, airbag, nedfällb. baks. ABS, ute temp. R/CD, alarm, d.fäste, v.säten, s/v-hj. EU-godk. full service, servo. Pris 119.000 kr,-. </adtext>
<addate>20020118</addate>
<volume>0</volume>
<category>5 dörrar</category>
</ad>
</autoads>
As you se the element category is missing in the first one,
Thats what im trying to output with an xsl string, that it should print out ” category is missing”
Thanks for all help.
You’ll need to specify which elements you’re expecting and test for their existence. In the simplest case, use something like this:
This outputs a comment in place of the missing node, but you could easily modify it to output an element or simply text.
For a more complete solution, create a list of the required elements and use the
documentfunction to verify the presence of each item in this list: