Page 1 of 1

"Element exists?" condition

PostPosted: Tue Feb 14, 2012 10:17 am
by olabrosse

I've read the OpenDoPe conventions for conditionals and couldn't find anything about basing a condition on the existence of an element.

In my template I want a whole chapter to not be displayed when elements of a certain type don't exist (basically meaning the XPath is invalid).

Is there a way to do this other than adding a boolean attribute somewhere that specifies whether such elements exist?

Thank you!


Re: "Element exists?" condition

PostPosted: Tue Feb 14, 2012 1:30 pm
by olabrosse
Although I would still like to know the answer to my previous question, I went ahead and added boolean elements to my template's custom XML to see how it works. Turns out it doesn't work. The conditions part always has an empty <conditions/> element.

Am I doing something wrong?

1. Select the text to be visible based on condition.
2. Click "Wrap with Condition" in the ribbon.
3. Click "New simple XPath Condition" in the task pane.
4. Select the boolean element, giving the proper XPath.
5. Set ID's for XPath and Condition.
6. Click "Create Condition".

After that, when I click inside the conditional block, the condition appears empty in the task pane:

Code: Select all
<conditions xmlns:xsi="" xmlns:xsd="" xmlns=""/>

This has the effect of causing a NPE in OpenDoPEHandler during the preprocess, as it assumes the condition exists as it gets its XPath.

Thanks for your help!

Re: "Element exists?" condition

PostPosted: Tue Feb 14, 2012 1:45 pm
by olabrosse
It just occurred to me that I might be expecting too much from the add-in. :oops: I really thought the reason why the add-in asked for the XPath and Condition ID's was to create the condition for you. hehe

Anyway, I typed in the conditions manually and it all worked out.

Any thoughts on the "XPath is valid" type of condition I mentioned above?

Thanks again.

Re: "Element exists?" condition

PostPosted: Wed Feb 15, 2012 10:32 pm
by jason
I'm not sure why you weren't able to add a condition successfully using the Add-In. It should work....

One way to do an "element exists" condition is using count, for example:

Code: Select all

or > 0

Re: "Element exists?" condition

PostPosted: Sat Feb 18, 2012 6:56 am
by olabrosse
Thanks Jason.

As you can tell, I'm fairly new to XPath. Your help is much appreciated.