Link to home
Start Free TrialLog in
Avatar of GessWurker
GessWurker

asked on

How to construct condition in xsl

I need to modify the attached XSL so that it returns information for fields that are empty in the input.

I.E. If the input contains
<inmr0:CatNotes />,
I need the XSL to return
<PropertyValue name="Notes" />
rather than nothing.

To clarify: I don't know how to set up conditions in the XSL so that it doesn't completely ignore the the empty fields in input.

I've attached the XSL along with sample input. The input contains a number of empty fields, including these:

<inmr0:CatNotes />
<inmr0:CatISBN />
<inmr0:CatFileName />

However, as I said, such fields make NO APPEARANCE in the output. What I need to see for them is this:

<PropertyValue name="Notes" />
<PropertyValue name="ISBN" / >
<PropertyValue name="Document File Name" / >

Who knows how to do this?
NeedsAdjustment.xsl
inputTEST.xml
inputTEST-out-problem.xml
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

The condition already is in your XSLT

                     <xsl:for-each select="inmr0:CatNotes[string(.)]">

does something for every CatNotes that ahs content
[string(.)] actually excludes all the notes that don't have content

if you remove all the occurences of [string(.)] from your stylesheet it will do what you need
Avatar of GessWurker
GessWurker

ASKER

Hi. And thanks. Nearly there. However... there's one problem: The concatentation for Document File Name. With an empty CatFileName, I end up with this:

<PropertyValue name="Document File Name">F:\Program Files\Inmagic\Genie\DocumentFolder\</PropertyValue>

I need to end up with this:

<PropertyValue name="Document File Name" />
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. Works as advertised! (i.e., perfectly!)

Cheers!