§

XML ஒட்டுங்கள்

§

விருப்பங்கள்

பயன்முறை
உள்தள்ளல்
XML அறிவிப்பு
சுய-மூடும் வெற்று குறிச்சொற்கள்
§

Format செய்யப்பட்ட வெளியீடு

xml

தமிழக backend developers XML உடன் பணிசெய்கிறார்கள் — RSS/Atom feeds, SOAP web services, Maven POM files மற்றும் SVG assets. ஒரு 500-வரி SOAP response debug செய்வது அல்லது sitemap.xml inspect செய்வது minified XML உடன் கடினம். இந்த formatter உங்கள் உலாவியில் DOMParser பயன்படுத்தி pretty-print செய்கிறது — XML உங்கள் கணினியை விட்டு வெளியேறுவதில்லை.

XML formatting என்றால் என்ன?

XML (Extensible Markup Language) என்பது structured ஆவணங்கள் மற்றும் data interchange க்கு W3C-standardised உரை வடிவம். Formatting — pretty-printing அல்லது beautifying என்றும் அழைக்கப்படுகிறது — ஒரு well-formed XML source எடுத்து மீண்டும் indent செய்கிறது, இதனால் ஒவ்வொரு element, attribute, comment, processing instruction மற்றும் CDATA section உம் ஸ்கேன் செய்ய எளிதாக இருக்கும். Parsed ஆவண tree சரியாக பாதுகாக்கப்படுகிறது; element களுக்கு இடையிலான whitespace மட்டுமே மாறுகிறது.

XML formatting எவ்வாறு வேலை செய்கிறது?

உங்கள் உள்ளீடு native DOMParser மற்றும் XMLSerializer APIs மற்றும் ஒரு custom recursive indenter பயன்படுத்தி முழுவதும் உங்கள் உலாவியில் செயலாக்கப்படுகிறது. உயர்-நிலை படிகள்:

  1. உங்கள் உள்ளீடு textarea இலிருந்து அப்படியே படிக்கப்படுகிறது — நீங்கள் ஒட்டிய ஒவ்வொரு byte உம் உள்ளூரில் நினைவகத்தில் வைக்கப்படுகிறது.
  2. Browser அதை new DOMParser().parseFromString(text, 'application/xml') உடன் parse செய்கிறது. உள்ளீடு well-formed ஆக இல்லாவிட்டால், parser இன் line மற்றும் column hints payload ஆக கொண்ட <parsererror> node embed செய்கிறது — அவை error strip ல் அப்படியே காட்டப்படுகின்றன.
  3. வெற்றிகரமான parse ல், custom indenter DOM tree ஐ depth-first நடந்து ஒவ்வொரு element, attribute set, CDATA section, comment மற்றும் processing instruction ஐயும் தற்போதைய depth ல் சொந்த வரியில் வெளியிடுகிறது. Option on ஆக இருக்கும்போது self-closing void tags மதிக்கப்படுகின்றன.
  4. Minify பயன்முறை pipeline ஐ flip செய்கிறது: XMLSerializer().serializeToString(doc) single-line form வெளியிடுகிறது, பின்னர் ஒரு guarded regex CDATA blocks அல்லது non-whitespace text nodes க்குள் தொட்டிருக்காமல் inter-element whitespace நீக்குகிறது.
  5. வெளியீடு readonly textarea க்கு எழுதப்படுகிறது, error strip அழிக்கப்படுகிறது, மற்றும் Download பொத்தான் முடிவை ticket க்கு ship அல்லது attach செய்யக்கூடிய .xml கோப்பாக package செய்கிறது.

இந்த கருவியால் XML ஐ ஏன் pretty-print செய்யவேண்டும்?

  • Privacy: ஒவ்வொரு parse, format மற்றும் minify pass உம் உங்கள் உலாவியில் நடக்கிறது. XML ஒருபோதும் எங்கள் servers ஐ அடைவதில்லை — upload இல்லை, telemetry இல்லை, account இல்லை.
  • Precise errors: உள்ளீடு malformed ஆக இருக்கும்போது, parser browser இயந்திரமே தெரிவிக்கும் சரியான line மற்றும் column காட்டுகிறது, synthetic guess அல்ல — DevTools ல் நீங்கள் பார்க்கும் அதே எண்கள்.
  • Faithful round-trip: format செய்து பின்னர் minify செய்தால் உங்கள் அசல் ஆவணத்தின் byte-equivalent திரும்பப்படுகிறது (XML declaration option தவிர) — formatting namespace களை re-canonicalise அல்லது attribute order மீண்டும் எழுதுவதில்லை.
  • வேகமான: pure DOMParser plus ~60-line indenter multi-megabyte SOAP envelopes மற்றும் OOXML chunks ஐ download செய்ய வேண்டிய external library இல்லாமல் உடனடியாக கையாளுகிறது.

XML formatting இன் பொதுவான பயன்பாடுகள் என்ன?

XML ஐ pretty-printing செய்வது web publishing, enterprise integration மற்றும் data archival முழுவதும் தோன்றுகிறது:

  • RSS / Atom feed inspection: channel metadata, item ordering மற்றும் namespace prefixes publish செய்வதற்கு முன்பு உறுதிசெய்ய podcast அல்லது news feed body ஒட்டவும்.
  • SOAP debugging: Header, Body மற்றும் Fault sections ஒரே பார்வையில் கண்ணுக்கு தெரியும்படி Wireshark அல்லது SOAP client log இலிருந்து copy செய்த envelope format செய்யவும்.
  • Sitemap auditing: entries எண்ணி URL-க்கு hreflang alternates உறுதிசெய்ய competitor அல்லது உங்கள் சொந்த staging site இலிருந்து fetch செய்த sitemap.xml ஐ மீண்டும் indent செய்யவும்.

XML formatting எடுத்துக்காட்டு எப்படி இருக்கும்?

3-element <feed><entry><title>Hello</title></entry></feed> ஒட்டி 2-space indent option உடன் Format அழுத்துவது depth ஆல் indent செய்யப்பட்ட, ஒவ்வொரு element அதன் சொந்த வரியில் உள்ள நான்கு-வரி ஆவணம் தருகிறது. அதே உள்ளீட்டிற்கு Minify க்கு மாறுவது அதை அசல் byte-string க்கு மீண்டும் சுருக்குகிறது. Round-tripping எந்த well-formed ஆவணத்திற்கும் loss-free.

இது offline இல் இயங்குகிறதா?

ஆம். Format மற்றும் minify pipeline pure DOMParser + XMLSerializer plus சிறிய recursive indenter, எல்லாமே browser tab க்குள் இயங்குகிறது. எதுவும் பதிவேற்றப்படவில்லை, எந்த service worker உம் உங்கள் உள்ளீட்டை proxy செய்யவில்லை, மற்றும் பக்கம் format step க்கு பூஜ்ய நெட்வொர்க் requests செய்கிறது. ஒரே outbound traffic நிலையான page-load assets (CSS, fonts, analytics) — உங்கள் XML ஒருபோதும் Ultim8Soft ஐ அடைவதில்லை.

Formatting ஆவணத்தை மாற்றுகிறதா?

Semantic மாற்றம் இல்லை. Formatting elements க்கு இடையிலான whitespace மட்டுமே மீண்டும் எழுதுகிறது. Element names, attribute values, text content, CDATA payloads, comments மற்றும் processing instructions byte-for-byte பாதுகாக்கப்படுகின்றன. Namespace declarations மற்றும் prefixes உள்ளீடு எழுதியவாறே வைக்கப்படுகின்றன — formatter attributes ஐ re-canonicalise அல்லது reorder செய்வதில்லை. வெளியீடு optional XML declaration toggle தவிர உள்ளீட்டை போல் அதே DOM tree க்கு parse ஆகிறது.

CDATA / comments / processing instructions எவ்வாறு கையாளப்படுகின்றன?

ஒவ்வொன்றும் தற்போதைய indent depth ல் சொந்த வரியில் அப்படியே வெளியிடப்படுகிறது. CDATA payloads <![CDATA[…]]> ல் wrap செய்யப்படுகின்றன, உள்ளே மீண்டும் indent இல்லாமல் — spec CDATA content opaque என்று சொல்கிறது, எனவே formatter ஒருபோதும் தொடுவதில்லை. Comments <!-- … --> பயன்படுத்துகின்றன; processing instructions <?target data?> பயன்படுத்துகின்றன. மூன்றும் format → minify → format round-trip ல் உள்ளடக்கம் intact ஆக உயிர்வாழ்கின்றன.

XML ஐ formatting மற்றும் minifying க்கு இடையில் என்ன வித்தியாசம்?

Formatting மனிதர்கள் ஆவண tree படிக்கக்கூடியதாக whitespace expand செய்கிறது; minifying transport மற்றும் storage க்கு அதை திரும்ப நீக்குகிறது. இரண்டும் raw byte string ல் அல்ல, parsed DOM ல் செயல்படுகின்றன, எனவே well-formed ஆவணத்தில் round-trip format → minify அசல் minified form இன் byte-equivalent தருகிறது. XML payload படிக்கவோ diff செய்யவோ வேண்டும்போது format direction பயன்படுத்துங்கள், metered API gateway வழியாக ship செய்யவோ வேறு ஆவணத்தில் embed செய்யவோ வேண்டும்போது minify direction பயன்படுத்துங்கள்.

இந்த XML formatter உங்கள் browser AJAX XHR responses மற்றும் SVG ஆவணங்களுக்கு பயன்படுத்தும் அதே parser பயன்படுத்துகிறது, எனவே எந்த well-formed XML உம் — RSS, Atom, SOAP, sitemap, OOXML, SVG — சுத்தமாக round-trip ஆகிறது. மேலே எந்த XML ஐயும் ஒட்டுங்கள், வெளியீட்டை நகலெடுங்கள், அல்லது .xml ஆக பதிவிறக்கவும்.