샘플
@xmldom/xmldom 0.8.13: XMLSerializer
검증된 샘플 — npm @xmldom/xmldom 0.8.13: XMLSerializer. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: XMLSerializer instance serializes a DOM…
sha256:0d23ff0511e419682567775db4692666b7ad3ebf770108957c97f0f47be7c87e
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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.XMLSerializer in pkg:npm/%40xmldom/xmldom@0.8.13
- 심벌
-
- @xmldom/xmldom.XMLSerializer
- 생성일
- 2026-08-23T14:04:49Z
컨트랙트
- XMLSerializer instance serializes a DOM Document node with elements, attributes, and text into a well-formed XML string
- XMLSerializer serializes individual DOM Element and DocumentFragment nodes into XML string representations
- XMLSerializer serializes Comment, CDATASection, and Text nodes accurately preserving their content
- XMLSerializer correctly serializes XML namespaces and escapes special characters in attributes and text
- XMLSerializer correctly formats self-closing empty XML elements
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
소스
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.XMLSerializer 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.XMLSerializer
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:b96c754bc31126b2c577b04536bc727931689998d9e9ab9415544499fd746513","contract":["XMLSerializer instance serializes a DOM Document node with elements, attributes, and text into a well-formed XML string","XMLSerializer serializes individual DOM Element and DocumentFragment nodes into XML string representations","XMLSerializer serializes Comment, CDATASection, and Text nodes accurately preserving their content","XMLSerializer correctly serializes XML namespaces and escapes special characters in attributes and text","XMLSerializer correctly formats self-closing empty XML elements"],"goal":"verify @xmldom/xmldom.XMLSerializer in pkg:npm/%40xmldom/xmldom@0.8.13","kind":"HOW","packages":["pkg:npm/%40xmldom/xmldom@0.8.13"],"schemaVersion":1,"symbols":["@xmldom/xmldom.XMLSerializer"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","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.XMLSerializer"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-xmldom-xmlserializer",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-xmldom-xmlserializer",
"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==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
}
}
}
}
{
"name": "sample-xmldom-xmlserializer",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"@xmldom/xmldom": "0.8.13"
}
}
{
"schemaVersion": 1,
"goal": "verify @xmldom/xmldom.XMLSerializer in pkg:npm/%40xmldom/xmldom@0.8.13",
"kind": "HOW",
"packages": [
"pkg:npm/%40xmldom/xmldom@0.8.13"
],
"symbols": [
"@xmldom/xmldom.XMLSerializer"
]
}
import { XMLSerializer, DOMParser } from '@xmldom/xmldom';
export function createSerializer() {
return new XMLSerializer();
}
export function serializeNode(node) {
const serializer = new XMLSerializer();
return serializer.serializeToString(node);
}
export function parseAndSerialize(xmlString, mimeType = 'text/xml') {
const parser = new DOMParser();
const doc = parser.parseFromString(xmlString, mimeType);
const serializer = new XMLSerializer();
return serializer.serializeToString(doc);
}
import assert from 'node:assert/strict';
import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
import {
createSerializer,
serializeNode,
parseAndSerialize
} from '../src/index.mjs';
const parser = new DOMParser();
const serializer = createSerializer();
// Assertion 1: XMLSerializer instance serializes a DOM Document node with elements, attributes, and text into a well-formed XML string
{
const xml = '<catalog><book id="bk101"><title>XML Developers Guide</title><price>44.95</price></book></catalog>';
const doc = parser.parseFromString(xml, 'text/xml');
const serialized = serializer.serializeToString(doc);
assert.equal(serialized, xml, 'Document serialization should match original XML');
assert.equal(parseAndSerialize(xml), xml, 'parseAndSerialize should produce identical output');
}
// Assertion 2: XMLSerializer serializes individual DOM Element and DocumentFragment nodes into XML string representations
{
const xml = '<root><header>Header Text</header><content>Body Text</content></root>';
const doc = parser.parseFromString(xml, 'text/xml');
const headerElem = doc.getElementsByTagName('header')[0];
const headerXml = serializeNode(headerElem);
assert.equal(headerXml, '<header>Header Text</header>', 'Element serialization should produce element XML');
const docFrag = doc.createDocumentFragment();
const fragChild = doc.createElement('fragment-item');
fragChild.setAttribute('status', 'active');
fragChild.textContent = 'Fragment Content';
docFrag.appendChild(fragChild);
const fragXml = serializer.serializeToString(docFrag);
assert.equal(fragXml, '<fragment-item status="active">Fragment Content</fragment-item>', 'DocumentFragment serialization should serialize child elements');
}
// Assertion 3: XMLSerializer serializes Comment, CDATASection, and Text nodes accurately preserving their content
{
const xml = '<container><!-- A valid comment --><![CDATA[<raw-data>&value</raw-data>]]><info>Sample text</info></container>';
const doc = parser.parseFromString(xml, 'text/xml');
const serialized = serializer.serializeToString(doc);
assert.ok(serialized.includes('<!-- A valid comment -->'), 'Comment should be serialized correctly');
assert.ok(serialized.includes('<![CDATA[<raw-data>&value</raw-data>]]>'), 'CDATASection should be serialized correctly');
assert.ok(serialized.includes('<info>Sample text</info>'), 'Text node in element should be serialized correctly');
}
// Assertion 4: XMLSerializer correctly serializes XML namespaces and escapes special characters in attributes and text
{
const xml = '<ns:root xmlns:ns="https://example.com/ns" attr="A & B "quoted""><ns:node><unescaped-tag> & symbol</ns:node></ns:root>';
const doc = parser.parseFromString(xml, 'text/xml');
const serialized = serializer.serializeToString(doc);
assert.ok(serialized.includes('xmlns:ns="https://example.com/ns"'), 'Namespace definition should be preserved');
assert.ok(serialized.includes('attr="A & B "quoted""'), 'Attribute special characters should be escaped');
assert.ok(serialized.includes('<unescaped-tag> & symbol'), 'Text special characters should be escaped');
}
// Assertion 5: XMLSerializer correctly formats self-closing empty XML elements
{
const xml = '<root><empty/><item flag="true"/><nested><emptyLeaf/></nested></root>';
const doc = parser.parseFromString(xml, 'text/xml');
const serialized = serializer.serializeToString(doc);
assert.equal(serialized, xml, 'Empty elements should be serialized as self-closing tags');
}
오리진 시더
익명