Skip to content

Commit 4416e37

Browse files
committed
fix getrecords xml, rename index.js to example_requests.js
1 parent c146f0e commit 4416e37

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cswrequests.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export async function fetchDescribeRecord(url, cswVersion) {
166166
function fetchRecordsXML(cswVersion, elementSetName, startPosition, maxRecords, constraint) {
167167
//return `<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows" outputSchema="http://www.opengis.net/cat/csw/2.0.2" outputFormat="application/xml" version="2.0.2" resultType="results" service="CSW" maxRecords="10" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd"><csw:Query typeNames="csw:Record"><csw:ElementSetName>summary</csw:ElementSetName><csw:Constraint version="1.1.0"><ogc:Filter><ogc:PropertyIsLike wildCard="*" singleChar="_" escapeChar="\\"><ogc:PropertyName>csw:AnyText</ogc:PropertyName><ogc:Literal>*None*</ogc:Literal></ogc:PropertyIsLike></ogc:Filter></csw:Constraint></csw:Query></csw:GetRecords>`
168168
return `<?xml version="1.0" encoding="UTF-8"?>
169-
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="${cswVersion}" resultType="results" startPosition="${startPosition}" maxRecords="${maxRecords}" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
169+
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="${cswVersion}" resultType="results" startPosition="${startPosition}" maxRecords="${maxRecords}" outputSchema="http://www.opengis.net/cat/csw/2.0.2" outputFormat="application/xml"
170+
xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
170171
<csw:Query typeNames="csw:Record">
171172
<csw:ElementSetName>${elementSetName}</csw:ElementSetName>
172173
</csw:Query>
@@ -177,20 +178,21 @@ export async function fetchGetRecords(url, cswVersion, elementSetName, serviceSe
177178
try {
178179
const params = []
179180
const preparedUrl = prepareUrl(url, params);
181+
const requestXML = fetchRecordsXML(cswVersion, elementSetName, 1, 10, '');
180182

181183
const response = await fetch(preparedUrl.href, {
182184
method: 'POST',
183185
headers: {
184186
'User-Agent': 'JS CSW Client/0.1',
185187
'Content-Type': 'text/xml',
186188
},
187-
body: fetchRecordsXML(cswVersion, elementSetName, 1, 10, '')
189+
body: requestXML
188190
});
189191
if (!response.ok) {
190192
throw new Error(`HTTP error! status: ${response.status}`);
191193
}
192194
const text = await response.text();
193-
console.log(text);
195+
//console.log(text);
194196
const cswRecords = await parseXml(text);
195197
let xmlRecordName;
196198
switch(elementSetName) {
File renamed without changes.

0 commit comments

Comments
 (0)