I'm trying to create a nested hierarchy from a flat structure, and I am using the following key:
<xsl:key name="next-headings"
match="w:p[w:pPr/w:pStyle/@w:val = 'Heading3']"
use="generate-id((ancestor::w:sdt[1] |
preceding-sibli开发者_运维百科ng::w:p
[w:pPr/w:pStyle/@w:val = 'Heading1'] or
preceding-sibling::w:p
[w:pPr/w:pStyle/@w:val = 'Heading2']
)[last()])"/>
I am getting the "not a node item" error, but don't understand why. Any help in translating this error is much appreciated!
As @LarsH has answered, the or
operator has more precedence that |
union operator, and it results in a boolean expression that you can't union to a node set.
But, besides that it looks like you want to replace the or
operator for a |
union, I would use this expression:
generate-id((ancestor::w:sdt[1] |
preceding-sibling::w:p
[w:pPr/w:pStyle/@w:val[. = 'Heading1' or . = 'Heading2']]
)[last()])
Edit: little typo...
I think you need to change or
to |
. You meant create a nodeset via union (|
), but the or
operator returns a boolean value, which is "not a node item".
精彩评论