From 7a715d22a7d87dcff616b31e71435bef2e99f9d2 Mon Sep 17 00:00:00 2001 From: "sgunderson@bigfoot.com" <> Date: Sat, 12 Aug 2006 19:51:18 +0200 Subject: [PATCH] Change the syntax for attributes from tag.attribute to tag/attribute; we might want classes quite soon, and that would be more logical to have as tag.class. --- doc/intro.txt | 8 ++++---- perl/XML/Template.pm | 4 ++-- perl/attribute.pl | 8 ++++---- perl/attribute2.pl | 2 +- php/attribute.php | 8 ++++---- php/attribute2.php | 2 +- php/xml-template.php | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/intro.txt b/doc/intro.txt index f94cef7..e9807e5 100644 --- a/doc/intro.txt +++ b/doc/intro.txt @@ -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; diff --git a/perl/XML/Template.pm b/perl/XML/Template.pm index 3d4fad8..c148ecc 100644 --- a/perl/XML/Template.pm +++ b/perl/XML/Template.pm @@ -83,8 +83,8 @@ sub process { # check all substitutions to see if we found anything # appropriate for my $key (keys %$obj) { - if (($key =~ /^\Q$tag\E\.(.*)$/) || - (defined($id) && $key =~ /^#\Q$id\E\.(.*)$/)) { + if (($key =~ /^\Q$tag\E\/(.*)$/) || + (defined($id) && $key =~ /^#\Q$id\E\/(.*)$/)) { $child->setAttribute($1, $obj->{$key}); } diff --git a/perl/attribute.pl b/perl/attribute.pl index 9e4947d..7447652 100644 --- a/perl/attribute.pl +++ b/perl/attribute.pl @@ -4,10 +4,10 @@ use XML::Template; 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; diff --git a/perl/attribute2.pl b/perl/attribute2.pl index 2557d33..832398e 100644 --- a/perl/attribute2.pl +++ b/perl/attribute2.pl @@ -3,7 +3,7 @@ use XML::Template; my $doc = XML::Template::process_file('../xml/clone.xml', { 'color' => 'blue', - '#things' => XML::Template::alternate('li.class', [ + '#things' => XML::Template::alternate('li/class', [ { 'li' => 'Raindrops on roses' }, { 'li' => 'Whiskers on kittens' }, { 'li' => 'Bright copper kettles' }, diff --git a/php/attribute.php b/php/attribute.php index b4899b8..626812e 100644 --- a/php/attribute.php +++ b/php/attribute.php @@ -4,10 +4,10 @@ require('xml-template.php'); $doc = XML_Template_process_file('../xml/clone.xml', array( 'color' => 'red', '#things' => array( - array( 'li' => 'Raindrops on roses', 'li.class' => 'odd' ), - array( 'li' => 'Whiskers on kittens', 'li.class' => 'even' ), - array( 'li' => 'Bright copper kettles', 'li.class' => 'odd' ), - array( 'li' => 'Warm, woolen mittens', 'li.class' => 'even' ) + array( 'li' => 'Raindrops on roses', 'li/class' => 'odd' ), + array( 'li' => 'Whiskers on kittens', 'li/class' => 'even' ), + array( 'li' => 'Bright copper kettles', 'li/class' => 'odd' ), + array( 'li' => 'Warm, woolen mittens', 'li/class' => 'even' ) ) )); print $doc->dump_mem(); diff --git a/php/attribute2.php b/php/attribute2.php index e145045..186828f 100644 --- a/php/attribute2.php +++ b/php/attribute2.php @@ -3,7 +3,7 @@ require('xml-template.php'); $doc = XML_Template_process_file('../xml/clone.xml', array( 'color' => 'blue', - '#things' => XML_Template_alternate('li.class', array( + '#things' => XML_Template_alternate('li/class', array( array( 'li' => 'Raindrops on roses' ), array( 'li' => 'Whiskers on kittens' ), array( 'li' => 'Bright copper kettles' ), diff --git a/php/xml-template.php b/php/xml-template.php index dc84bf6..b5f7096 100644 --- a/php/xml-template.php +++ b/php/xml-template.php @@ -48,8 +48,8 @@ function XML_Template_process($node, $obj, $clean = 1) # appropriate foreach (array_keys($obj) as $key) { # FIXME: we would want something like \Q and \E here... - if (preg_match('/^' . $tag . '\.(.*)$/', $key, $matches) || - ($id != null && preg_match('/^#' . $id . '\.(.*)$/', $key, $matches))) { + if (preg_match('/^' . $tag . '\/(.*)$/', $key, $matches) || + ($id != null && preg_match('/^#' . $id . '\/(.*)$/', $key, $matches))) { $child->set_attribute($matches[1], $obj[$key]); } -- 2.39.2