Quantcast
Channel: SCN : Unanswered Discussions - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 6719

Unable to remove empty nodes from Message

$
0
0

Hello,

 

I have message format like this:

 

<?xml version="1.0" encoding="UTF-8"?>

<ns1:Enrollment xmlns:ns1="http://pac.bluecross.ca/Common/Types" xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance">

  <ns1:Policies>

  <ns1:Policy>

  <ns1:Code>11140</ns1:Code>

  <ns1:Certificates>

  <ns1:Certificate>

  <ns1:Class>

  <ns1:Code>1</ns1:Code>

  <ns1:EffectiveDate>2009-05-09T00:00:00</ns1:EffectiveDate>

  </ns1:Class>

  <ns1:CurrentEmploymentRecord>

  <ns1:HoursWorked>20</ns1:HoursWorked>

  <ns1:Type>FullTimeHourly</ns1:Type>

  </ns1:CurrentEmploymentRecord>

  <ns1:CurrentIncome>

  <ns1:Amount>5000</ns1:Amount>

  <ns1:EffectiveDate>2014-01-01T00:00:00</ns1:EffectiveDate>

  <ns1:Frequency>BiWeekly</ns1:Frequency>

  <ns1:Type>Salary</ns1:Type>

  </ns1:CurrentIncome>

  <ns1:Dependents>

  <ns1:CoveredLife>

  <ns1:CoverageDeclines/>

  <ns1:CoveredLifeHolder>

  <ns1:Contacts/>

  <ns1:DefaultAddress/>

  <ns1:DefaultEmail/>

  <ns1:DefaultPhone/>

  <ns1:PreferredLanguage>ENG</ns1:PreferredLanguage>

  <ns1:DateOfBirth>2009-05-09T00:00:00</ns1:DateOfBirth>

  <ns1:FirstName>Sean Louis</ns1:FirstName>

  <ns1:LastName>Carrier</ns1:LastName>

  <ns1:***>Male</ns1:***>

  </ns1:CoveredLifeHolder>

  <ns1:DependentCategory>Child</ns1:DependentCategory>

  <ns1:DependentSubCategory>Minor</ns1:DependentSubCategory>

  <ns1:Number>03</ns1:Number>

  </ns1:CoveredLife>

  </ns1:Dependents>

  <ns1:Division>

  <ns1:Code>1</ns1:Code>

  <ns1:EffectiveDate>2009-05-09T00:00:00</ns1:EffectiveDate>

  </ns1:Division>

  <ns1:FamilyCategory>Family</ns1:FamilyCategory>

  <ns1:HealthCareSpendingAccountInformation/>

  <ns1:HireDate>2002-07-15T00:00:00</ns1:HireDate>

  <ns1:InsuredCoveredLife>

  <ns1:CoverageDeclines/>

  <ns1:CoveredLifeHolder>

  <ns1:Contacts/>

  <ns1:DefaultAddress ns2:type="ns1:CanadianAddress">

  <ns1:City>Surrey</ns1:City>

  <ns1:Country>CA</ns1:Country>

  <ns1:Line1>98 - 10752 Guildford Drive</ns1:Line1>

  <ns1:PostalCode>V3R 1W6</ns1:PostalCode>

  <ns1:Province>BC</ns1:Province>

  </ns1:DefaultAddress>

  <ns1:DefaultEmail>

  <ns1:CorrespondenceMethod>Email</ns1:CorrespondenceMethod>

  <ns1:CorrespondenceType>Home</ns1:CorrespondenceType>

  <ns1:Data>someone@burnaby.ca</ns1:Data>

  </ns1:DefaultEmail>

  <ns1:DefaultPhone>

  <ns1:CorrespondenceMethod>Telephone</ns1:CorrespondenceMethod>

  <ns1:CorrespondenceType>Home</ns1:CorrespondenceType>

  <ns1:Data>(001)(555)555-5555</ns1:Data>

  </ns1:DefaultPhone>

  <ns1:PreferredContact>Mail</ns1:PreferredContact>

  <ns1:PreferredLanguage>ENG</ns1:PreferredLanguage>

  <ns1:DateOfBirth>1974-02-07T00:00:00</ns1:DateOfBirth>

  <ns1:FirstName>Krisztina</ns1:FirstName>

  <ns1:LastName>Carrier</ns1:LastName>

  <ns1:***>Female</ns1:***>

  </ns1:CoveredLifeHolder>

  <ns1:EffectiveDate>2007-06-01T00:00:00</ns1:EffectiveDate>

  <ns1:Status>Inforce</ns1:Status>

  </ns1:InsuredCoveredLife>

  <ns1:JobTitle>Recreation Leader 2</ns1:JobTitle>

  <ns1:Number>000050</ns1:Number>

  <ns1:Plan>

  <ns1:Code>9027380101</ns1:Code>

  <ns1:EffectiveDate>2009-05-09T00:00:00</ns1:EffectiveDate>

  </ns1:Plan>

  <ns1:RegionalAdministration>

  <ns1:Country>CA</ns1:Country>

  <ns1:ProvinceOfBilling>BC</ns1:ProvinceOfBilling>

  </ns1:RegionalAdministration>

  <ns1:Section/>

  </ns1:Certificate>

  </ns1:Certificates>

  </ns1:Policy>

 

Here is my XSL for removing empty nodes:

 

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:strip-space elements="*"/>

    <xsl:template match="node()|@*">

        <xsl:copy>

            <xsl:apply-templates select="node()|@*"/>

        </xsl:copy>

    </xsl:template>

    <xsl:template match="*[not(@*) and not(*) and (not(text()) or .=-1)]"/>

</xsl:stylesheet>

 

 

This program removes all empty nodes except below nodes:

 

<ns1:Dependents>

  <ns1:CoveredLife>

  <ns1:CoverageDeclines/>

  <ns1:CoveredLifeHolder>

  <ns1:Contacts/>

  <ns1:DefaultAddress/>

  <ns1:DefaultEmail/>

  <ns1:DefaultPhone/>

 

Please throw some ideas.

 

Thank you

John


Viewing all articles
Browse latest Browse all 6719

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>