Problem with ${xpath_eval(parent::node()/@id)}

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
aujunior
Posts: 35
Joined: Thu Feb 16, 2023 11:00 pm

Problem with ${xpath_eval(parent::node()/@id)}

Post by aujunior »

Good afternoon!

We are having a problem with xpath_eval, when passing xPath "/*/@id" the system correctly returns the @id of the first element of the XML, however when we pass "parent::node()/@id" the system returns nothing .

We are using :
${xpath_eval(parent::node()/@id)}-${uuid}

Can you tell us if the way to collect the ID of the relative node is correct?

We have tested the "parent::node()/@id" statement in Oxygen Desktop and it is working correctly. The problem is with Oxygen Web.
RossL
Posts: 1
Joined: Thu May 23, 2024 7:25 am
Location: https://hackerdna.com
Contact:

Re: Problem with ${xpath_eval(parent::node()/@id)}

Post by RossL »

Hello,

Your problem reminds me of an old hacker trick. In Oxygen Desktop, the instruction works because the desktop environment has a more robust and tolerant implementation. Make sure the context of the current node is set correctly before using "parent::node()/@id". If the context is incorrect, the evaluation won't work. Here's a hacker's tip: try to isolate the problem by testing different contexts, or by checking whether updates or patches are available for Oxygen Web.
cristi_talau
Posts: 501
Joined: Thu Sep 04, 2014 4:22 pm

Re: Problem with ${xpath_eval(parent::node()/@id)}

Post by cristi_talau »

Hello,

Can you share in what context you are using the xpath_eval environment variable? Is it passed as an argument to an AuthorOperation inside an Action? Something else?

Best,
Cristian
aujunior
Posts: 35
Joined: Thu Feb 16, 2023 11:00 pm

Re: Problem with ${xpath_eval(parent::node()/@id)}

Post by aujunior »

Hello!

We create an UniqueAttributesRecognizer and call GenerateIDElementsInfo.generateID() passing "idGenerationPattern", "AuthorElement element", "Editor Location".

Code: Select all

/** Using AuthorElement element
         * 
         */
        logger.error("idGenerationPattern > before " + idGenerationPattern);
        logger.error("element.getLocalName() > " + element.getLocalName());
        logger.error("edLocation.toString() > " + edLocation.toString());
        // primeiramente crio o ID que contiver xpath evaluation
        idGenerationPattern = GenerateIDElementsInfo.generateID(idGenerationPattern, element.getLocalName(),
                edLocation != null ? edLocation.toString() : null);
        logger.error("idGenerationPattern > after " + idGenerationPattern);
And received this log:
//Working using ${xpath_eval(/*/@id)}
ERROR idGenerationPattern > before ${xpath_eval(/*/@id)}-ZID-${uuid}
ERROR element.getLocalName() > zoneIdent
ERROR edLocation.toString() > webdav-http://****@******/zoneS1000D.xml
ERROR idGenerationPattern > after ZON-0000000040-ZID-af696d1f-49aa-4dc9-b3d5-6701335e776b

//Not working using ${xpath_eval(parent::node()/@id)}-gra
ERROR idGenerationPattern > before ${xpath_eval(parent::node()/@id)}-gra
ERROR element.getLocalName() > before graphic
ERROR edLocation.toString() > webdav-http://****@*****/zoneS1000D.xml
ERROR idGenerationPattern > after -gra

//Not working using ${xpath_eval(./parent::node()/@id)}-hot
ERROR idGenerationPattern > before ${xpath_eval(./parent::node()/@id)}-hot
ERROR element.getLocalName() > hotspot
ERROR edLocation.toString() > webdav-http://****@*****/zoneS1000D.xml
ERROR idGenerationPattern > after -hot

Tried:
./parent::node()/@id
parent::node()/@id
/parent::node()/@id
./parent::*/@id
parent:*/@id
./ancestor::node()[1]/@id
Last edited by aujunior on Thu May 23, 2024 6:39 pm, edited 1 time in total.
aujunior
Posts: 35
Joined: Thu Feb 16, 2023 11:00 pm

Re: Problem with ${xpath_eval(parent::node()/@id)}

Post by aujunior »

Good morning Cristian!

Could you tell if it is an xpath error or if it is a limitation of the GenerateIDElementsInfo.generateID() method?

Best,
Audye
cristi_talau
Posts: 501
Joined: Thu Sep 04, 2014 4:22 pm

Re: Problem with ${xpath_eval(parent::node()/@id)}

Post by cristi_talau »

Hello,

This is a limitation of GenerateIDElementsInfo.generateID - it does not know where the selection is in the editor. In the desktop application, it is easier to determine since there is only one user, and only one editor open. In Web Author we fixed a similar problem (reference ID WA-6789) and the fix will be in the next release. If you can send us a framework such that we can reproduce the problem, we can confirm if it is fixed in the next release.

Another option is to use Java code to find the desired ID instead of relying on GenerateIDElementsInfo.generateID. For example, you can use AuthorDocumentController.findNodesByXPath or evaluateXPath.

Best,
Cristian
Post Reply