Solved

How to construct condition in xsl

Posted on 2013-05-20
5
271 Views
Last Modified: 2013-05-20
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
0
Comment
Question by:GessWurker
  • 3
  • 2
5 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39181399
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
0
 

Author Comment

by:GessWurker
ID: 39181468
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" />
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 39181513
<xsl:for-each select="inmr0:CatFileName">
                        <PropertyValue name="Document File Name">
                          <xsl:if test="string(.)">
                            <xsl:value-of select="concat('F:\Program Files\Inmagic\Genie\DocumentFolder\', .)"/>
                          </xsl:if>
                        </PropertyValue>
                      </xsl:for-each>
0
 

Author Comment

by:GessWurker
ID: 39181637
Thanks. Works as advertised! (i.e., perfectly!)

Cheers!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39181681
welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now