Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] removing nodes to parent based on all child nodes not having text value

From: "Cindy Lard" <Cindy.Lard@----------->
To:
Date: 12/5/2008 3:34:00 PM
Thank you all so much for your help.  The example data was not correct as you
pointed out.  The input and desired output should have been as follows:

Input

<Registration>
     <UserName>DID1901</UserName>
     <ActivityType>25</ActivityType>
     <ActivityDate>2008-10-30T12:10:26</ActivityDate>
     <RegistrationCounty>19</RegistrationCounty>
     <Registrants>
          <Registrant>
               <Entity>
                    <Individual>
                         <Prefix/>
                         <FirstName/>
                         <LastName/>
                         <Middle/>
                         <Suffix/>
                    </Individual>
                    <Business>
                         <MailingAddress>
                               <Address>
                                    <MailingAddressType/>
                                    <MailingAddressLine1>123
Street</MailingAddressLine1>
                                    <MailingAddressLine2/>
                               </Address>
                         </MailingAddress>
                    </Business>
               </Entity>
          </Registrant>
     </Registrants>
</Registration>



Output

<Registration>
     <UserName>DID1901</UserName>
     <ActivityType>25</ActivityType>
     <ActivityDate>2008-10-30T12:10:26</ActivityDate>
     <RegistrationCounty>19</RegistrationCounty>
     <Registrants>
          <Registrant>
               <Entity>
                    <Business>
                         <MailingAddress>
                               <Address>
                                    <MailingAddressType/>
                                    <MailingAddressLine1>123
Street</MailingAddressLine1>
                                    <MailingAddressLine2/>
                               </Address>
                         </MailingAddress>
                    </Business>
               </Entity>
          </Registrant>
     </Registrants>
</Registration>


In this case there only needs to be either <Individual> or <Business> under
<Entity>.  Either the registration is for an individual or business. Both
should not exist in the same file.  Because the business registration
information is being pulled from a legacy system certain information required
in the XML may not be available, such as <MailingAddressType/> and
<MailingAddressLine2/> as in the preceding example.  However, if any
descendant element of a child has a text value such as
<MailingAddressLine1>123 Street</MailingAddressLine1> it's parent and siblings
all need to be copied even if those siblings have no text value the nodes need
to be copied.  If no descendant elements have a text value as is the case with
<Individual> that node and all descendant nodes of that element need to be
stripped out.  Wow, I hope that wasn't too confusing.

All the templates I have used thus far will strip out any element with no text
value, which removes the needed (dare I say required) elements of
<MailingAddressType/> and <MailingAddressLine2/> under the <Address> element.


I really appreciate all the help!!!


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent