![]() |
|
|
|||||||
![]() |
XML - xsl:template not getting matched |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hello:
I am stumped on what I belive to be a namespace issue. The XSL, source XML, and result XML are included below. The problem is that the template to match "getBalances" is never invoked by the apply-templates. If I remove the default namespace in the source XML's getBalance element, the problem goes away and the template is matched. I spent several hours searching the newsgroups but in vain. Any help would be appreciated. Thanks ==xsl== <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://city.com/ziggy/"> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="SOAP-ENV:Envelope"> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://city.com/ziggy/" xmlns <xsl:apply-templates select="SOAP-ENV:Header"/> <xsl:apply-templates select="SOAP-ENV:Body"/> </SOAP-ENV:Envelope> </xsl:template> <xsl:template match="SOAP-ENV:Header"> <!-- copy children without any modifications --> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="SOAP-ENV:Body"> <SOAP-ENV:Body> <xsl:apply-templates select="getBalances"/> </SOAP-ENV:Body> </xsl:template> <xsl:template match="getBalances"> <xsl:text> HERE ! </xsl:text> </xsl:template> </xsl:stylesheet> ==source xml== <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns <SOAP-ENV:Header/> <SOAP-ENV:Body> <getBalances xmlns="http://city.com/ziggy/">123456</getBalances> </SOAP-ENV:Body> </SOAP-ENV:Envelope> ==result xml== <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:impl="http://city.com/ziggy/" xmlns <SOAP-ENV:Header/> <SOAP-ENV:Body/> </SOAP-ENV:Envelope> tentstitcher@gmail.com |
|
|
|
|
#2 |
|
Posts: n/a
|
wrote:
> apply-templates. If I remove the default namespace in the source XML's > getBalance element, the problem goes away and the template is matched. Use a prefixed name such as ziggy:getBalance, and add a declaration for that prefix to your stylesheet. XSLT is namespace-aware. You have to work with that. It is possible to achieve namespace-insensitive matching via predicates, but it's gawdawful ugly and emphatically the wrong thing to do. -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry |
|
|
|
#3 |
|
Posts: n/a
|
Joe,
Thanks for the quick response. It seems to be working fine after I applied your suggested fix. Thanks Joe Kesselman wrote: > wrote: > > apply-templates. If I remove the default namespace in the source XML's > > getBalance element, the problem goes away and the template is matched. > > Use a prefixed name such as ziggy:getBalance, and add a declaration for > that prefix to your stylesheet. > > XSLT is namespace-aware. You have to work with that. It is possible to > achieve namespace-insensitive matching via predicates, but it's > gawdawful ugly and emphatically the wrong thing to do. > > -- > () ASCII Ribbon Campaign | Joe Kesselman > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry |
|