我试图仅选择那些变量值等于其他变量值的节点。确切的文本是这样的:
但它不起作用。我想不可能将节点值表达式放在谓词内。但我也觉得很难相信。所以这就是为什么我在这里问:)
这个表达有什么问题?
谢谢!
编辑:
xml 代码如下所示:
;
<蛋白质>...
<肽><肽>...<蛋白质_登记><登记>89456......
不起作用的内容
以及< /code>
配合使用
与
但是,我在 apply-template 调用中使用它,我仍然不确定这个表达式是否执行我想做的操作(选择具有该特定编号的所有肽节点),但至少我可以继续尝试一些事情:)
谢谢!
I'm trying to select only those nodes that have a value of a variable equal to a value of other variable. The exact text would be this:
<xsl:value-of select="/data/peptides/peptide/protein_accessions[accession = ./accession/accs]" />
But it does not work. I guess it is not possible to put a node value expression inside the predicate. But also, I find it difficult to believe. So that's why I am here asking :)
What's wrong with this expression??
Thanks!
EDIT:
The xml code would be something like this:
<data>
<proteins>...</proteins>
<peptides><peptide>...<protein_accessions><accession>89456</accession></protein_accessions>...</peptide>...</peptides>
</data>
And what did not work with
<xsl:value-of select="/data/peptides/peptide/protein_accessions[accession = ./accession/accs]" />
works with
<xsl:value-of select="/data/peptides/peptide/protein_accessions[accession = current()/accession/accs]" />
However, I am using this in an apply-template call, I am still not sure if this expression does what I want to do (to select all the peptide nodes with that particular number), but at least I can move on and try things :)
Thanks!
发布评论
评论(2)
如果没有看到你的 XML,这很难回答,但你可能的意思是
Without seeing your XML this is hard to answer, but you probably mean
上面的 XPath 表达式显然不根本选择任何
肽
元素。它选择的所有节点(如果存在)都是名为 Protein_accessions 的元素。
如果您想要选择适当的
peptide
元素,请使用如下内容:The XPath expression above clearly doesn't select any
peptide
element at all.All nodes it selects, if such exist, are elements named
protein_accessions
.In case you want the appropriate
peptide
elements to be selected, use something like this: