我试图将通过迭代获得的值放入CDATA字段。 在XSLT中有可能这样做吗? 我的XML文件: 我的XSL文件: 因此,基本上我希望时间戳字段值位于CDATA字段中,以便最终基本上看起来像这样: 谢谢你的帮助! ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我的 XSL 文件中有这个片段:
<script type="text/javascript">
<![CDATA[
function clearSelection() {
if (document.getSelection) { // for all new browsers (IE9+, Chrome, Firefox)
document.getSelection().removeAllRanges();
document.getSelection().addRange(document.createRange());
console.log("document.getSelection");
} else if (window.getSelection) { // equals with the document.getSelection (MSDN info)
if (window.getSelection().removeAllRanges) { // for all new browsers (IE9+, Chrome, Firefox)
window.getSelection().removeAllRanges();
window.getSelection().addRange(document.createRange());
console.log("window.getSelection.removeAllRanges");
} else if (window.getSelection().empty) { // Chrome supports this as well
window.getSelection().empty();
console.log("window.getSelection.empty");
}
} else if (document.selection) { // IE8-
document.selection.empty();
console.log("document.selection.empty");
}
}
function CopyToClipboard(containerid) {
clearSelection();
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
document.execCommand("copy");
alert("The assignment slip has been copied, now paste into an email")
}
}
]]>
</script>
看到当前有 static 文本的alert
行了吗? 我想将该文本字符串替换为以下值:
<xsl:value-of select="$Translations/msa:Translations/msa:*[local-name() = $LangCode]/msa:AlertText"/>
我只使用了CDATA
,因为我厌倦了 Visual Studio 重新格式化我的文档并将所有 Javascript 左对齐为一个白色块。
我已经设法通过简单地拆分我的CDATA
来做到这一点:
<script type="text/javascript">
<![CDATA[
function clearSelection() {
if (document.getSelection) { // for all new browsers (IE9+, Chrome, Firefox)
document.getSelection().removeAllRanges();
document.getSelection().addRange(document.createRange());
console.log("document.getSelection");
} else if (window.getSelection) { // equals with the document.getSelection (MSDN info)
if (window.getSelection().removeAllRanges) { // for all new browsers (IE9+, Chrome, Firefox)
window.getSelection().removeAllRanges();
window.getSelection().addRange(document.createRange());
console.log("window.getSelection.removeAllRanges");
} else if (window.getSelection().empty) { // Chrome supports this as well
window.getSelection().empty();
console.log("window.getSelection.empty");
}
} else if (document.selection) { // IE8-
document.selection.empty();
console.log("document.selection.empty");
}
}
function CopyToClipboard(containerid) {
clearSelection();
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
document.execCommand("copy");
alert("]]><xsl:value-of select="$Translations/msa:Translations/msa:*[local-name() = $LangCode]/msa:AlertText"/><![CDATA[")
}
}
]]>
</script>
请让我知道是否有更简单的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.