Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to construct condition in xsl

Posted on 2013-05-20
5
Medium Priority
?
283 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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. 
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

972 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