Solved

How to construct condition in xsl

Posted on 2013-05-20
5
270 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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 video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

15 Experts available now in Live!

Get 1:1 Help Now