Below is the xslt I wrote..It works perfectly in xml spy and it was working perfectly previously.All of a sudden i this is not working..its directly going to otherwise condition and taking the value even though "when" function value is coming...Is there any change made in this version???Any help on this?
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:SCI="http://abc.xsd" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:param name="App" select="''"/> <xsl:template match="/"> <soap:Envelope> <soap:Body> <xsl:element name="SCI:abc"> <xsl:element name="SCI:xyz"> <xsl:choose> <xsl:when test="//xyz/App"> <xsl:element name="App"> <xsl:value-of select="//xyz/App"/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:element name="App"> <xsl:value-of select="$App"/> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:element> </xsl:element> </soap:Body> </soap:Envelope> </xsl:template> </xsl:stylesheet>
It works for me.
when I pass in a document like:
<xyz> <App>foo</App> </xyz>
...I get the expected output, which is :
<soap:Envelope xmlns:SCI="http://abc.xsd" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body> <SCI:abc> <SCI:xyz> <App>foo</App> </SCI:xyz> </SCI:abc> </soap:Body> </soap:Envelope>
And when I pass in a source document that does not have the //xyz/App element, I get the result of the xsl:otherwise branch.
See attached for a working example.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |