Skip to content

Commit 6ab32f7

Browse files
committed
fix namespace prefixes
1 parent 94a376d commit 6ab32f7

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/Record.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class Record
1919
/** @var QuiteSimpleXMLElement */
2020
public $data;
2121

22-
static $recordTpl = '<srw:record xmlns:srw="http://www.loc.gov/zing/srw/">
23-
<srw:recordSchema>{{recordSchema}}</srw:recordSchema>
24-
<srw:recordPacking>{{recordPacking}}</srw:recordPacking>
25-
<srw:recordPosition>{{position}}</srw:recordPosition>
26-
<srw:recordData>{{data}}</srw:recordData>
27-
</srw:record>';
22+
static $recordTpl = '<s:record xmlns:s="http://www.loc.gov/zing/srw/">
23+
<s:recordSchema>{{recordSchema}}</s:recordSchema>
24+
<s:recordPacking>{{recordPacking}}</s:recordPacking>
25+
<s:recordPosition>{{position}}</s:recordPosition>
26+
<s:recordData>{{data}}</s:recordData>
27+
</s:record>';
2828

2929
/**
3030
* Create a new record
@@ -53,6 +53,6 @@ public static function make($position, $data, $recordSchema='marcxchange', $reco
5353
self::$recordTpl
5454
);
5555

56-
return new Record(new QuiteSimpleXMLElement($record));
56+
return new Record(QuiteSimpleXMLElement::make($record, Response::$nsPrefixes));
5757
}
5858
}

src/Response.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
*/
88
class Response implements ResponseInterface
99
{
10+
public static $nsPrefixes = array(
11+
'srw' => 'http://www.loc.gov/zing/srw/',
12+
'exp' => 'http://explain.z3950.org/dtd/2.0/',
13+
'd' => 'http://www.loc.gov/zing/srw/diagnostic/',
14+
);
15+
1016
public static $errorMessages = array(
1117
'info:srw/diagnostic/1/1' => 'General system error',
1218
'info:srw/diagnostic/1/2' => 'System temporarily unavailable',
@@ -127,11 +133,7 @@ protected function initializeFromText($text)
127133
$this->rawResponse = $text;
128134

129135
// Throws Danmichaelo\QuiteSimpleXMLElement\InvalidXMLException on invalid xml
130-
$this->response = QuiteSimpleXMLElement::make($text, array(
131-
'srw' => 'http://www.loc.gov/zing/srw/',
132-
'exp' => 'http://explain.z3950.org/dtd/2.0/',
133-
'd' => 'http://www.loc.gov/zing/srw/diagnostic/',
134-
));
136+
$this->response = QuiteSimpleXMLElement::make($text, self::$nsPrefixes);
135137

136138
$this->version = $this->response->text('/srw:*/srw:version');
137139

0 commit comments

Comments
 (0)