xpath - XSLT 2.0, Checking for the existence of specific node at specific position -


i have xml several <mt> elements ones below

<gsp> <res> <r> <mt n="authors" v="mckee, d.w.; general electric co., schenectady, ny (usa). corporate research , development dept"/> <mt n="english-title" v="advanced gas-cooled nuclear reactor materials evaluation , development program: corrosion behavior of experimental alloys in controlled-purity helium @ temperatures in 750 1050&lt;sup&gt;0&lt;/sup&gt;c range"/> <mt n="title" v="ni-20cr + al, ti, si, nb and/or y"/> </r> </res> </gsp> 

i want check if there element @n='title' after @n='english-title'. don't want use <mt> element @n='title', if appears anywhere else.

how can achieved?

this xpath expression:

//mt[@n='title'][preceding-sibling::mt[1][@n='english-title']] 

will select nodes. selects among all mt elements have n attribute contents "title", ones preceding mt sibling contains n attribute contents "english title".

you can use inside xslt attribute accepts absolute xpath expressions , print result tree, save in variable, etc.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -