如果兄弟是唯一的,则查找节点

Finding a node if a brother is unique

我有这样一条 DTD 行:

<!ELEMENT performance (composition, (soloist)?,(orchestra, conductor)?)>

而且我想找到只有一个独奏者的作品。

我想过这样的事情:

/performance/compositions[count(../soloist)=1]

是否正确? 是否可以在谓词中使用 AND 运算符? (例如,如果我不想要独奏家和一个管弦乐队)

由于performance的声明只允许零个或一个soloist和零个或一个orchestra,因此无需计算出现的次数。

致 return compositionsoloist:

    /performance[soloist]/composition

致 return composition 没有 soloist 但有 orchestra:

    /performance[not(soloist) and orchestra]/composition