Skip to content

Commit 07b4806

Browse files
authored
Document xml:id usage (#216)
1 parent a4884fb commit 07b4806

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

configure.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ function xinclude_residual( DOMDocument $dom )
10571057
// XInclude by XPath/XPointer may start causing duplications
10581058
// (see docs/structure.md). Crude and ugly fixup ahead, beware!
10591059

1060+
$see = false;
10601061
$list = array();
10611062
$nodes = $xpath->query( "//*[@xml:id]" );
10621063
foreach( $nodes as $node )
@@ -1065,11 +1066,16 @@ function xinclude_residual( DOMDocument $dom )
10651066
if ( isset( $list[ $id ] ) )
10661067
{
10671068
if ( ! str_contains( $id , '..' ) )
1069+
{
10681070
echo " Random removing duplicated xml:id: $id\n";
1071+
$see = true;
1072+
}
10691073
$node->removeAttribute( "xml:id" );
10701074
}
10711075
$list[ $id ] = $id;
10721076
}
1077+
if ( $see )
1078+
echo " See: https://github.com/php/doc-base/blob/master/docs/structure.md#xmlid-structure\n";
10731079
}
10741080

10751081
echo "Validating {$ac["INPUT_FILENAME"]}... ";

docs/structure.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,22 @@ There are some other important files:
4646

4747
## `xml:id` structure
4848

49-
The PHP is complex, and uses `xml:id` extensively. For chunking,
50-
linking and XInclude purposes. So some care is necessary to avoid
51-
collisions. There are two pseudo-types of IDs used in manuals.
49+
The PHP Manual is complex, and uses `xml:id`s extensively, for various
50+
purposes. So some care is necessary to avoid failures.
51+
There are two types of `xml:id`s used in manuals.
5252

5353
* **Structural IDs:** IDs that are present on structural elements of
54-
DocBook XML (like `<chapter>`, `<section>` and so on);
54+
DocBook XML (like `<chapter>`, `<section>` and so on), that are used for
55+
linking and chunking;
5556

5657
* **XInclude IDs:** IDs that are used as target of XIncludes.
5758

58-
Structural IDs are in the pattern `id.id`, while XInclude IDs use the
59-
pattern `structural.id..local.name`. That is, Structural IDs, the
60-
name parts are separated with a single dot, while XInclude IDs start
61-
with an Structural ID, an `..` separator, and a local path suffix.
59+
Structural IDs are in the pattern `id.id` (always one dot as separator),
60+
while XInclude IDs use the pattern `structural.id..local.name`. That is,
61+
for Structural IDs the name parts are separated with a *single* dot, while
62+
XInclude IDs are composed of an Structural ID prefix, a *double* dot separator,
63+
and a named suffix.
64+
65+
The `configure.php` script will remove any duplicated IDs found. Without
66+
warnings in the case of XInclude IDs, so it is possible to use XInclude
67+
IDs elsewhere, and will warn about duplicate Structural IDs.

0 commit comments

Comments
 (0)