Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XSL HELP!! >Thread Next - Re: XSL HELP!! Re: XSL HELP!!To: NULL Date: 5/28/2008 6:43:00 AM Martin, Thanks for your help. I have one question on this. Is it possible to have a variable name for the template "match"?. The reason I am asking this is: The node "UnixEmail" is NOT static and may change dynamically, for example, it could be even the "Domain" node.. So, is it possible to have something like this n XSL:? <xsl:template match=@DynamicNodeName> Thanks, Ganesh "Martin Honnen" wrote: > Ganesh Muthuvelu wrote: > > > Using a XSL template, how to get ONLY the node UnixEmail with attribute ID > > value = 4 PLUS ALL OTHER NODES (such as <Organization>) > > Here is a sample stylesheet: > > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:param name="id" select="4"/> > > <xsl:output method="xml"/> > > <xsl:template match="@* | node()"> > <xsl:copy> > <xsl:apply-templates select="@* | node()"/> > </xsl:copy> > </xsl:template> > > <xsl:template match="UnixEmail"> > <xsl:if test="@ID = $id"> > <xsl:copy-of select="."/> > </xsl:if> > </xsl:template> > > </xsl:stylesheet> > > > Result with your XML sample is > > <p1:Domains_and_Emails xmlns:p1="LDAP"> > <Organization>ABCD</Organization> > <Radius Suspended="false" ID="1" Platform_Id="7" > ObjectClass="radiusprofile"> > <Common_Name>OptiUser</Common_Name> > <radiusProfileDn>cn=dialup,ou=radiusprofiles,o=ABCD</radiusProfileDn> > </Radius> > <Domain Suspended="false" ID="2" Platform_Id="7"> > <Organization_Unit>domains</Organization_Unit> > <domain_name>xyztel.com</domain_name> > > > > <UnixEmail Suspended="false" ID="4" Platform_Id="7" > ObjectClass="radiusprofile,posixAccount,CourierMailAccount"> > <uid attributeId="1">jeff</uid> > <Password attributeId="4">xyz</Password> > <EmailAccount>jeff@x...</EmailAccount> > </UnixEmail> > > > > </Domain> > > </p1:Domains_and_Emails> > > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
