- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 <xsl:copy-of>
提交两个 XML 节点的副本以及一个表单。问题是我只获取节点的文本内容而不是所有完整的节点内容。根据w3schools :
The
<xsl:copy-of>
element creates a copy of the current node. Note: Namespace nodes, child nodes, and attributes of the current node are automatically copied as well!
但是,这似乎并没有发生在我身上——要么我不理解注释,要么我正在使用 <xsl:copy-of>
元素不正确。我在下面包含了我的 xml、xsl 和 jQuery 的片段(我将 xsl 应用到 xml,它创建了一个 html 表单,它使用 jQuery 提交)。我还包括了我目前获得的输出以及所需的输出。非常感谢任何建议!
XML 看起来像这样:
<trigger offsetBeg="89" offsetEnd="96">induced</trigger>
<ggps>
<ggp role="Theme" offsetBeg="68" offsetEnd="73" id="10013"
consensusName="HDAC6">HDAC6</ggp>
<ggp role="Cause" offsetBeg="100" offsetEnd="103" id="7001"
consensusName="TSA">TSA</ggp>
</ggps>
XSL 看起来像这样:
<xsl:variable name="trigger"><xsl:copy-of select="trigger" /></xsl:variable>
<xsl:variable name="ggps"><xsl:copy-of select="ggps" /></xsl:variable>
<form name="label_form" action="">
<input class="trigger" type="hidden" name="trigger" value="{$trigger}" />
<input class="ggps" type="hidden" name="ggps" value="{$ggps}" />
<div><button class="button">Submit</button></div>
</form>
当我将其添加到 XSL 时:
<xsl:copy-of select="current()/trigger"></xsl:copy-of>
<xsl:copy-of select="current()/ggps"></xsl:copy-of>
我得到这个 HTML:
<trigger offsetBeg="89" offsetEnd="96">induced</trigger>
<ggps>
<ggp role="Theme" offsetBeg="68" offsetEnd="73" id="10013"
consensusName="HDAC6">HDAC6</ggp>
<ggp role="Cause" offsetBeg="100" offsetEnd="103" id="7001"
consensusName="TSA">TSA</ggp>
</ggps>
我正在使用 jQuery 来提交表单:
$(".button").click(function() {
var trigger = $(this).parent().siblings("input.trigger").val();
var ggps = $(this).parent().siblings("input.ggps").val();
var dataString = 'trigger=' + trigger + '&ggps=' + ggps;
$.ajax({
type : "POST",
url : "/submit_label",
data : dataString,
success : function(){
console.log("dataString:\n" + dataString);
}
});
return false;
});
我从 console.log 得到的是这样的:
dataString:
trigger='induced '&ggps=' HDAC6 TSA '
我想从 console.log 得到的是这样的:
dataString:
trigger='<trigger offsetBeg="89" offsetEnd="96">induced</trigger>'&ggps='<ggps>
<ggp role="Theme" offsetBeg="68" offsetEnd="73"id="10013"consensusName="HDAC6">
HDAC6</ggp><ggp role="Cause" offsetBeg="100" offsetEnd="103" id="7001"
consensusName="TSA">TSA</ggp></ggps>'
我想要这个,因为我希望能够将这些节点直接放入我将要构建的另一个 XML 文档中。
最佳答案
您的变量 $trigger 包含相关树的完整副本,但是当您使用这样的属性值模板时:
value="{$trigger}"
该值被扁平化为一个字符串 - 具体来说,根元素的字符串值,它是其后代文本节点的串联。
如果您希望属性包含树的序列化版本(即,包含标记的词法 XML,可能会转义以使其成为合法的属性值),那么您需要调用某种 serialize-xml() 函数. XSLT 3.0 和一些产品(例如 Saxon)中有这样的功能;或者您可以自己编写。
关于javascript - 如何使用 xsl :copy-of to copy text of XML node and pass to form? 改用 CDATA?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20024026/
所以,我有一个 Python 脚本,基本上可以写入 80GB 以上的文件。目前它只是串行运行,在服务器上运行大约需要 13 个小时,这是我唯一一次实际运行它。 我打算将它并行化,以便它写入多个文件,而
我最近将 ASP.Net Web API 项目部署到我们的 Azure 应用服务测试槽,但在向 API 端点发出请求时开始收到错误。通过远程调试,很明显该应用正在从部署的 web.config 文件中
为什么我在 android 的 xml 布局中有这个警告消息 信息是避免使用“px”作为单位,改用“dp” 最佳答案 答案就在那里:What is the difference between "px
我正在使用 Symfony 2.3,并且在我的分析器中有与 Twig 相关的弃用警告。如: DEPRECATION - Using "replace" with character by charac
这个问题在这里已经有了答案: Convert pandas dataframe to NumPy array (15 个答案) 关闭 3 年前。 我有以下代码 train_X, test_X, tr
我正在尝试在 Storyboard完成后运行一些代码,但似乎找不到如何设置它...如果我只是这样做 Completed="LoadingStoryBoard_Completed" 在 Storyboa
我最近使用 ng update 更新了我的 Angular 版本并且在运行 ng lint 时 我收到错误 create is deprecated: use new Observable() ins
我将 webpacker 从 4.x 升级到 5.2.1 并开始收到此警告: The resolved_paths option has been deprecated. Use additional
我正在编译一些 C 代码,但出现错误 typedef 'A' is initialized (use decltype instead) 在我的结构声明之一。什么可能导致这种情况? 最佳答案 我可以用
打开 GUI 的简单程序,单击一个按钮设置 curDir,单击另一个按钮设置 savDir,第三个按钮执行一些 C++ 代码,类似于 ls -l curDir > savDir.txt 我的一个 Qt
我要git diff成为一个快速的命令行解决方案来查看两个文件之间的差异,然后我想要 git difftool启动 meld 以获得文件差异的更多图形 View 。 目前,git diff完全按照我的
我正在尝试构建一个 webpack 解析器,下面的 .plugin 方法代码似乎已被弃用,我找不到使用 .hooks 的类似方法调用。 module.exports = class Resolver
我最近在运行我的应用程序时开始收到此错误。它似乎不会影响一切,但它在日志中非常嘈杂和烦人。我没有对我的应用程序进行任何更改或添加任何会导致此类问题的内容,我最近所做的唯一一件事就是升级到最新版本的 F
我想用 Python mongodb 查询,但“DeprecationWarning: count is deprecated。改用 Collection.count_documents。”给出这样的
代码: export default { props: { article: {type: Object} }, data () { retur
这让我发疯。我想读取一些文本文件(位于我的项目目录之外),用 Windows-1252 编码,将它们编辑为字符串,然后写回这些文件,再次作为 Windows-1252。然而,Visual Studio
我需要一点帮助。因为 preg_replace 已弃用,我必须将所有 my preg_replace 转换为 preg_replace_callback... 我尝试过的: 改变: $template
简短的例子: #include #include using namespace boost; template BOOST_TYPEOF_TPL(T() + U()) add2(const T&
我尝试运行 Vuetify VueJS Cordova example但是在 npm run dev 之后出现了这个错误 node build/dev-server.js Starting dev s
我有以下代码: func setupShortcutItems(launchOptions: [NSObject: AnyObject]?) -> Bool { var shouldPerfo
我是一名优秀的程序员,十分优秀!