Page 1 of 1

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

Posted: Wed May 22, 2024 10:15 pm
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.

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

Posted: Thu May 23, 2024 7:30 am
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.

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

Posted: Thu May 23, 2024 12:19 pm
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

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

Posted: Thu May 23, 2024 6:37 pm
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

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

Posted: Mon Jun 10, 2024 1:38 pm
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

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

Posted: Tue Jun 11, 2024 7:11 pm
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