我正在开发一个使用apache cocoon将XML转换为PDF的应用程序,我正在重新设计处理输入XML的XSL.
目前在XSL中,我们有这样的代码
<xsl:variable name="variable1">
<xsl:choose>
<xsl:when test="$testVariable ='1'">
<xsl:value-of select="'A'"/>
</xsl:when>
<xsl:when test="$testVariable ='1'">
<xsl:value-of select="'B'"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="variable2">
<xsl:choose>
<xsl:when test="$testVariable ='1'">
<xsl:value-of select="'X'"/>
</xsl:when>
<xsl:when test="$testVariable ='1'">
<xsl:value-of select="'Y'"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
Run Code Online (Sandbox Code Playgroud)
如果我改成它会有用吗?
<xsl:variable name="variable1"/>
<xsl:variable name="variable2"/>
<xsl:choose>
<xsl:when test="$testVariable ='1'">
<xsl:variable name="variable1" select="'A'">
<xsl:variable name="variable2" select="'X'">
</xsl:when>
<xsl:when test="$testVariable ='2'">
<xsl:variable name="variable1" select="'B'">
<xsl:variable name="variable2" select="'Y'">
</xsl:when>
</xsl:choose>
Run Code Online (Sandbox Code Playgroud) 我正在学习C++形式Thinking in C++ V1.我遇到了一个证明继承的例子.在这里
#include <iostream>
class Instrument{
public:
virtual void play(){
std::cout<<"instrument::play()";
}
};
class Wind: public Instrument{
public:
void play(){
std::cout<<"Wind::play()";
}
};
void tune(Instrument& i){
i.play();
}
int _tmain(int argc, _TCHAR* argv[])
{
Wind flute;
tune(flute);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这Wind::play()在控制台上输出.
但是,如果我将方法'tune'更改为
void tune(Instrument i){
i.play();
}
Run Code Online (Sandbox Code Playgroud)
输出会 instrument::play()
由于添加了'&'以便传递长笛的参考而不是副本,为什么程序输出instrument::play()而不是Wind::play()?