@@ -26,30 +26,30 @@ |
||
| 26 | 26 | // By default, it will point to the root element, |
| 27 | 27 | // <author/> |
| 28 | 28 | $record = qp('<?xml version="1.0"?><author></author>') |
| 29 | - // Add a new last name inside of author. |
|
| 30 | - ->append('<lastName>Dostoyevsky</lastName>') |
|
| 31 | - // Select all of the children of <author/>. In this case, |
|
| 32 | - // that is <lastName/> |
|
| 33 | - ->children() |
|
| 34 | - // Oh, wait... we wanted last name to be inside of a <name/> |
|
| 35 | - // element. Use wrap to wrap the current element in something: |
|
| 36 | - ->wrap('<name/>') |
|
| 37 | - // And before last name, we want to add first name. |
|
| 38 | - ->before('<firstName/>') |
|
| 39 | - // Select first name |
|
| 40 | - ->prev() |
|
| 41 | - // Set the text of first name |
|
| 42 | - ->text('Fyodor') |
|
| 43 | - // And then after first name, add the patronymic |
|
| 44 | - ->after('<patronymic>Fyodorovich</patronymic>') |
|
| 45 | - // Now go back to the root element, the top of the document. |
|
| 46 | - ->top() |
|
| 47 | - // Add another tag -- origin. |
|
| 48 | - ->append('<origin>Russia</origin>') |
|
| 49 | - // turn the QueryPath contents back into a string. Since we are |
|
| 50 | - // at the top of the document, the whole document will be converted |
|
| 51 | - // to a string. |
|
| 52 | - ->xml(); |
|
| 29 | + // Add a new last name inside of author. |
|
| 30 | + ->append('<lastName>Dostoyevsky</lastName>') |
|
| 31 | + // Select all of the children of <author/>. In this case, |
|
| 32 | + // that is <lastName/> |
|
| 33 | + ->children() |
|
| 34 | + // Oh, wait... we wanted last name to be inside of a <name/> |
|
| 35 | + // element. Use wrap to wrap the current element in something: |
|
| 36 | + ->wrap('<name/>') |
|
| 37 | + // And before last name, we want to add first name. |
|
| 38 | + ->before('<firstName/>') |
|
| 39 | + // Select first name |
|
| 40 | + ->prev() |
|
| 41 | + // Set the text of first name |
|
| 42 | + ->text('Fyodor') |
|
| 43 | + // And then after first name, add the patronymic |
|
| 44 | + ->after('<patronymic>Fyodorovich</patronymic>') |
|
| 45 | + // Now go back to the root element, the top of the document. |
|
| 46 | + ->top() |
|
| 47 | + // Add another tag -- origin. |
|
| 48 | + ->append('<origin>Russia</origin>') |
|
| 49 | + // turn the QueryPath contents back into a string. Since we are |
|
| 50 | + // at the top of the document, the whole document will be converted |
|
| 51 | + // to a string. |
|
| 52 | + ->xml(); |
|
| 53 | 53 | |
| 54 | 54 | // Print our results. |
| 55 | 55 | print $record; |
| 56 | 56 | \ No newline at end of file |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | // We first set up the parameters that will be sent. |
| 44 | 44 | $params = array( |
| 45 | - 'query' => $sparql, |
|
| 46 | - 'format' => 'application/sparql-results+xml', |
|
| 45 | + 'query' => $sparql, |
|
| 46 | + 'format' => 'application/sparql-results+xml', |
|
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | // DB Pedia wants a GET query, so we create one. |
@@ -56,27 +56,27 @@ discard block |
||
| 56 | 56 | // Get the headers from the resulting XML. |
| 57 | 57 | $headers = array(); |
| 58 | 58 | foreach ($qp->children('variable') as $col) { |
| 59 | - $headers[] = $col->attr('name'); |
|
| 59 | + $headers[] = $col->attr('name'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Get rows of data from result. |
| 63 | 63 | $rows = array(); |
| 64 | 64 | $col_count = count($headers); |
| 65 | 65 | foreach ($qp->top()->find('results>result') as $row) { |
| 66 | - $cols = array(); |
|
| 67 | - $row->children(); |
|
| 68 | - for ($i = 0; $i < $col_count; ++$i) { |
|
| 66 | + $cols = array(); |
|
| 67 | + $row->children(); |
|
| 68 | + for ($i = 0; $i < $col_count; ++$i) { |
|
| 69 | 69 | $cols[$i] = $row->branch()->eq($i)->text(); |
| 70 | - } |
|
| 71 | - $rows[] = $cols; |
|
| 70 | + } |
|
| 71 | + $rows[] = $cols; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Turn data into table. |
| 75 | 75 | $table = '<table><tr><th>' . implode('</th><th>', $headers) . '</th></tr>'; |
| 76 | 76 | foreach ($rows as $row) { |
| 77 | - $table .= '<tr><td>'; |
|
| 78 | - $table .= implode('</td><td>', $row); |
|
| 79 | - $table .= '</td></tr>'; |
|
| 77 | + $table .= '<tr><td>'; |
|
| 78 | + $table .= implode('</td><td>', $row); |
|
| 79 | + $table .= '</td></tr>'; |
|
| 80 | 80 | } |
| 81 | 81 | $table .= '</table>'; |
| 82 | 82 | |
@@ -20,38 +20,38 @@ |
||
| 20 | 20 | |
| 21 | 21 | // Begin with an HTML stub document (XHTML, actually), and navigate to the title. |
| 22 | 22 | qp(QueryPath::HTML_STUB, 'title') |
| 23 | - // Add some text to the title |
|
| 24 | - ->text('Example of QueryPath.') |
|
| 25 | - // Now look for the <body> element |
|
| 26 | - ->top('body') |
|
| 27 | - // Inside the body, add a title and paragraph. |
|
| 28 | - ->append('<h1>This is a test page</h1><p>Test text</p>') |
|
| 29 | - // Now we select the paragraph we just created inside the body |
|
| 30 | - ->children('p') |
|
| 31 | - // Add a 'class="some-class"' attribute to the paragraph |
|
| 32 | - ->attr('class', 'some-class') |
|
| 33 | - // And add a style attribute, too, setting the background color. |
|
| 34 | - ->css('background-color', '#eee') |
|
| 35 | - // Now go back to the paragraph again |
|
| 36 | - ->parent() |
|
| 37 | - // Before the paragraph and the title, add an empty table. |
|
| 38 | - ->prepend('<table id="my-table"></table>') |
|
| 39 | - // Now let's go to the table... |
|
| 40 | - ->top('#my-table') |
|
| 41 | - // Add a couple of empty rows |
|
| 42 | - ->append('<tr></tr><tr></tr>') |
|
| 43 | - // select the rows (both at once) |
|
| 44 | - ->children() |
|
| 45 | - // Add a CSS class to both rows |
|
| 46 | - ->addClass('table-row') |
|
| 47 | - // Now just get the first row (at position 0) |
|
| 48 | - ->eq(0) |
|
| 49 | - // Add a table header in the first row |
|
| 50 | - ->append('<th>This is the header</th>') |
|
| 51 | - // Now go to the next row |
|
| 52 | - ->next() |
|
| 53 | - // Add some data to this row |
|
| 54 | - ->append('<td>This is the data</td>') |
|
| 55 | - // Write it all out as HTML |
|
| 56 | - ->writeHTML(); |
|
| 23 | + // Add some text to the title |
|
| 24 | + ->text('Example of QueryPath.') |
|
| 25 | + // Now look for the <body> element |
|
| 26 | + ->top('body') |
|
| 27 | + // Inside the body, add a title and paragraph. |
|
| 28 | + ->append('<h1>This is a test page</h1><p>Test text</p>') |
|
| 29 | + // Now we select the paragraph we just created inside the body |
|
| 30 | + ->children('p') |
|
| 31 | + // Add a 'class="some-class"' attribute to the paragraph |
|
| 32 | + ->attr('class', 'some-class') |
|
| 33 | + // And add a style attribute, too, setting the background color. |
|
| 34 | + ->css('background-color', '#eee') |
|
| 35 | + // Now go back to the paragraph again |
|
| 36 | + ->parent() |
|
| 37 | + // Before the paragraph and the title, add an empty table. |
|
| 38 | + ->prepend('<table id="my-table"></table>') |
|
| 39 | + // Now let's go to the table... |
|
| 40 | + ->top('#my-table') |
|
| 41 | + // Add a couple of empty rows |
|
| 42 | + ->append('<tr></tr><tr></tr>') |
|
| 43 | + // select the rows (both at once) |
|
| 44 | + ->children() |
|
| 45 | + // Add a CSS class to both rows |
|
| 46 | + ->addClass('table-row') |
|
| 47 | + // Now just get the first row (at position 0) |
|
| 48 | + ->eq(0) |
|
| 49 | + // Add a table header in the first row |
|
| 50 | + ->append('<th>This is the header</th>') |
|
| 51 | + // Now go to the next row |
|
| 52 | + ->next() |
|
| 53 | + // Add some data to this row |
|
| 54 | + ->append('<td>This is the data</td>') |
|
| 55 | + // Write it all out as HTML |
|
| 56 | + ->writeHTML(); |
|
| 57 | 57 | ?> |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | $splos->rewind(); |
| 85 | 85 | $first = $splos->current(); |
| 86 | 86 | if ($first instanceof \DOMDocument) { |
| 87 | - $this->dom = $first;//->documentElement; |
|
| 87 | + $this->dom = $first; //->documentElement; |
|
| 88 | 88 | } else { |
| 89 | - $this->dom = $first->ownerDocument;//->documentElement; |
|
| 89 | + $this->dom = $first->ownerDocument; //->documentElement; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $this->scopeNode = $scopeNode; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | return $this->combineAnyDescendant($node, $selectors, $index); |
| 265 | 265 | case SimpleSelector::ANOTHER_SELECTOR: |
| 266 | 266 | // fprintf(STDOUT, "Next selector: %s\n", $selectors[$index]); |
| 267 | - return $this->matchesSimpleSelector($node, $selectors, $index);; |
|
| 267 | + return $this->matchesSimpleSelector($node, $selectors, $index); ; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | return false; |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | $name = $pseudoClass['name']; |
| 777 | 777 | // Avoid E_STRICT violation. |
| 778 | 778 | $value = $pseudoClass['value'] ?? NULL; |
| 779 | - $ret &= $this->psHandler->elementMatches($name, $node, $this->scopeNode, $value); |
|
| 779 | + $ret &= $this->psHandler->elementMatches($name, $node, $this->scopeNode, $value); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | return $ret; |