English 中文(简体)
• 如何检查在另一个具有特定特性的XML中是否存在一个XML的 no价值?
原标题:How to check if a node s value in one XML is present in another XML with a specific attribute?
  • 时间:2010-06-03 10:25:41
  •  标签:
  • xml
  • xslt

问题似乎没有什么混淆。 因此,请允许我以一个例子说明我的情况:

Suppose I have an XML: A.xml

<Cakes>
    <Cake>Egg</Cake>
    <Cake>Banana</Cake>
</Cakes>

另一项XML:B.xml

<Cakes>
    <Cake show="true">Egg</Cake>
    <Cake show="true">Strawberry</Cake>
    <Cake show="false">Banana</Cake>
</Cakes>

现在,我要表明一些案文:“TRUE”,如果在<代码>A.xml上的所有震动都有<代码>show=“true” in B.xml,否则“FALSE

在上述情况下,它将印刷FALSE。

为此,我需要制定一部XSL。 如果汽车在B.xml显示“真实”,我可以穿透A.xml的所有面包车,如果发现显示“false”,我不知道如何在(和设定一个变数)之间断裂。

是否可能? 感谢任何帮助/帮助。

最佳回答
<xsl:choose>
<xsl:when test="count(document( B.xml )/Cakes/Cake[@show= true  AND text() = /Cakes/Cake/text()]) = count(/Cakes/Cake)">
true
</xsl:when>
<xsl:otherwise>
false
</xsl:otherwise>

应帮助(不是100%)

问题回答

这里的问题是,你可以更新SL的可变性;SL可变性只有一次签字,但可以有条件转让。

我认为,更简单、更明智的办法是使用小型的XSL碎片,从适当的方案拟订语言中将其从方案上说出来,这样可以使用XPath来进行消化。

我认为,最好的办法是:

www.un.org/Depts/DGACM/index_spanish.htm 是否至少有一个要素是“Cake”为“A.xml”,与“Cake”为“B.xml”,其属性是“thetrue”?。

因此,Xpath 1.0:

document(A.xml )/Cakes/Cake[not(not)(B.xml)/Cakes/Cake[@show= real)]

注:我对译文表示歉意。 我讲西班牙语。

www.un.org/Depts/DGACM/index_spanish.htm 正确评估这一状况的最简单的XPath表述之一是:。

not(document( B.xml )/*/Cake[@show != true ] = /*/Cake)




相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签