Reputation: 1
I have the below input xml and as i am working in xsl transformation using xalan api now the below is the xml
<?xml version="1.0" encoding="UTF-8"?>
<Report xmlns:fpml="http://www.fpml.org/FpML-5/confirmation" xmlns="http://www.eurexchange.com/EurexIRSFullInventoryReport" name="CB202 Full Inventory Report">
<reportNameGrp>
<CM>
<acctTypGrp name="A1">
<ProductType name="OIS">
<currTypCod value="EUR">
<rateIndex name="EONIA">
<rateIndexTenor name="1D">
<idxSource>EONIA</idxSource>
<CCPTradeId id="612822">
<fpml:dataDocument fpmlVersion="5-0">
<fpml:trade>
<fpml:tradeHeader>
<fpml:partyTradeIdentifier>
<fpml:partyReference href="CPTY_612822"></fpml:partyReference>
<fpml:tradeId tradeIdScheme=""></fpml:tradeId>
</fpml:partyTradeIdentifier>
<fpml:partyTradeIdentifier>
<fpml:partyReference href="PO_612822"></fpml:partyReference>
<fpml:accountReference href="ACC_612822"></fpml:accountReference>
<fpml:tradeId tradeIdScheme="">9786042-2</fpml:tradeId>
<fpml:versionedTradeId>
<fpml:tradeId tradeIdScheme="">612822</fpml:tradeId>
<fpml:version>1</fpml:version>
</fpml:versionedTradeId>
</fpml:partyTradeIdentifier>
<fpml:tradeDate>2013-05-21</fpml:tradeDate>
<fpml:clearedDate>2013-11-13</fpml:clearedDate>
</fpml:tradeHeader>
<fpml:swap>
<fpml:swapStream id="fixedLeg_612822">
<fpml:payerPartyReference href="CPTY_612822"></fpml:payerPartyReference>
<fpml:receiverPartyReference href="PO_612822"></fpml:receiverPartyReference>
<fpml:calculationPeriodDates id="fixedLegCalcPeriodDates_612822">
<fpml:effectiveDate>
<fpml:unadjustedDate>2013-05-23</fpml:unadjustedDate>
<fpml:dateAdjustments>
<fpml:businessDayConvention>NONE</fpml:businessDayConvention>
</fpml:dateAdjustments>
</fpml:effectiveDate>
<fpml:terminationDate>
<fpml:unadjustedDate>2015-05-23</fpml:unadjustedDate>
<fpml:dateAdjustments>
<fpml:businessDayConvention>MODFOLLOWING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
</fpml:dateAdjustments>
</fpml:terminationDate>
<fpml:calculationPeriodDatesAdjustments>
<fpml:businessDayConvention>MODFOLLOWING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
</fpml:calculationPeriodDatesAdjustments>
<fpml:calculationPeriodFrequency>
<fpml:periodMultiplier>1</fpml:periodMultiplier>
<fpml:period>Y</fpml:period>
<fpml:rollConvention>23</fpml:rollConvention>
</fpml:calculationPeriodFrequency>
</fpml:calculationPeriodDates>
<fpml:paymentDates>
<fpml:calculationPeriodDatesReference href="fixedLegCalcPeriodDates_612822"></fpml:calculationPeriodDatesReference>
<fpml:paymentFrequency>
<fpml:periodMultiplier>1</fpml:periodMultiplier>
<fpml:period>Y</fpml:period>
</fpml:paymentFrequency>
<fpml:payRelativeTo>CalculationPeriodEndDate</fpml:payRelativeTo>
<fpml:paymentDaysOffset>
<fpml:periodMultiplier>1</fpml:periodMultiplier>
<fpml:period>D</fpml:period>
<fpml:dayType>Business</fpml:dayType>
</fpml:paymentDaysOffset>
<fpml:paymentDatesAdjustments>
<fpml:businessDayConvention>MODFOLLOWING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
</fpml:paymentDatesAdjustments>
</fpml:paymentDates>
<fpml:calculationPeriodAmount>
<fpml:calculation>
<fpml:notionalSchedule>
<fpml:notionalStepSchedule>
<fpml:initialValue>100000000.00</fpml:initialValue>
<fpml:currency>EUR</fpml:currency>
</fpml:notionalStepSchedule>
</fpml:notionalSchedule>
<fpml:fixedRateSchedule>
<fpml:initialValue>0.01200000</fpml:initialValue>
</fpml:fixedRateSchedule>
<fpml:dayCountFraction>ACT/360</fpml:dayCountFraction>
</fpml:calculation>
</fpml:calculationPeriodAmount>
</fpml:swapStream>
<fpml:swapStream id="floatingLeg_612822">
<fpml:payerPartyReference href="PO_612822"></fpml:payerPartyReference>
<fpml:receiverPartyReference href="CPTY_612822"></fpml:receiverPartyReference>
<fpml:calculationPeriodDates id="floatingLegCalcPeriodDates_612822">
<fpml:effectiveDate>
<fpml:unadjustedDate>2013-05-23</fpml:unadjustedDate>
<fpml:dateAdjustments>
<fpml:businessDayConvention>NONE</fpml:businessDayConvention>
</fpml:dateAdjustments>
</fpml:effectiveDate>
<fpml:terminationDate>
<fpml:unadjustedDate>2015-05-23</fpml:unadjustedDate>
<fpml:dateAdjustments>
<fpml:businessDayConvention>MODFOLLOWING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
</fpml:dateAdjustments>
</fpml:terminationDate>
<fpml:calculationPeriodDatesAdjustments>
<fpml:businessDayConvention>MODFOLLOWING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
</fpml:calculationPeriodDatesAdjustments>
<fpml:calculationPeriodFrequency>
<fpml:periodMultiplier>1</fpml:periodMultiplier>
<fpml:period>Y</fpml:period>
<fpml:rollConvention>23</fpml:rollConvention>
</fpml:calculationPeriodFrequency>
</fpml:calculationPeriodDates>
<fpml:paymentDates>
<fpml:calculationPeriodDatesReference href="floatingLegCalcPeriodDates_612822"></fpml:calculationPeriodDatesReference>
<fpml:paymentFrequency>
<fpml:periodMultiplier>1</fpml:periodMultiplier>
<fpml:period>Y</fpml:period>
</fpml:paymentFrequency>
<fpml:payRelativeTo>CalculationPeriodEndDate</fpml:payRelativeTo>
<fpml:paymentDaysOffset>
<fpml:periodMultiplier>1</fpml:periodMultiplier>
<fpml:period>D</fpml:period>
<fpml:dayType>Business</fpml:dayType>
</fpml:paymentDaysOffset>
<fpml:paymentDatesAdjustments>
<fpml:businessDayConvention>MODFOLLOWING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
</fpml:paymentDatesAdjustments>
</fpml:paymentDates>
<fpml:resetDates id="floatingLegresetDates_612822">
<fpml:calculationPeriodDatesReference href="floatingLegCalcPeriodDates_612822"></fpml:calculationPeriodDatesReference>
<fpml:resetRelativeTo>CalculationPeriodEndDate</fpml:resetRelativeTo>
<fpml:fixingDates>
<fpml:periodMultiplier>0</fpml:periodMultiplier>
<fpml:period>D</fpml:period>
<fpml:businessDayConvention>PRECEDING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
<fpml:dateRelativeTo href="floatingLegresetDates_612822"></fpml:dateRelativeTo>
</fpml:fixingDates>
<fpml:resetFrequency>
<fpml:periodMultiplier>1</fpml:periodMultiplier>
<fpml:period>Y</fpml:period>
</fpml:resetFrequency>
<fpml:resetDatesAdjustments>
<fpml:businessDayConvention>MODFOLLOWING</fpml:businessDayConvention>
<fpml:businessCenters>
<fpml:businessCenter>EUTA</fpml:businessCenter>
</fpml:businessCenters>
</fpml:resetDatesAdjustments>
</fpml:resetDates>
<fpml:calculationPeriodAmount>
<fpml:calculation>
<fpml:notionalSchedule>
<fpml:notionalStepSchedule>
<fpml:initialValue>100000000.00</fpml:initialValue>
<fpml:currency>EUR</fpml:currency>
</fpml:notionalStepSchedule>
</fpml:notionalSchedule>
<fpml:floatingRateCalculation>
<fpml:floatingRateIndex>EUR-EONIA-OIS-COMPOUND</fpml:floatingRateIndex>
</fpml:floatingRateCalculation>
<fpml:dayCountFraction>ACT/360</fpml:dayCountFraction>
</fpml:calculation>
</fpml:calculationPeriodAmount>
</fpml:swapStream>
</fpml:swap>
<fpml:documentation>
<fpml:masterAgreement>
<fpml:masterAgreementType masterAgreementTypeScheme="">ISDA</fpml:masterAgreementType>
</fpml:masterAgreement>
<fpml:contractualDefinitions>ISDA2006</fpml:contractualDefinitions>
</fpml:documentation>
</fpml:trade>
<fpml:party id="CPTY_612822">
<fpml:partyId>EUREX</fpml:partyId>
<fpml:partyName>EUREX</fpml:partyName>
</fpml:party>
<fpml:party id="PO_612822">
<fpml:partyId>BOSLO</fpml:partyId>
<fpml:partyName>plc.</fpml:partyName>
</fpml:party>
<fpml:account id="ACC_612822">
<fpml:accountId>BOSLO_A1</fpml:accountId>
<fpml:accountBeneficiary href="PO_612822"></fpml:accountBeneficiary>
</fpml:account>
</fpml:dataDocument>
<novDateTime>2013-11-13 17:50:44.773</novDateTime>
</CCPTradeId>
</rateIndexTenor>
</rateIndex>
</currTypCod>
</ProductType>
</acctTypGrp>
</CM>
</reportNameGrp>
</Report>
as you can see that from the above xml i am tring to read the value of tradeid scheme parameter that is 9786042-2 now i want to put a check that is value does not exixts in trade id scheme paremeter then null is dispalyed so for that i have come up with below xsl , but still for the cses where tradeid scheme paramtere value is not there null is not updated in those cases please advise how to populate null for those cases.
<!-- Main template starts -->
<xsl:template match="/eur:Report">
<EurexMessage>
<EurexFlows>
<xsl:apply-templates select=".//eur:rateIndexTenor" />
<!-- select="eur:reportNameGrp/eur:CM/eur:acctTypGrp/eur:ProductType/eur:currTypCod/eur:rateIndex/eur:rateIndexTenor"
/> -->
</EurexFlows>
</EurexMessage>
</xsl:template>
<!-- sub template starts -->
<xsl:template match="eur:rateIndexTenor">
<xsl:for-each select="eur:CCPTradeId">
<EurexMessageObject>
<!-- ####***** contact id is nul not displayd ****##### ----->
<ContractID>
<xsl:choose>
<xsl:when test="fpml:dataDocument/*/*/fpml:partyTradeIdentifier/fpml:tradeId/@tradeIdScheme !=' '">
<xsl:value-of
select="fpml:dataDocument/*/*/fpml:partyTradeIdentifier[2]/fpml:tradeId" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'null'" />
</xsl:otherwise>
</xsl:choose>
</ContractID>
</EurexMessageObject>
</xsl:for-each>
</xsl:template>
Upvotes: 0
Views: 197
Reputation: 101748
The expression something != ' '
will produce
true
if there are any something
s that are not equal to ' '
(a single space)false
if all of the something
s are equal to ' '
false
if there are no something
sIn your case, both of the something
s are equal to ''
(empty string). Since both of these are unequal to ' '
, the result here is true
.
If I am understanding correctly, you want to output the tradeId where the tradeIdScheme is not blank or whitespace, or output null
if there is no such tradeId.
If so, this should do it:
<ContractID>
<xsl:variable name="foundTradeId"
select="fpml:dataDocument/*/*/fpml:partyTradeIdentifier/fpml:tradeId
[normalize-space(@tradeIdScheme)]" />
<xsl:value-of select="$foundTradeId" />
<xsl:if test="not($foundTradeId)">null</xsl:if>
</ContractID>
Upvotes: 1