I am trying to do a XSLT transform from one XML format to another...so far everything is going very smooth except I am having some problems when I am doing concatination involving attributes. The problem is if say I am concatinating 3 attributes from one format into one value to be put in the new format, if any of the 3 attributes (all optional) are not included in the source xml file the entire concatination fails.
Is there a way around this? Even if one or more of the attributes do not exist in the source doc I still want it to concactinate what it can and just put nothing in the space where the missing attribute would be.
I'll try to make a simple example of files and guts of my concat.
Source
<Person Firstname="John" MiddleName="Jacob" LastName="JengleHiemerSchmitt"/>
<Person Firstname="Mary" LastName="Smith"/>
Target
<PersonFullName></PersonFullname>
XSLT concat
<PERSON>
<xsl:variable name="concatResult" select="concat('My Name is', $FirstName)"/>
<xsl:variable name="concatResult1" select="concat($concatResult, $MiddleName)"/>
<xsl:variable name="concatResult2" select="concat($concatResult1, $LastName)"/>
<xsl:value-of select="$concatResult2"/>
</PERSON>
For the first pperson it would work fine, but in the second person it would just give me nothing.
What am I doing wrong here?
Is there a way around this? Even if one or more of the attributes do not exist in the source doc I still want it to concactinate what it can and just put nothing in the space where the missing attribute would be.
I'll try to make a simple example of files and guts of my concat.
Source
<Person Firstname="John" MiddleName="Jacob" LastName="JengleHiemerSchmitt"/>
<Person Firstname="Mary" LastName="Smith"/>
Target
<PersonFullName></PersonFullname>
XSLT concat
<PERSON>
<xsl:variable name="concatResult" select="concat('My Name is', $FirstName)"/>
<xsl:variable name="concatResult1" select="concat($concatResult, $MiddleName)"/>
<xsl:variable name="concatResult2" select="concat($concatResult1, $LastName)"/>
<xsl:value-of select="$concatResult2"/>
</PERSON>
For the first pperson it would work fine, but in the second person it would just give me nothing.
What am I doing wrong here?