샘플
@xmldom/xmldom 0.8.13: DOMParser
검증된 샘플 — npm @xmldom/xmldom 0.8.13: DOMParser. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: @xmldom/xmldom.DOMParser parses XML string and…
sha256:7c4b7aef8fb678bc0ebca63918bd1c6e4ee098be694c684c54bb129ea53b8bc8
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-23 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
케이스
HOW- 목표
- verify @xmldom/xmldom.DOMParser in pkg:npm/%40xmldom/xmldom@0.8.13
- 심벌
-
- @xmldom/xmldom.DOMParser
- 환경
- node 22.23.2
- 생성일
- 2026-08-23T14:02:19Z
컨트랙트
- @xmldom/xmldom.DOMParser parses XML string and returns a DOM Document with documentElement and child nodes
- @xmldom/xmldom.DOMParser supports getElementsByTagName, getElementsByTagNameNS, and attribute retrieval on parsed elements
- @xmldom/xmldom.DOMParser supports custom errorHandler callbacks for warning, error, and fatalError
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify @xmldom/xmldom.DOMParser in pkg:npm/%40xmldom/xmldom@0.8.13
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40xmldom/xmldom@0.8.13
Demonstrate these symbols/APIs:
- @xmldom/xmldom.DOMParser
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:f39eacacfbd38bea5d9efd12522904abca6299749f53a89cc9f17facb205e2e3","contract":["@xmldom/xmldom.DOMParser parses XML string and returns a DOM Document with documentElement and child nodes","@xmldom/xmldom.DOMParser supports getElementsByTagName, getElementsByTagNameNS, and attribute retrieval on parsed elements","@xmldom/xmldom.DOMParser supports custom errorHandler callbacks for warning, error, and fatalError"],"goal":"verify @xmldom/xmldom.DOMParser in pkg:npm/%40xmldom/xmldom@0.8.13","kind":"HOW","packages":["pkg:npm/%40xmldom/xmldom@0.8.13"],"schemaVersion":1,"symbols":["@xmldom/xmldom.DOMParser"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40xmldom/xmldom@0.8.13"],"schemaVersion":1,"subject":"pkg:npm/%40xmldom/xmldom@0.8.13","symbols":["@xmldom/xmldom.DOMParser"],"verifierAdapter":"node-typescript@1"}
'use strict';
const { DOMParser } = require('@xmldom/xmldom');
/**
* Parses an XML string into a DOM Document using @xmldom/xmldom.DOMParser.
* @param {string} xmlString
* @param {string} [mimeType='text/xml']
* @param {object} [options]
* @returns {Document}
*/
function parseXml(xmlString, mimeType = 'text/xml', options = {}) {
const parser = new DOMParser(options);
return parser.parseFromString(xmlString, mimeType);
}
module.exports = {
DOMParser,
parseXml
};
{
"name": "sample-xmldom-domparser",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-xmldom-domparser",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@xmldom/xmldom": "0.8.13"
}
},
"node_modules/@xmldom/xmldom": {
"version": "0.8.13",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.13.tgz",
"integrity": "sha512-KRYzxepc14G/CEpEGc3Yn+JKaAeT63smlDr+vjB8jRfgTBBI9wRj/nkQEO+ucV8p8I9bfKLWp37uHgFrbntPvw==",
"deprecated": "this version has critical issues, please update to the latest version",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
}
}
}
}
{
"name": "sample-xmldom-domparser",
"version": "1.0.0",
"private": true,
"description": "verify @xmldom/xmldom.DOMParser in pkg:npm/%40xmldom/xmldom@0.8.13",
"main": "index.js",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"@xmldom/xmldom": "0.8.13"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify @xmldom/xmldom.DOMParser in pkg:npm/%40xmldom/xmldom@0.8.13",
"kind": "HOW",
"packages": [
"pkg:npm/%40xmldom/xmldom@0.8.13"
],
"symbols": [
"@xmldom/xmldom.DOMParser"
]
}
'use strict';
const assert = require('assert');
const { DOMParser } = require('@xmldom/xmldom');
const { parseXml } = require('../index.js');
function run() {
// 1. Basic XML parsing and document element inspection
const parser = new DOMParser();
const xml = '<library><book id="b1"><title>Clean Code</title><author>Robert Martin</author></book><book id="b2"><title>Refactoring</title><author>Martin Fowler</author></book></library>';
const doc = parser.parseFromString(xml, 'text/xml');
assert(doc, 'parseFromString should return a document object');
assert.strictEqual(doc.documentElement.nodeName, 'library', 'Root element should be library');
// 2. Element retrieval by tag name and attribute inspection
const books = doc.getElementsByTagName('book');
assert.strictEqual(books.length, 2, 'Should find two book elements');
assert.strictEqual(books[0].getAttribute('id'), 'b1', 'First book id should be b1');
assert.strictEqual(books[1].getAttribute('id'), 'b2', 'Second book id should be b2');
const titles = doc.getElementsByTagName('title');
assert.strictEqual(titles.length, 2, 'Should find two title elements');
assert.strictEqual(titles[0].textContent, 'Clean Code', 'First title text should match');
assert.strictEqual(titles[1].textContent, 'Refactoring', 'Second title text should match');
// 3. XML namespace handling
const nsXml = '<root xmlns:ns="http://example.com/ns"><ns:item name="sample">Namespaced Content</ns:item></root>';
const nsDoc = parser.parseFromString(nsXml, 'text/xml');
const items = nsDoc.getElementsByTagNameNS('http://example.com/ns', 'item');
assert.strictEqual(items.length, 1, 'Should find one namespaced item');
assert.strictEqual(items[0].getAttribute('name'), 'sample', 'Attribute name should match');
assert.strictEqual(items[0].textContent, 'Namespaced Content', 'Text content should match');
// 4. Helper function exported by index.js
const helperDoc = parseXml('<response status="ok"><data>Payload</data></response>');
assert.strictEqual(helperDoc.documentElement.nodeName, 'response', 'Helper parseXml should return valid doc');
assert.strictEqual(helperDoc.documentElement.getAttribute('status'), 'ok', 'Attribute status should be ok');
assert.strictEqual(helperDoc.getElementsByTagName('data')[0].textContent, 'Payload', 'Data text should match');
// 5. Custom errorHandler callback handling
const warnings = [];
const errorParser = new DOMParser({
errorHandler: {
warning: (w) => warnings.push(w),
error: (e) => {},
fatalError: (fe) => {}
}
});
errorParser.parseFromString('<unclosed><tag>', 'text/xml');
assert(warnings.length > 0, 'DOMParser should invoke custom errorHandler callbacks on malformed XML');
console.log('Contract tests passed successfully.');
}
try {
run();
process.exit(0);
} catch (err) {
console.error('Contract test failed:', err);
process.exit(1);
}
오리진 시더
익명