Skip to content

Commit

Permalink
Use simplier xpath to extract first names
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsunday committed Apr 3, 2024
1 parent cafa7ac commit 7338a28
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/Processor/NameProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,11 @@ class NameProcessor
*/
private const FULL_NAME = 'full';

private const XPATH_FIRST_NAMES_ALL
= './/text()';

private const XPATH_FIRST_NAMES_EXCEPT_PART
= '(//q[@class="wt-nickname"]/text() | //span[@class="SURN"]/text() | //span[@class="SURN"]/following::text())';

/**
* The XPath identifier to extract the first name parts (including the prefix).
*
* As PHP does not support XPath 2.0 "except" => XPATH_FIRST_NAMES_ALL except XPATH_FIRST_NAMES_EXCEPT_PART
*/
private const XPATH_FIRST_NAMES
= self::XPATH_FIRST_NAMES_ALL . '[count(.|' . self::XPATH_FIRST_NAMES_EXCEPT_PART . ')!=count(' . self::XPATH_FIRST_NAMES_EXCEPT_PART . ')]';
= '//text()[not(ancestor::q[@class="wt-nickname"]) and not(preceding::span[@class="SURN"] or ancestor::span[@class="SURN"])]';

/**
* The XPath identifier to extract the last name parts (surname + surname suffix).
Expand Down

0 comments on commit 7338a28

Please sign in to comment.