document = new DOMDocument(); $this->document->registerNodeClass( 'DOMElement', 'ezcDocumentPdfInferencableDomElement' ); $this->document->load( dirname( __FILE__ ) . '/files/docbook/pdf/location_ids.xml' ); $this->xpath = new DOMXPath( $this->document ); $this->xpath->registerNamespace( 'doc', 'http://docbook.org/ns/docbook' ); } public function testRootNodeLocationId() { $element = $this->xpath->query( '//doc:article' )->item( 0 ); $this->assertEquals( '/article', $element->getLocationId() ); } public function testSectionNodeLocationId() { $element = $this->xpath->query( '//doc:section' )->item( 0 ); $this->assertEquals( '/article/section#paragraph_with_inline_markup', $element->getLocationId() ); } public function testLocationIdFromStrangeElementId() { $element = $this->xpath->query( '//doc:sectioninfo' )->item( 0 ); $this->assertEquals( '/article/section#paragraph_with_inline_markup/sectioninfo#some_strange_id_42', $element->getLocationId() ); } public function testNodeLocationIdWithRole() { $element = $this->xpath->query( '//doc:emphasis' )->item( 1 ); $this->assertEquals( '/article/section#paragraph_with_inline_markup/para/emphasis[Role=strong]', $element->getLocationId() ); } public function testNodeLocationIdWithClass() { $element = $this->xpath->query( '//doc:para' )->item( 1 ); $this->assertEquals( '/article/section#paragraph_with_inline_markup/para.note_warning', $element->getLocationId() ); } public function testNodeLocationIdWithRoleNormalization() { $element = $this->xpath->query( '//doc:emphasis' )->item( 2 ); $this->assertEquals( '/article/section#paragraph_with_inline_markup/para.note_warning/emphasis[Role=strong]', $element->getLocationId() ); } } ?>