|
next
|
Subject: if string = null stop it from being created. Author: christino Hadfield Date: 04 Oct 2007 10:10 AM Originally Posted: 04 Oct 2007 10:09 AM
|
Hi this is my code, but i want to stop the reference number from being created if it is blank or null? Does anyone know if this can be done as i am getting conflicting answers look at the web!
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:java="java">
<xsl:decimal-format name="pound" decimal-separator="." grouping-separator=","/>
<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:template match="Root">
<incoming-message>
<message>
<subject><xsl:text>test</xsl:text></subject>
<address type="FROM">
<value>
<xsl:text>test</xsl:text>
</value>
<component type="address">
<xsl:text>test</xsl:text>
</component>
</address>
<xsl:text>
</xsl:text>
<address type="TO">
<value>
<xsl:text>test</xsl:text>
</value>
</address>
<body>
<xsl:text>Reference Number: </xsl:text><xsl:value-of select="Reference"/>
<xsl:text>
</xsl:text>
<xsl:text>Dispute ID: </xsl:text><xsl:value-of select="DisputeID"/><xsl:text>
</xsl:text>
<xsl:text>Name: </xsl:text><xsl:value-of select="Name"/><xsl:text>
</xsl:text>
<xsl:text>Address: </xsl:text><xsl:value-of select="Address"/><xsl:text>
</xsl:text>
<xsl:text>DisputeReply: </xsl:text><xsl:value-of select="DisputeReply"/><xsl:text>
</xsl:text>
</body>
<sourceId><xsl:value-of select="DisputeID"/></sourceId>
<metadata name="RECEIVED_DATE">
<!--<xsl:value-of select="received_date"/>-->
<xsl:call-template name="reformat-date3">
<xsl:with-param name="datestring" select="Date"/>
</xsl:call-template>
</metadata>
<metadata name="Attachment">
<xsl:value-of select="MessagePath"/>
</metadata>
<metadata name="REFERENCE_NUMBER" ordering="1"><xsl:value-of select="Reference"/></metadata>
<metadata name="DISPUTEID" ordering="2"><xsl:value-of select="DisputeID"/></metadata>
<metadata name="NAME" ordering="3"><xsl:value-of select="Name"/></metadata>
<metadata name="ADDRESS" ordering="4"><xsl:value-of select="Address"/></metadata>
<metadata name="REPLYEMAIL" ordering="5">test@test.com</metadata>
<metadata name="DISPUTEREPLY" ordering="6"><xsl:value-of select="DisputeReply"/></metadata>
</message>
</incoming-message>
</xsl:template>
<xsl:template name="reformat-date">
<!--
Date string is expected to be in the format DDMMYY, this has to be converted to the ISO
8601 format of CCYY-MM-DD
-->
<!-- The input date string -->
<xsl:param name="datestring"/>
<!-- The current century -->
<xsl:variable name="currentcentury" select="20"/>
<!-- The separtor character used in output -->
<xsl:variable name="separator" select="string('-')" />
<!-- Break up the current string -->
<xsl:variable name="day" select="substring($datestring, 1, string-length('DD'))"/>
<xsl:variable name="month" select="substring($datestring, 1 + string-length('DD'), string-length('MM'))"/>
<xsl:variable name="year" select="substring($datestring, 1 + string-length('DD') + string-length('MM'), string-length('YY'))"/>
<!-- reformat it to ISO 8601 -->
<xsl:value-of select="$currentcentury"/>
<xsl:value-of select="$year"/>
<xsl:value-of select="$separator"/>
<xsl:value-of select="$month"/>
<xsl:value-of select="$separator"/>
<xsl:value-of select="$day"/>
</xsl:template>
<xsl:template name="reformat-date2">
<!-- the format DD/MM/YYYY, this has to be converted to the
Date string is expected to be in
ISO 8601 format of CCYY-MM-DD
-->
<!-- The input date string -->
<xsl:param name="datestring"/>
<!-- The current century -->
<xsl:variable name="currentcentury" select="20"/>
<!-- The separtor character used in output -->
<xsl:variable name="separator" select="string('-')" />
<!-- Break up the current string -->
<xsl:variable name="day" select="substring($datestring, 1, string-length('DD'))"/>
<xsl:variable name="month" select="substring($datestring, 2 + string-length('DD'), string-length('MM'))"/>
<xsl:variable name="year" select="substring($datestring, 5 + string-length('DD') + string-length('MM'), string-length('YY'))"/>
<!-- reformat it to ISO 8601 -->
<xsl:value-of select="$currentcentury"/>
<xsl:value-of select="$year"/>
<xsl:value-of select="$separator"/>
<xsl:value-of select="$month"/>
<xsl:value-of select="$separator"/>
<xsl:value-of select="$day"/>
</xsl:template>
<xsl:template name="reformat-date3">
<!-- the format YYYY-MM-DD, this has to be converted to the
Date string is expected to be in
ISO 8601 format of CCYY-MM-DD
-->
<!-- The input date string -->
<xsl:param name="datestring"/>
<!-- The current century -->
<xsl:variable name="currentcentury" select="20"/>
<!-- The separtor character used in output -->
<xsl:variable name="separator" select="string('-')" />
<!-- Break up the current string -->
<xsl:variable name="year" select="substring($datestring, 3, string-length('YY'))"/>
<xsl:variable name="month" select="substring($datestring, 2 + string-length('YYYY'), string-length('MM'))"/>
<xsl:variable name="day" select="substring($datestring,3 + string-length('YYYY') + string-length('MM'), string-length('DD'))"/>
<!-- reformat it to ISO 8601 -->
<xsl:value-of select="$currentcentury"/>
<xsl:value-of select="$year"/>
<xsl:value-of select="$separator"/>
<xsl:value-of select="$month"/>
<xsl:value-of select="$separator"/>
<xsl:value-of select="$day"/>
</xsl:template>
</xsl:stylesheet>
|
|
|