diff --git a/configure.php b/configure.php index cc8415c66..327b39532 100755 --- a/configure.php +++ b/configure.php @@ -1057,6 +1057,7 @@ function xinclude_residual( DOMDocument $dom ) // XInclude by XPath/XPointer may start causing duplications // (see docs/structure.md). Crude and ugly fixup ahead, beware! + $see = false; $list = array(); $nodes = $xpath->query( "//*[@xml:id]" ); foreach( $nodes as $node ) @@ -1065,11 +1066,16 @@ function xinclude_residual( DOMDocument $dom ) if ( isset( $list[ $id ] ) ) { if ( ! str_contains( $id , '..' ) ) + { echo " Random removing duplicated xml:id: $id\n"; + $see = true; + } $node->removeAttribute( "xml:id" ); } $list[ $id ] = $id; } + if ( $see ) + echo " See: https://github.com/php/doc-base/blob/master/docs/structure.md#xmlid-structure\n"; } echo "Validating {$ac["INPUT_FILENAME"]}... "; diff --git a/docs/structure.md b/docs/structure.md index 0f8d97c34..327374268 100644 --- a/docs/structure.md +++ b/docs/structure.md @@ -46,16 +46,22 @@ There are some other important files: ## `xml:id` structure -The PHP is complex, and uses `xml:id` extensively. For chunking, -linking and XInclude purposes. So some care is necessary to avoid -collisions. There are two pseudo-types of IDs used in manuals. +The PHP Manual is complex, and uses `xml:id`s extensively, for various +purposes. So some care is necessary to avoid failures. +There are two types of `xml:id`s used in manuals. * **Structural IDs:** IDs that are present on structural elements of -DocBook XML (like ``, `
` and so on); +DocBook XML (like ``, `
` and so on), that are used for +linking and chunking; * **XInclude IDs:** IDs that are used as target of XIncludes. -Structural IDs are in the pattern `id.id`, while XInclude IDs use the -pattern `structural.id..local.name`. That is, Structural IDs, the -name parts are separated with a single dot, while XInclude IDs start -with an Structural ID, an `..` separator, and a local path suffix. +Structural IDs are in the pattern `id.id` (always one dot as separator), +while XInclude IDs use the pattern `structural.id..local.name`. That is, +for Structural IDs the name parts are separated with a *single* dot, while +XInclude IDs are composed of an Structural ID prefix, a *double* dot separator, +and a named suffix. + +The `configure.php` script will remove any duplicated IDs found. Without +warnings in the case of XInclude IDs, so it is possible to use XInclude +IDs elsewhere, and will warn about duplicate Structural IDs.