- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我通过 SoapUI 发送肥皂请求并使用 XSLT
生成 XML
回复。我的回复需要如下所示:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TXLifeResponse>
<TransType tc="1201">General Requirement Order Request</TransType>
</TXLifeResponse>
</soap:Body>
</soap:Envelope>
我可以从下面的XSLT
得到这个回复
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:acord="http://ACORD.org/Standards/Life/2"
xmlns="http://ACORD.org/Standards/Life/2">
<xsl:output method="xml" encoding="utf-8" indent="yes" />
<xsl:variable name="TransType_tc" select="//acord:TXLife/acord:TXLifeRequest//acord:TransType/@tc" />
<xsl:variable name="TransType" select="//acord:TXLife/acord:TXLifeRequest//acord:TransType" />
<xsl:template match="/">
<TXLifeResponse>
<xsl:element name="TransType">
<xsl:attribute name="tc"><xsl:value-of select="$TransType_tc"/></xsl:attribute>
<xsl:value-of select="$TransType"/>
</xsl:element>
</TXLifeResponse>
</xsl:template>
</xsl:stylesheet>
但我注意到了一个意想不到的行为。使用前<xsl:element
和<xsl:attribute>
标签,我在XSLT
中做了类似的事情:
<TransType tc="<xsl:value-of select="$TransType_tc"/>"><xsl:value-of select="$TransType"/> </TransType>
以及 SoapUI
中收到的输出是:
<TransType tc="1201">General Requirement Order Request </TransType>
任何人都可以帮助我理解为什么 <
未转换,但 >
和"
做到了。
谢谢
最佳答案
看看 syntax rules described in the XML specification :
The right angle bracket (
>
) may be represented using the string>
, and must, for compatibility, be escaped using either>
or a character reference when it appears in the string]]>
in content, when that string is not marking the end of a CDATA section.
所以,这是合法的:
<xml> > </xml>
...但在这种情况下不会:
<xml> ]]> </xml>
To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (
'
) may be represented as'
, and the double-quote character ("
) as"
.
所以,这是合法的:
<xml attr=" ' " />
...但在这种情况下不会:
<xml attr=' ' ' />
一些转义编码器开发人员过于谨慎,或者更容易概括表示,因为您不需要了解太多有关转义数据的上下文。
关于xml - 为什么 < 不转换为 < while > 和其他转义字符适当转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14345208/
这段代码在 Java 中的等价物是什么?我放了一部分,我对 I/O 部分感兴趣: int fd = open(FILE_NAME, O_WRONLY); int ret = 0; if (fd =
我正在尝试将维度为 d1,d2,d3 的张量 M[a1,a2,a3] reshape 为维度为 d2, d1*d3 的矩阵 M[a2,a1*a3]。我试过 M.reshape(d2,d1*d3) 但是
我是一名优秀的程序员,十分优秀!