Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: match attribute for xsl:template [Thread Next] Re: match attribute for xsl:templateTo: NULL Date: 11/8/2005 10:18:00 AM Hi, Although i'm unable to test other dev tools (MSXML or Xalan) i just did with .Net 1.1 The .Net XSLT class chokes on the compilation of these XSLT's. I tried locating some info @ W3C but couldn't find this specific topic. (I might have missed it). I remember doing something similar, but the first post obviously doesn't work in .Net (not sure in other parsers). I couldn't resist 'trying to solve the functionality question' and this is what i came up with: <?xml version="1.0" encoding="UTF-8" ?> <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" /> <xsl:param name="ElementName" /> <xsl:param name="NamespaceURI" /> <xsl:template match="/"> <xsl:element name="root"> <xsl:apply-templates select="child::*" /> </xsl:element> </xsl:template> <xsl:template match="node()"> <xsl:variable name="ElemsToProcess" select="*[local-name()=$ElementName and namespace-uri()=$NamespaceURI]" /> <xsl:if test="count($ElemsToProcess) > 0"> <xsl:call-template name="doit"> <xsl:with-param name="ElemsToProcess" select="$ElemsToProcess" /> </xsl:call-template> </xsl:if> <xsl:apply-templates select="child::*" /> </xsl:template> <xsl:template name="doit"> <xsl:param name="ElemsToProcess" /> <xsl:for-each select="$ElemsToProcess"> <xsl:element name="output"> <xsl:text>The element name = </xsl:text> <xsl:value-of select="local-name()" /> <xsl:text> </xsl:text> <xsl:text>The element resides in namespace = </xsl:text> <xsl:value-of select="namespace-uri()" /> <xsl:text> </xsl:text> <xsl:text>The element has the content = </xsl:text> <xsl:value-of select="." /> <xsl:text> </xsl:text> </xsl:element> </xsl:for-each> </xsl:template> <xsl:template match="text()"></xsl:template> </stylesheet> This template accepts a "ElementName" & "NamespaceURI" and will execute the template called "doit" for each one found. The real question becomes.. what is the intended functionality for this? Hope this helps, Marvin Smit On Mon, 07 Nov 2005 21:13:30 +0000, Peter Flynn <peter.nosp@m...> wrote: >Oleg Tkachenko [MVP] wrote: > >> Marvin Smit wrote: >> >>> you could do the following approach (with parameters): >>> >>> <xsl:param name='param1' /> >>> <xsl:param name='param2' /> >>> >>> <xsl:template match="*[local-name()=$param1 and >>> namespace-uri()=$param2]" /> >> >> No, variable references cannot be used in match, even within a >> predicate. > >Parameter references can: > ><?xml version="1.0" encoding="ISO-8859-1"?> ><doc> > <foo>bar</foo> > <bar>foo</bar> ></doc> > ><?xml version="1.0" encoding="iso-8859-1"?> ><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:output method="html"/> > <xsl:param name="ename"/> > > <xsl:template match="*[name()=$ename]"> > <blort> > <xsl:value-of select="."/> > </blort> > </xsl:template> > ></xsl:stylesheet> > >///Peter | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
