It's possible to create invalid XHTML, by using two headings with the same name. For example:
====== example ======
====== example ======
This will result in the following XHTML:
<h1><a name="example" id="example">example</a></h1>
<h1><a name="example" id="example">example</a></h1>
I don't think this is a theoretical use-case. I experienced it with the following (Dutch) page (OK, the blog plugin is also causing some invalid XHTML, but that's not the point):
http://retortplusplus.org/home/projecten/adger/intro
The thing is: you can generate invalid XHTML with DokuWiki, without enabling HTML and PHP inclusion. I think the engine needs to keep track of all used id-attributes, and use sequence numbers to prevent double id's. The output will than be:
<h1><a name="example" id="example">example</a></h1>
<h1><a name="example_1" id="example_1">example</a></h1>
And while you're at it, you might want to add explicit id's the headings, like in trac (http://trac.edgewall.org/wiki/WikiFormatting#Headings):
====== A quick and dirty example ====== #qd_example
will result in
<h1><a name="qd_example" id="qd_example">example</a></h1>