capint
12/1/2015 - 9:36 PM

XML >> XML Namespace

XML >> XML Namespace

<!-- XSLT elements inside an HTML document thanks to its namespace prefix -->
<?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>
  <h2>My CD Collection</h2>
  <table border="1">
    <tr>
      <th style="text-align:left">Title</th>
      <th style="text-align:left">Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
    <tr>
      <td><xsl:value-of select="title"/></td>
      <td><xsl:value-of select="artist"/></td>
    </tr>
    </xsl:for-each>
  </table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>
Name conflicts in XML can be avoided using a NAME PREFIX
When using prefixes in XML, a NAMESPACE for the prefix must be defined
The namespace declaration has the following syntax: xmlns:prefix="URI"

Source: http://www.w3schools.com/xml/xml_namespaces.asp