XML XML

Model structured documents with elements, attributes, namespaces, schemas, parsing, and transformations.

Lessons

Sign in to save progress
1 XML Tutorial 2 XML HOME 3 XML Introduction 4 What Is XML 5 XML vs HTML 6 How XML Is Used 7 XML Tree Structure 8 XML Elements, Attributes & Documents 9 XML Syntax Rules 10 The XML Declaration & Prolog 11 XML Elements 12 Element Naming Rules 13 XML Attributes 14 Elements vs Attributes 15 Text Content 16 Mixed Content 17 Empty Elements 18 XML Comments 19 Whitespace Handling 20 Predefined Entities 21 Custom Entities 22 CDATA Sections 23 Processing Instructions 24 Character Encoding 25 Well-Formed vs Valid 26 Namespaces & Qualified Names 27 Declaring Namespaces 28 Default Namespaces 29 Namespace Scope 30 Qualified Names 31 Document Type Definition (DTD) 32 DTD Element Declarations 33 DTD Attribute Declarations 34 Internal & External DTDs 35 DTD, XSD & Validation 36 XML Schema (XSD) Introduction 37 XSD Simple Types 38 XSD Complex Types 39 XSD Elements & Attributes 40 XSD Restrictions & Facets 41 XSD Order & Occurrence 42 XSD Import & Include 43 ID, IDREF & Keys 44 Validating XML Documents 45 RELAX NG Schemas 46 Schematron Rules 47 Parsing XML in JavaScript and PHP 48 The XML DOM 49 DOM Navigation 50 Accessing Elements & Values 51 Modifying the XML DOM 52 SAX Parsing 53 Pull Parsing (StAX) 54 Parsing XML in JavaScript 55 Parsing XML in PHP 56 Parsing XML in Python 57 Serializing XML 58 Handling Parse Errors 59 XPath Basics 60 XPath Axes 61 XPath Predicates 62 XPath Functions 63 XPath String Functions 64 XInclude 65 XQuery Introduction 66 XSLT & Transformations 67 XSLT Introduction 68 XSLT Templates 69 xsl:value-of & xsl:for-each 70 XSLT Conditionals 71 XSLT Sorting 72 XSLT Keys & Grouping 73 XSLT Parameters & Variables 74 Transforming XML to HTML 75 XSL-FO for Print 76 XML in APIs, RSS & Sitemaps 77 RSS Feeds 78 Atom Feeds 79 XML Sitemaps 80 SOAP Web Services 81 WSDL Service Definitions 82 SVG as XML 83 XHTML 84 XML Configuration Files 85 XML in Office Documents 86 XMLHttpRequest 87 XML vs JSON 88 Converting XML and JSON 89 XML Data Binding 90 XML Signature & Encryption 91 XML Security 92 XML Best Practices 93 Common XML Mistakes 94 Formatting & Pretty-Printing 95 Handling Large XML Files 96 XML Editors & Tools 97 XML Cheatsheet 98 XML Interview Questions 99 XML Quiz 100 XML Exercises 101 XML Practice Problems 102 XML Project Ideas 103 XML Syllabus 104 XML Study Plan 105 XML Bootcamp

XSLT & Transformations

XML Lesson 66 of 105 ~1 min read

Overview

Transform XML into HTML or another XML structure.

XSLT & Transformations is easiest to learn by reading the example, changing it, and observing the result.

Core Ideas

  • Understand what XSLT & Transformations changes.
  • Run the example.
  • Change one value.
  • Explain the result.

Step by Step

  1. Read the XSLT & Transformations example.
  2. Run it.
  3. Change it.
  4. Explain it.

Code Example

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html><body>
      <h1>Lessons</h1>
      <ul>
        <xsl:for-each select="lessons/lesson">
          <xsl:sort select="title"/>
          <li><xsl:value-of select="title"/></li>
        </xsl:for-each>
      </ul>
    </body></html>
  </xsl:template>
</xsl:stylesheet>

Checklist

  • Read the example and change one value.
  • Check the result in the browser.
  • Write down the rule you learned.

Common Mistakes

  • Skipping the example.
  • Changing many things at once.
  • Not checking the result.

Practice Challenge

Practice the XSLT & Transformations example in a small scratch file, then explain what changed and why.

Mastery Check

  • You can explain XSLT & Transformations.
  • You can change the example.
  • You can debug the result.
Create a free account to save which lessons you've finished. Save my progress