Using XPath with bookmap metadata

Post here questions and problems related to editing and publishing DITA content.
DmitryS
Posts: 26
Joined: Wed Nov 27, 2019 11:03 am

Using XPath with bookmap metadata

Post by DmitryS »

Hi!
Please help me to return the value of bookmeta/bookrights/copyrlast/year.
Expression

Code: Select all

//*[contains(@class, "bookmap/year")]/text() 
returns two values, from <copyrfirst> and <copyrlast>.

Sincerely,
Dmitry
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Using XPath with bookmap metadata

Post by alex_jitianu »

Hi Dmitry,

That's because both copyrlast and copyrfirst have a year element in them, and your XPath takes all the year elements from anywhere in the document. Just restrict the expression to the year from withing copyrlast, like this:

Code: Select all

//*[contains(@class, "bookmap/copyrlast")]/*[contains(@class, "bookmap/year")]/text() 
Best regards,
Alex
DmitryS
Posts: 26
Joined: Wed Nov 27, 2019 11:03 am

Re: Using XPath with bookmap metadata

Post by DmitryS »

Thank you, Alex!

Sincerely,
Dmitry
Post Reply