]> git.sesse.net Git - xml-template/blobdiff - doc/intro.txt
Added a note about the test suite.
[xml-template] / doc / intro.txt
index a5d1dede4511be796cd7d90dabeb3389b22a8cbe..448ded6c6138d2a81103ddc5b5fe88ba92579606 100644 (file)
@@ -17,8 +17,8 @@ to check out the code and this documentation.
 
 There is a lot to be said about design philosophy, but let's first give a
 simple example to give you the feel of how it works. (The example is in
-Perl, but there's also a functionally equivalent PHP version, and more
-languages should probably come soon.)
+Perl, but there are also functionally equivalent PHP and Python versions,
+and more languages should probably come soon.)
 
 Template (simple.xml):
 
@@ -83,14 +83,14 @@ Template (clone.xml):
   <!DOCTYPE
     html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:tmpl="http://template.sesse.net/" xml:lang="en">
+  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://template.sesse.net/" xml:lang="en">
     <head>
       <title>Cloning test</title>
     </head>
     <body>
-       <p>My favourite color is <tmpl:color />; I like that very much.
+       <p>My favourite color is <t:color />; I like that very much.
          All my favourite things:</p>
-      <ul tmpl:id="things">
+      <ul t:id="things">
         <li />
       </ul>
     </body>
@@ -135,7 +135,7 @@ Result:
   </html>
 
 This isn't much harder than the example above; we've done a simple replacement
-of the contents of <tmpl:color> to "blue" (and after that just removed the tag;
+of the contents of <t:color> to "blue" (and after that just removed the tag;
 any tag you use in the templating namespace will automatically get stripped
 away), and then cloned the contents of our "things" bullet list. Note that
 XML::Template automatically recurses after the cloning, since you probably
@@ -169,14 +169,14 @@ Template (clone.xml), repeated for your convenience:
   <!DOCTYPE
     html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:tmpl="http://template.sesse.net/" xml:lang="en">
+  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://template.sesse.net/" xml:lang="en">
     <head>
       <title>Cloning test</title>
     </head>
     <body>
-       <p>My favourite color is <tmpl:color />; I like that very much.
-         All my favourite things:</p>
-      <ul tmpl:id="things">
+      <p>My favourite color is <t:color />; I like that very much.
+        All my favourite things:</p>
+      <ul t:id="things">
         <li />
       </ul>
     </body>
@@ -190,10 +190,10 @@ Code (attribute.pl):
   my $doc = XML::Template::process_file('../xml/clone.xml', {
        'color' => 'red',
        '#things' => [
-               { 'li' => 'Raindrops on roses',    'li.class' => 'odd' },
-               { 'li' => 'Whiskers on kittens',   'li.class' => 'even' },
-               { 'li' => 'Bright copper kettles', 'li.class' => 'odd' },
-               { 'li' => 'Warm, woolen mittens',  'li.class' => 'even' }
+               { 'li' => 'Raindrops on roses',    'li/class' => 'odd' },
+               { 'li' => 'Whiskers on kittens',   'li/class' => 'even' },
+               { 'li' => 'Bright copper kettles', 'li/class' => 'odd' },
+               { 'li' => 'Warm, woolen mittens',  'li/class' => 'even' }
        ]
   });
   print $doc->toString;
@@ -249,8 +249,12 @@ The main thoughts behind XML::Template have been, in no particular order:
    the entire DOM with wrappers for each language. (Thankfully, by relying on
    the DOM support in each language, the code so far is under 200 lines per
    implementation, so maintaining this hopefully shouldn't be much work.)
-   As proof-of-concept, I've got Perl and PHP implementations that work and
-   feel largely the same -- Python, Ruby and other implementations are welcome.
+   As proof-of-concept, I've got Perl, PHP and Python implementations that work
+   and feel largely the same -- Ruby and other implementations are welcome.
+   (This is backed up by a test suite, which ensures that all the different
+   implementations return structurally equivalent XML for a certain set of
+   test cases. Porting to a new language is not difficult, and once you've
+   got all the test cases to pass, your work is most likely done.)
 
 As a side note to the second point, I've spent some time wondering exactly
 _why_ you want to separate the back-end logic from your HTML, and why people