以下xsl的输出xml有换行符。我需要在下面的xsl映射中删除cteDadosMsg节点中的换行符。
XSL地图
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap12:Header>
<cteCabecMsg xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CteConsulta">
<cUF><xsl:value-of select="substring(/n0:ConsultaCT/n0:chCTe,1,2)"/></cUF>
<versaoDados>2.00</versaoDados>
</cteCabecMsg>
</soap12:Header>
<soap12:Body>
<cteDadosMsg xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CteConsulta">
<consSitCTe xmlns="http://www.portalfiscal.inf.br/cte" versao="3.10">
<tpAmb><xsl:value-of select="/n0:ConsultaCT/n0:tpAmb"/></tpAmb>
<xServ>CONSU</xServ>
<chCTe><xsl:value-of select="/n0:ConsultaCT/n0:chCTe"/></chCTe>
</consSitCTe>
</cteDadosMsg>
</soap12:Body>
</soap12:Envelope>
</xsl:template>
输出
答案 0 :(得分:0)
我没有尝试过它,看看它是否有效,因为我没有你的XML,但我认为你得到换行的原因是你使用静态字符串2.00和CONSU和静态字符串带有换行符。您可能想尝试通过用xsl:text替换这些静态字符串来查看是否仍然获得换行符... 有点像
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap12:Header>
<cteCabecMsg xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CteConsulta">
<cUF><xsl:value-of select="substring(/n0:ConsultaCT/n0:chCTe,1,2)"/></cUF>
<versaoDados><xsl:text>2.00</xsl:text></versaoDados>
</cteCabecMsg>
</soap12:Header>
<soap12:Body>
<cteDadosMsg xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CteConsulta">
<consSitCTe xmlns="http://www.portalfiscal.inf.br/cte" versao="3.10">
<tpAmb><xsl:value-of select="/n0:ConsultaCT/n0:tpAmb"/></tpAmb>
<xServ><xsl:text>CONSU</xsl:text></xServ>
<chCTe><xsl:value-of select="/n0:ConsultaCT/n0:chCTe"/></chCTe>
</consSitCTe>
</cteDadosMsg>
</soap12:Body>
</soap12:Envelope>
</xsl:template>