Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2011, 10:31 PM
Registered User
 
Join Date: Aug 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default XML to XML using xslt

Hi i need to convert the xml to xml

inut xml is

<associds>
<associd>
<associdentifierValue>12345</associdentifierValue>
<associdtype>AAA</associdtype>
</associd>
<associd>
<associdentifierValue>24688</associdentifierValue>
<associdtype>BBB</associdtype>
</associd>
</associds>

expected out is if child element value is BBB - i need to remove the whole element in associd.

<associds>
<associd>
<associdentifierValue>12345</associdentifierValue>
<associdtype>AAA</associdtype>
</associd>
</associds>


XSLT is given below, but it is removing only associdtype is BBB , i need to remove entire parent. i need as soon as possible.. Thanks in advance.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
extension-element-prefixes="dp"
exclude-result-prefixes="dp">

<xsl:output method="xml"/>

<!-- Confidential#1 access-denied fields-->

<xsl:template match="associdtype[.='BBB']">
</xsl:template>
<!-- Rest of the response fields are allowed to pass from service output -->

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
 
Old August 18th, 2011, 02:25 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Code:
<xsl:template match="associd[associdtype='BBB']">
<!-- do nothing -->
</xsl:template>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
dandagopi (August 18th, 2011)
 
Old August 18th, 2011, 10:53 PM
Registered User
 
Join Date: Aug 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thanks

Thanks it worked.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding xml-html transformation of an xml string using xslt and javascript suprakash444 XSLT 1 January 12th, 2009 01:23 AM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 04:26 PM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 08:48 AM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.