TOC macro throws up exception on some pages but not others
Asked by Steve Goldberg:

I use the TOC macro all over my pages but on some pages (seemingly inexplicably) it throws up an exception on some pages but not others. I get the following error:
> Error rendering macro 'toc' : \[com.ctc.wstx.exc.WstxLazyException\] com.ctc.wstx.exc.WstxParsingException: Duplicate attribute 'id'. at \[row,col {unknown-source}\]: \[7,688\]

I can't figure out why. Anybody know?


Answers:
author: hsuhailah
body: Looks like you are hitting a known bug as raised here: <https://jira.atlassian.com/browse/CONF-23412>

Unfortunately, there's no workaround at the moment. You may want to vote for it to be fixed and watch the page for any future updates.

comments: author: Steve Goldberg
body: You're right, I found this out a few days after I posted the question here. I can report that the way to work around this is not to avoid putting headers within other macros. It doesn't happen all the time but the instance where it was breaking for me, I could get around it by doing this.


author: Mick Davidson
body: Steve,

I've got the same problem.

Can you explain what you mean by "the way to work around this is not to avoid putting headers within other macros" please?

IE, what does "not to avoid " and "headers" mean? Should headers be headings?

This is what our code looks like in HTML:

\<p\>  
\<ac:macro ac:name="toc"\>  
\<ac:parameter ac:name="maxLevel"\>3\</ac:parameter\>  
\</ac:macro\>  
\</p\>

I've tried moving the macro around within the page structure, deleting it altogether and adding a new one, and nothing works.

Cheers.

comments: author: Steve Goldberg
body: Grammar fail. Take what I said and remove the word "not" and change the word "headers": I can report that the way to work around this is to avoid putting headings within other macros

In other words, it's nothing to do with your macro that is generating the TOC but rather where you are putting your h1s, h2s, etc. Ensure your headings are only in the page body.


author: scoffin
body: I can't believe I'm reading and liking this workaround from over 6 years ago because the same issue still persists! Either bring back my beloved Anchor macros or fix the table of contents!


author: Mick Davidson
body: Steve, good point, I've just added it. Cheers.


author: Mick Davidson
body: Steve,

OK, I tried what you said but it didn't work. However, given what you said, I went through a copy of the entire page and started changing/removing elements (headings, macros etc), one at a time.

So all the headings were changed to paragraph, various macros were removed and re-instated. Finally I removed a macro called HTML Comment, and bingo Johnny! the TOC started rendering. :)

I then tested that all was ok by changing everything back to normal and it still works.

This means that the solution in your case isn't the solution in mine. Were/are you using the HTML Comment macro on any of your problem pages?

I think I have another page that is having the same problem, when I find that I'll run the same experiment again and report my findings here.

Cheers.

comments: author: Steve Goldberg
body: I wasn't actually using that macro so it's interesting that you had the same problem but with a different cause. Have you updated the JIRA ticket with this additional information? It could be useful for Atlassian.


Tags: table-of-contents