SyntaxStudy
Sign Up
XML Understanding XML Namespaces
XML Beginner 1 min read

Understanding XML Namespaces

XML namespaces solve the problem of name collisions when combining XML vocabularies from different sources. When two vocabularies both define an element named — for example, Dublin Core metadata and an HTML-like vocabulary — a namespace provides a way to distinguish between them. A namespace is identified by a URI (Uniform Resource Identifier), which acts as a globally unique name. The URI does not need to point to any resource; it is used purely as a unique identifier. Namespaces are declared using the xmlns attribute. A default namespace declaration (xmlns="http://example.com/ns") applies to the element it is declared on and all its descendants that do not themselves declare a namespace or a different default. A prefixed namespace declaration (xmlns:dc="http://purl.org/dc/elements/1.1/") binds the prefix dc to that namespace URI. Elements and attributes using that prefix — such as <dc:title> — belong to the corresponding namespace. The expanded name of an element is the combination of its namespace URI and its local name. When comparing element names in namespace-aware processing — as in XSLT, XPath, or a validating parser — it is the expanded name that matters, not the prefix. Two prefixes bound to the same URI are interchangeable; two prefixes bound to different URIs are distinct even if the local names match. </article> <div class="my-4 text-center ad-slot" aria-label="Advertisement"> <!-- AD SLOT: in-article (replace with your AdSense/Monetag code) --> </div> <div class="example-box mt-4" id="code-example"> <div class="example-box-header"> <i class="fa-solid fa-code"></i> Example </div> <div class="example-box-body relative group"> <button onclick="copyCode(this)" class="copy-btn absolute top-3 right-3 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity"> <i class="fa-regular fa-copy text-xs"></i> Copy </button> <pre class="language-html"><code class="language-html"><?xml version="1.0" encoding="UTF-8"?> <!-- Combining two vocabularies: a book record with Dublin Core metadata and a custom inventory namespace. --> <inventory xmlns="http://example.com/inventory" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com/inventory inventory.xsd"> <!-- Default namespace: 'item' belongs to example.com/inventory --> <item id="i001"> <!-- Prefixed namespace: dc:title belongs to Dublin Core --> <dc:title>XML in a Nutshell</dc:title> <dc:creator>Elliotte Rusty Harold</dc:creator> <dc:date>2004-06-01</dc:date> <dc:format>Book</dc:format> <!-- Local vocabulary elements (default namespace) --> <quantity>12</quantity> <location>Shelf B-4</location> </item> </inventory></code></pre> </div> <div class="example-box-footer dark:bg-gray-800/60"> <span class="text-xs text-gray-400 flex items-center gap-1.5"> <i class="fa-solid fa-file-code text-gray-300"></i> HTML </span> <div class="flex items-center gap-2"> <button onclick="toggleTryIt()" id="tryit-toggle-btn" class="try-it-btn"> <i class="fa-solid fa-play"></i> Try it Yourself » </button> <a href="https://syntaxstudy.com/editor/xml-namespaces-1" target="_blank" class="inline-flex items-center gap-1.5 text-xs text-gray-400 hover:text-brand transition-colors px-2 py-1 rounded border border-gray-200 dark:border-gray-700" title="Open in full editor"> <i class="fa-solid fa-up-right-from-square text-xs"></i> Full Editor </a> </div> </div> </div> <div id="tryit-panel" class="tryit-panel" style="display:none"> <div class="tryit-panel-header"> <span class="font-semibold text-sm flex items-center gap-2"> <i class="fa-solid fa-laptop-code"></i> Try it Yourself </span> <div class="flex items-center gap-2"> <button onclick="runTryIt()" class="tryit-run-btn"> <i class="fa-solid fa-play text-xs"></i> Run </button> <button onclick="resetTryIt()" class="tryit-reset-btn"> <i class="fa-solid fa-rotate-left text-xs"></i> Reset </button> <button onclick="toggleTryIt()" class="tryit-close-btn" title="Close"> <i class="fa-solid fa-xmark"></i> </button> </div> </div> <div class="tryit-body"> <div class="tryit-editor-col"> <div class="tryit-col-label">Code</div> <textarea id="tryit-code" class="tryit-textarea" spellcheck="false"></textarea> </div> <div class="tryit-preview-col"> <div class="tryit-col-label">Result</div> <iframe id="tryit-frame" class="tryit-frame" sandbox="allow-scripts allow-same-origin"></iframe> </div> </div> </div> <div class="mt-10 pt-6 border-t border-gray-100 dark:border-gray-800"> <h3 class="text-sm font-bold text-gray-700 dark:text-gray-300 uppercase tracking-wider mb-4 flex items-center gap-2"> <i class="fa-solid fa-link text-brand text-xs"></i> Related Resources </h3> <div class="grid sm:grid-cols-3 gap-3"> <a href="https://syntaxstudy.com/references/xml" class="flex items-center gap-3 p-3 rounded-xl border border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900 hover:border-brand hover:bg-brand/5 transition-all group"> <span class="w-8 h-8 rounded-lg flex items-center justify-center shrink-0" style="background:#0060ac18"> <i class="fa-solid fa-file-code text-xs" style="color:#0060ac"></i> </span> <div class="min-w-0"> <div class="text-xs font-semibold text-gray-700 dark:text-gray-300 group-hover:text-brand transition-colors">XML Reference</div> <div class="text-xs text-gray-400">Complete tag & property list</div> </div> </a> <a href="https://syntaxstudy.com/howtos?category=xml" class="flex items-center gap-3 p-3 rounded-xl border border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900 hover:border-brand hover:bg-brand/5 transition-all group"> <span class="w-8 h-8 rounded-lg bg-amber-50 dark:bg-amber-900/20 flex items-center justify-center shrink-0"> <i class="fa-solid fa-list-check text-amber-500 text-xs"></i> </span> <div class="min-w-0"> <div class="text-xs font-semibold text-gray-700 dark:text-gray-300 group-hover:text-brand transition-colors">XML How-To Guides</div> <div class="text-xs text-gray-400">Step-by-step practical guides</div> </div> </a> <a href="https://syntaxstudy.com/exercises/xml" class="flex items-center gap-3 p-3 rounded-xl border border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900 hover:border-brand hover:bg-brand/5 transition-all group"> <span class="w-8 h-8 rounded-lg bg-indigo-50 dark:bg-indigo-900/20 flex items-center justify-center shrink-0"> <i class="fa-solid fa-dumbbell text-indigo-500 text-xs"></i> </span> <div class="min-w-0"> <div class="text-xs font-semibold text-gray-700 dark:text-gray-300 group-hover:text-brand transition-colors">XML Exercises</div> <div class="text-xs text-gray-400">Practice what you've learned</div> </div> </a> </div> <div class="mt-4 xl:hidden"> <p class="text-xs text-gray-400 uppercase tracking-wider font-semibold mb-2">More in XML</p> <div class="flex flex-wrap gap-2"> <a href="https://syntaxstudy.com/xml/introduction/xml-intro-1" class="text-xs px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-brand hover:text-brand transition-colors"> XML Introduction </a> <a href="https://syntaxstudy.com/xml/syntax/xml-syntax-1" class="text-xs px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-brand hover:text-brand transition-colors"> XML Syntax </a> <a href="https://syntaxstudy.com/xml/elements/xml-elements-1" class="text-xs px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-brand hover:text-brand transition-colors"> Elements & Attributes </a> <a href="https://syntaxstudy.com/xml/dtd/xml-dtd-1" class="text-xs px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-brand hover:text-brand transition-colors"> DTD </a> <a href="https://syntaxstudy.com/xml/schema/xml-schema-1" class="text-xs px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-brand hover:text-brand transition-colors"> XML Schema (XSD) </a> <a href="https://syntaxstudy.com/xml/xpath/xml-xpath-1" class="text-xs px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-brand hover:text-brand transition-colors"> XPath </a> </div> </div> </div> <div class="flex items-center justify-between gap-4 mt-6 pt-6 border-t border-gray-100 dark:border-gray-800"> <a href="https://syntaxstudy.com/xml/elements/xml-elements-3" class="nav-btn max-w-[220px]"> <i class="fa-solid fa-arrow-left flex-shrink-0"></i> <div class="text-left min-w-0"> <div class="text-xs text-gray-400 font-normal">Previous</div> <div class="truncate text-sm">Attributes vs Child Elements — Design Decisions</div> </div> </a> <a href="https://syntaxstudy.com/xml/namespaces/xml-namespaces-2" class="nav-btn max-w-[220px] flex-row-reverse text-right"> <i class="fa-solid fa-arrow-right flex-shrink-0"></i> <div class="text-right min-w-0"> <div class="text-xs text-gray-400 font-normal">Next</div> <div class="truncate text-sm">Default and Prefixed Namespace Declarations</div> </div> </a> </div> </div> <aside class="hidden xl:block w-64 flex-shrink-0"> <div class="sticky top-24"> <div class="bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 overflow-hidden shadow-sm"> <div class="bg-gray-50 dark:bg-gray-800 px-4 py-3 border-b border-gray-200 dark:border-gray-700"> <h3 class="text-xs font-bold text-gray-700 dark:text-gray-300 uppercase tracking-wider flex items-center gap-2"> <i class="fa-solid fa-list-ul text-brand"></i> XML Namespaces </h3> </div> <div class="max-h-[70vh] overflow-y-auto divide-y divide-gray-50 dark:divide-gray-800"> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">XML Introduction</span> </div> <a href="https://syntaxstudy.com/xml/introduction/xml-intro-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">What Is XML and Why It Matters</span> </a> <a href="https://syntaxstudy.com/xml/introduction/what-is-xml" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Introduction to XML</span> </a> <a href="https://syntaxstudy.com/xml/introduction/xml-intro-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">The XML Prolog and Declaration</span> </a> <a href="https://syntaxstudy.com/xml/introduction/xml-intro-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Well-Formed vs Valid XML Documents</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">XML Syntax</span> </div> <a href="https://syntaxstudy.com/xml/syntax/xml-syntax-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Elements, Attributes, and Text Nodes</span> </a> <a href="https://syntaxstudy.com/xml/syntax/xml-syntax" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XML Syntax Rules</span> </a> <a href="https://syntaxstudy.com/xml/syntax/xml-syntax-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">CDATA Sections and Comments</span> </a> <a href="https://syntaxstudy.com/xml/syntax/xml-syntax-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Entity References and Special Characters</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">Elements & Attributes</span> </div> <a href="https://syntaxstudy.com/xml/elements/xml-elements-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Element Content Models</span> </a> <a href="https://syntaxstudy.com/xml/elements/xml-elements-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Element Naming Rules and Best Practices</span> </a> <a href="https://syntaxstudy.com/xml/elements/xml-elements-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Attributes vs Child Elements — Design Decisions</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">XML Namespaces</span> </div> <a href="https://syntaxstudy.com/xml/namespaces/xml-namespaces-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors bg-brand/5 dark:bg-brand/10 text-brand dark:text-green-400 font-semibold"> <i class="fa-solid fa-circle text-brand flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Understanding XML Namespaces</span> </a> <a href="https://syntaxstudy.com/xml/namespaces/xml-namespaces-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Default and Prefixed Namespace Declarations</span> </a> <a href="https://syntaxstudy.com/xml/namespaces/xml-namespaces-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Namespace-Aware Parsing in Practice</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">DTD</span> </div> <a href="https://syntaxstudy.com/xml/dtd/xml-dtd-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Introduction to Document Type Definitions</span> </a> <a href="https://syntaxstudy.com/xml/dtd/xml-dtd-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">DTD Attribute Types and Defaults</span> </a> <a href="https://syntaxstudy.com/xml/dtd/xml-dtd-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">External DTDs and Entity Declarations</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">XML Schema (XSD)</span> </div> <a href="https://syntaxstudy.com/xml/schema/xml-schema-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XML Schema (XSD) Basics</span> </a> <a href="https://syntaxstudy.com/xml/schema/xml-schema-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XSD Simple Types and Facets</span> </a> <a href="https://syntaxstudy.com/xml/schema/xml-schema-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XSD Complex Types, Keys, and References</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">XPath</span> </div> <a href="https://syntaxstudy.com/xml/xpath/xml-xpath-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XPath Syntax and Location Paths</span> </a> <a href="https://syntaxstudy.com/xml/xpath/xml-xpath-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XPath Axes and Node Tests</span> </a> <a href="https://syntaxstudy.com/xml/xpath/xml-xpath-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XPath Functions and Expressions</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">XSLT</span> </div> <a href="https://syntaxstudy.com/xml/xslt/xml-xslt-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">Introduction to XSLT Templates</span> </a> <a href="https://syntaxstudy.com/xml/xslt/xml-xslt-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XSLT Control Structures and Variables</span> </a> <a href="https://syntaxstudy.com/xml/xslt/xml-xslt-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XSLT Identity Transform and Modes</span> </a> <div class="px-4 pt-3 pb-1"> <span class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">Parsing XML</span> </div> <a href="https://syntaxstudy.com/xml/parsing/xml-parsing-1" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">DOM Parsing with Python xml.etree.ElementTree</span> </a> <a href="https://syntaxstudy.com/xml/parsing/xml-parsing-2" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">SAX Parsing with Python xml.sax</span> </a> <a href="https://syntaxstudy.com/xml/parsing/xml-parsing-3" class="flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"> <i class="fa-regular fa-circle text-gray-300 dark:text-gray-600 flex-shrink-0" style="font-size:7px"></i> <span class="flex-1 leading-snug">XML Parsing in Java: DOM and SAX</span> </a> </div> </div> </div> </aside> </div> </main> <!-- Footer --> <footer class="bg-white dark:bg-gray-900 border-t border-gray-200 dark:border-gray-800 mt-auto"> <div class="max-w-screen-xl mx-auto px-6 py-8 grid grid-cols-1 sm:grid-cols-3 gap-8"> <div> <div class="flex items-center gap-2 mb-3"> <span class="bg-brand rounded-lg w-7 h-7 flex items-center justify-center" aria-hidden="true"> <i class="fa-solid fa-code text-white text-xs"></i> </span> <span class="font-bold text-gray-900 dark:text-white text-lg">SyntaxStudy</span> </div> <p class="text-gray-500 dark:text-gray-400 text-sm leading-relaxed"> Free, beginner-friendly tutorials for web development. Learn at your own pace, anywhere. </p> </div> <div> <h3 class="text-sm font-semibold text-gray-900 dark:text-white mb-3 uppercase tracking-wide">Tutorials</h3> <div class="grid grid-cols-2 gap-1"> <a href="https://syntaxstudy.com/html/introduction/what-is-html" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">HTML</a> <a href="https://syntaxstudy.com/css/introduction/what-is-css" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">CSS</a> <a href="https://syntaxstudy.com/javascript/introduction/what-is-javascript" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">JavaScript</a> <a href="https://syntaxstudy.com/php/introduction/what-is-php" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">PHP</a> <a href="https://syntaxstudy.com/python/introduction/what-is-python" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Python</a> <a href="https://syntaxstudy.com/mysql/introduction/what-is-mysql" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">MySQL</a> <a href="https://syntaxstudy.com/bootstrap/introduction/what-is-bootstrap" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Bootstrap</a> <a href="https://syntaxstudy.com/jquery/introduction/what-is-jquery" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">jQuery</a> <a href="https://syntaxstudy.com/typescript/introduction/what-is-typescript" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">TypeScript</a> <a href="https://syntaxstudy.com/react/introduction/react-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">React</a> <a href="https://syntaxstudy.com/vue/introduction/what-is-vue" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Vue.js</a> <a href="https://syntaxstudy.com/nodejs/introduction/what-is-nodejs" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Node.js</a> <a href="https://syntaxstudy.com/git/introduction/what-is-git" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Git</a> <a href="https://syntaxstudy.com/linux/introduction/linux-intro" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Linux / Bash</a> <a href="https://syntaxstudy.com/mongodb/introduction/mongo-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">MongoDB</a> <a href="https://syntaxstudy.com/docker/introduction/what-is-docker" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Docker</a> <a href="https://syntaxstudy.com/java/introduction/what-is-java" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Java</a> <a href="https://syntaxstudy.com/c/introduction/c-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">C</a> <a href="https://syntaxstudy.com/cpp/introduction/what-is-cpp" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">C++</a> <a href="https://syntaxstudy.com/csharp/introduction/what-is-csharp" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">C#</a> <a href="https://syntaxstudy.com/go/introduction/what-is-go" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Go</a> <a href="https://syntaxstudy.com/rust/introduction/what-is-rust" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Rust</a> <a href="https://syntaxstudy.com/kotlin/introduction/kotlin-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Kotlin</a> <a href="https://syntaxstudy.com/swift/introduction/swift-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Swift</a> <a href="https://syntaxstudy.com/sass/introduction/what-is-sass" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">SASS / SCSS</a> <a href="https://syntaxstudy.com/tailwind/introduction/what-is-tailwind" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Tailwind CSS</a> <a href="https://syntaxstudy.com/django/introduction/django-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Django</a> <a href="https://syntaxstudy.com/nextjs/introduction/what-is-nextjs" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Next.js</a> <a href="https://syntaxstudy.com/laravel/introduction/laravel-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Laravel</a> <a href="https://syntaxstudy.com/graphql/introduction/what-is-graphql" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">GraphQL</a> <a href="https://syntaxstudy.com/rest-api/introduction/what-is-rest" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">REST API</a> <a href="https://syntaxstudy.com/r/introduction/r-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">R</a> <a href="https://syntaxstudy.com/xml/introduction/xml-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">XML</a> <a href="https://syntaxstudy.com/web-security/introduction/security-intro" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Web Security</a> <a href="https://syntaxstudy.com/postgresql/introduction/pg-intro-1" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">PostgreSQL</a> <a href="https://syntaxstudy.com/express/introduction/what-is-express" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors">Express.js</a> </div> </div> <div> <h3 class="text-sm font-semibold text-gray-900 dark:text-white mb-3 uppercase tracking-wide">Tools</h3> <ul class="space-y-1"> <li><a href="https://syntaxstudy.com/editor" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2"><i class="fa-solid fa-code w-4" aria-hidden="true"></i> Code Editor</a></li> <li><a href="https://syntaxstudy.com/search" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2"><i class="fa-solid fa-magnifying-glass w-4" aria-hidden="true"></i> Search</a></li> <li><a href="https://syntaxstudy.com/register" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2"><i class="fa-solid fa-user-plus w-4" aria-hidden="true"></i> Create Account</a></li> </ul> </div> <div> <h3 class="text-sm font-semibold text-gray-900 dark:text-white mb-3 uppercase tracking-wide">Company</h3> <ul class="space-y-1"> <li><a href="https://syntaxstudy.com/about" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2"><i class="fa-solid fa-circle-info w-4" aria-hidden="true"></i> About</a></li> <li><a href="https://syntaxstudy.com/contact" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2"><i class="fa-solid fa-envelope w-4" aria-hidden="true"></i> Contact</a></li> <li><a href="https://syntaxstudy.com/privacy-policy" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2"><i class="fa-solid fa-shield-halved w-4" aria-hidden="true"></i> Privacy Policy</a></li> <li><a href="https://syntaxstudy.com/sitemap.xml" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2"><i class="fa-solid fa-sitemap w-4" aria-hidden="true"></i> Sitemap</a></li> <li><a href="https://syntaxstudy.com/donate" class="text-gray-500 dark:text-gray-400 text-sm hover:text-brand transition-colors flex items-center gap-2">☕ Support Us</a></li> </ul> </div> </div> <div class="border-t border-gray-100 dark:border-gray-800 py-4 px-6 flex flex-col sm:flex-row items-center justify-between gap-2 text-center"> <p class="text-gray-400 text-xs">© 2026 SyntaxStudy. Free online tutorials for everyone.</p> <div class="flex items-center gap-4 text-xs"> <a href="https://syntaxstudy.com/privacy-policy" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors">Privacy Policy</a> <a href="https://syntaxstudy.com/contact" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors">Contact</a> <a href="https://syntaxstudy.com/about" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors">About</a> </div> </div> </footer> </div> <!-- ═══════════════════════════════════════════════════════════ SCRIPTS ════════════════════════════════════════════════════════════ --> <script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script> <script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js" data-autoloader-path="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/"></script> <script> function appState() { return { sidebarOpen: false, darkMode: false, init() { this.darkMode = localStorage.getItem('darkMode') === 'true'; this.$watch('darkMode', v => { localStorage.setItem('darkMode', v); document.documentElement.classList.toggle('dark', v); }); if (this.darkMode) document.documentElement.classList.add('dark'); }, saveDark(v) { localStorage.setItem('darkMode', v); } }; } let _rafPending = false; window.addEventListener('scroll', () => { if (_rafPending) return; _rafPending = true; requestAnimationFrame(() => { _rafPending = false; const el = document.getElementById('progress-bar'); if (!el) return; const scrolled = document.documentElement.scrollTop; const total = document.documentElement.scrollHeight - window.innerHeight; el.style.width = (total > 0 ? (scrolled / total) * 100 : 0) + '%'; }); }, { passive: true }); </script> <script> const _tryItOriginal = '\u003C?xml version=\u00221.0\u0022 encoding=\u0022UTF-8\u0022?\u003E\n\u003C!--\n Combining two vocabularies: a book record with\n Dublin Core metadata and a custom inventory namespace.\n--\u003E\n\u003Cinventory\n xmlns=\u0022http:\/\/example.com\/inventory\u0022\n xmlns:dc=\u0022http:\/\/purl.org\/dc\/elements\/1.1\/\u0022\n xmlns:xsi=\u0022http:\/\/www.w3.org\/2001\/XMLSchema-instance\u0022\n xsi:schemaLocation=\u0022http:\/\/example.com\/inventory inventory.xsd\u0022\u003E\n\n \u003C!-- Default namespace: \u0027item\u0027 belongs to example.com\/inventory --\u003E\n \u003Citem id=\u0022i001\u0022\u003E\n\n \u003C!-- Prefixed namespace: dc:title belongs to Dublin Core --\u003E\n \u003Cdc:title\u003EXML in a Nutshell\u003C\/dc:title\u003E\n \u003Cdc:creator\u003EElliotte Rusty Harold\u003C\/dc:creator\u003E\n \u003Cdc:date\u003E2004-06-01\u003C\/dc:date\u003E\n \u003Cdc:format\u003EBook\u003C\/dc:format\u003E\n\n \u003C!-- Local vocabulary elements (default namespace) --\u003E\n \u003Cquantity\u003E12\u003C\/quantity\u003E\n \u003Clocation\u003EShelf B-4\u003C\/location\u003E\n\n \u003C\/item\u003E\n\n\u003C\/inventory\u003E'; const _tryItLang = 'html'; function toggleTryIt() { const panel = document.getElementById('tryit-panel'); const btn = document.getElementById('tryit-toggle-btn'); if (!panel) return; const opening = panel.style.display === 'none'; panel.style.display = opening ? 'block' : 'none'; if (opening) { const ta = document.getElementById('tryit-code'); if (ta && !ta.value) ta.value = _tryItOriginal; runTryIt(); panel.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } if (btn) btn.innerHTML = opening ? '<i class="fa-solid fa-xmark text-xs"></i> Close Editor' : '<i class="fa-solid fa-play"></i> Try it Yourself »'; } function runTryIt() { const ta = document.getElementById('tryit-code'); const frame = document.getElementById('tryit-frame'); if (!ta || !frame) return; let code = ta.value; if (_tryItLang === 'css') { code = `<!DOCTYPE html><html><head><style> body{font-family:sans-serif;padding:1.5rem;line-height:1.6} h1{font-size:2rem;margin-bottom:.5rem}h2{font-size:1.5rem} p{margin:.5rem 0}a{color:#6366f1} ul,ol{padding-left:1.5rem} button{cursor:pointer;padding:.4rem .9rem;border-radius:.375rem} </style><style>${code}</style></head><body> <h1>Heading 1</h1><h2>Heading 2</h2> <p>A paragraph of <a href="#">sample text</a> to style.</p> <p class="highlight">A paragraph with class="highlight".</p> <ul><li>List item one</li><li>List item two</li></ul> <button class="btn">Button</button> <div class="box" style="margin-top:1rem;padding:1rem;border:1px solid #ccc">A div.box</div> </body></html>`; } else if (_tryItLang === 'javascript' || _tryItLang === 'js') { code = `<!DOCTYPE html><html><head><style> body{font-family:monospace;font-size:13px;margin:0;background:#1e1e1e;color:#d4d4d4} #output{padding:12px;white-space:pre-wrap;word-break:break-all} .log{color:#9cdcfe}.error{color:#f48771}.warn{color:#dcdcaa} </style></head><body><div id="output"></div><script> (function(){ const out=document.getElementById('output'); function write(cls,...a){const d=document.createElement('div');d.className=cls;d.textContent=a.map(x=>typeof x==='object'?JSON.stringify(x,null,2):String(x)).join(' ');out.appendChild(d);} const _log=console.log,_err=console.error,_warn=console.warn; console.log=(...a)=>{_log(...a);write('log',...a)}; console.error=(...a)=>{_err(...a);write('error',...a)}; console.warn=(...a)=>{_warn(...a);write('warn',...a)}; window.onerror=(m,s,l)=>{write('error','Error: '+m+' (line '+l+')')}; })(); <\/script><script>${code}<\/script></body></html>`; } frame.srcdoc = code; } function resetTryIt() { const ta = document.getElementById('tryit-code'); if (ta) { ta.value = _tryItOriginal; runTryIt(); } } // Auto-run on typing (debounced) document.addEventListener('DOMContentLoaded', () => { const ta = document.getElementById('tryit-code'); if (!ta) return; let timer; ta.addEventListener('input', () => { clearTimeout(timer); timer = setTimeout(runTryIt, 600); }); ta.addEventListener('keydown', e => { if (e.key === 'Tab') { e.preventDefault(); const s = ta.selectionStart, end = ta.selectionEnd; ta.value = ta.value.substring(0, s) + ' ' + ta.value.substring(end); ta.selectionStart = ta.selectionEnd = s + 4; } }); }); function copyCode(btn) { const code = btn.closest('.example-box-body').querySelector('code'); navigator.clipboard.writeText(code.innerText).then(() => { btn.innerHTML = '<i class="fa-solid fa-check text-xs"></i> Copied!'; btn.style.opacity = '1'; setTimeout(() => { btn.innerHTML = '<i class="fa-regular fa-copy text-xs"></i> Copy'; btn.style.opacity = ''; }, 2000); }); } function markLessonComplete(lessonId) { fetch(`/progress/${lessonId}`, { method: 'POST', headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name=csrf-token]').content, 'Content-Type': 'application/json' } }).then(r => r.json()).then(data => { if (!data.success) return; // Update button const btn = document.getElementById('markCompleteBtn'); if (btn) btn.outerHTML = '<span class="inline-flex items-center gap-1.5 bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400 text-sm font-semibold px-3 py-1 rounded-lg"><i class="fa-solid fa-circle-check"></i> Completed</span>'; // Update sidebar progress const pctEl = document.getElementById('sidebar-pct'); const barEl = document.getElementById('sidebar-bar'); const countEl = document.getElementById('sidebar-count'); if (data.total > 0) { const newPct = Math.round((data.completed / data.total) * 100); if (pctEl) pctEl.textContent = newPct + '%'; if (barEl) barEl.style.width = newPct + '%'; if (countEl) countEl.textContent = `${data.completed} of ${data.total} lessons done`; } // Show certificate link in sidebar if now 100% if (data.category_complete) { const certLink = document.getElementById('sidebar-cert-link'); if (certLink) certLink.classList.replace('hidden', 'flex'); showCongratulationsModal(data.category_name, data.certificate_url); } }); } function showCongratulationsModal(categoryName, certUrl) { const overlay = document.createElement('div'); overlay.className = 'cert-modal-overlay'; overlay.innerHTML = ` <div class="cert-modal"> <div style="font-size:3.5rem;margin-bottom:0.75rem">🎉</div> <h2 style="font-size:1.4rem;font-weight:800;color:#111827;margin-bottom:0.5rem" class="dark:text-white"> Congratulations! </h2> <p style="color:#6b7280;font-size:0.95rem;margin-bottom:1.5rem"> You've completed all <strong>${categoryName}</strong> lessons.<br> Your certificate is ready! </p> <a href="${certUrl}" style="display:inline-flex;align-items:center;gap:8px;background:#04aa6d;color:#fff;font-weight:700;padding:12px 28px;border-radius:12px;font-size:1rem;text-decoration:none;margin-bottom:0.75rem"> <i class="fa-solid fa-certificate"></i> Get Your Certificate </a> <br> <button onclick="this.closest('.cert-modal-overlay').remove()" style="background:none;border:none;color:#9ca3af;font-size:0.85rem;cursor:pointer;margin-top:0.5rem;padding:4px 8px"> Close </button> </div>`; overlay.addEventListener('click', e => { if (e.target === overlay) overlay.remove(); }); document.body.appendChild(overlay); } </script> <script>(function(s){s.dataset.zone='10955223',s.src='https://n6wxm.com/vignette.min.js'})([document.documentElement, document.body].filter(Boolean).pop().appendChild(document.createElement('script')))</script> <script>(function(s){s.dataset.zone='10955225',s.src='https://nap5k.com/tag.min.js'})([document.documentElement, document.body].filter(Boolean).pop().appendChild(document.createElement('script')))</script> <script src="https://5gvci.com/act/files/tag.min.js?z=10955228" data-cfasync="false" async></script> </body> </html>