We help IT Professionals succeed at work.

How to strip - and # using xslt

sridhar R
sridhar R asked
on
145 Views
Last Modified: 2019-01-11
Hell Experts

I Have an xml to xml conversion where i need to copy entire xml As it is but need to strip hypen from bank account numbers and # from Address.

To explain it clearly attached is the source xml. I want the target to be exactly same except that i want to avoid # in field StrtNm (address field) and - in  <Othr/Id>618-401517-001</Id></Othr> (bank account field).

Bottom line is Street address from below part of xml has #. I want that to be stripped

 <PstlAdr>
                  <StrtNm>3 Killiney Road, #07-01 Winsland House I</StrtNm>
                  <PstCd>239519</PstCd>
                  <TwnNm>Singapore</TwnNm>
                  <Ctry>SG</Ctry>
  </PstlAdr>

And bank account no (618-401517-001) form below part of xml has '-' I want that to be stripped.

<CdtrAcct>
               <Id>
                  <Othr>
                     <Id>618-401517-001</Id>
                  </Othr>
               </Id>
               <Tp>
                  <Cd>SACC</Cd>
               </Tp>
               <Ccy>SGD</Ccy>
               <Nm>Winsland Investment PTE LTD</Nm>
            </CdtrAcct>


Below is the code i am using at them moment to copy xml as it is. Can any one please update below code to accomplish above.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wd="urn:com.workday/bsvc"
    xmlns:etv="urn:com.workday/etv" exclude-result-prefixes="xs" version="2.0">
    <xsl:output method="xml"  indent="yes"/>
    <!-- identity transform -->
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node() "/>
        </xsl:copy>
    </xsl:template>
   
    <xsl:template match="text()">
        <xsl:value-of select="normalize-space()" />
    </xsl:template>
 </xsl:stylesheet>


Thanks in advance for help,
Sridar
SG_ACH_01_09.pgp
Comment
Watch Question

Information Architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi Geert,

Thanks a ton for help. this code is working perfectly.

Best Regards,
Sridhar
Gertone (Geert Bormans)Information Architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.