Q:

Filter for specific value, but use default value if it doesn't exist

I have an input schema that contains a list of phone numbers with a phone number type which looks as follows:
<phoneNumbers>
    <phoneNumber type="work">...</phoneNumber>
    <phoneNumber type="home">...</phoneNumber>
</phoneNumbers>

I only want to map a specific type of number, let's say 'work'. If a 'work' type phone number isn't available I need to fill in a default value.
This is what I start with:

The problem I run into is that I can't get the default value to appear in the output if there is no 'work' phone number present.

A:

How about using scripting functoid with  this.
public string setphonenumber(string work_number)
{
  string default = "123456789";
  if(work_number ="")
      return default;
  else return work_number;

}

A:

You can use an inline XSLT Scripting Functiod.
Suppose the source and destination structures look like this:

Inline XSLT would be something like this:
<workNumber xmlns:p="http://PhoneNumberMap.SourceSchema">
  <xsl:variable name="var:v1" select="/p:Root/phoneNumbers/phoneNumber[@type='work']" />
  <xsl:choose>
    <xsl:when test="$var:v1!=''">
      <xsl:value-of select="$var:v1" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="'some default'" />
    </xsl:otherwise>
  </xsl:choose>
</workNumber>

