diff options
author | Gianni Ceccarelli <dakkar@dechirico.(none)> | 2009-03-27 13:00:46 +0100 |
---|---|---|
committer | Gianni Ceccarelli <dakkar@dechirico.(none)> | 2009-03-27 13:00:46 +0100 |
commit | 26248672c6b3ee8f8b10dff5f2b8302e008f46c1 (patch) | |
tree | 0035267f3e4b3ab4aa64c22ca60d2018cc6b6e1d /t | |
parent | libxml, no namespace support (diff) | |
download | Tree-Template-Declare-26248672c6b3ee8f8b10dff5f2b8302e008f46c1.tar.gz Tree-Template-Declare-26248672c6b3ee8f8b10dff5f2b8302e008f46c1.tar.bz2 Tree-Template-Declare-26248672c6b3ee8f8b10dff5f2b8302e008f46c1.zip |
LibXML with namespace support, and fixed tests
Diffstat (limited to 't')
-rw-r--r-- | t/02-xslt.t | 9 | ||||
-rw-r--r-- | t/03-html.t | 5 | ||||
-rw-r--r-- | t/04-xml.t | 47 |
3 files changed, 46 insertions, 15 deletions
diff --git a/t/02-xslt.t b/t/02-xslt.t index e47572b..49e617a 100644 --- a/t/02-xslt.t +++ b/t/02-xslt.t @@ -1,4 +1,10 @@ #!perl +package main; +use Test::Most 'die'; +BEGIN { +eval 'use Tree::DAG_Node::XPath; require Tree::Transform::XSLTish'; +plan skip_all => 'Tree::DAG_Node::XPath and Tree::Transform::XSLTish needed for this test' if $@; +} package Copy;{ use Tree::Transform::XSLTish; @@ -24,12 +30,13 @@ tree_rule match => '*', priority => 0, action => sub { } package main; -use Test::Most 'no_plan','die'; use strict; use warnings; use Tree::Template::Declare options => {builder => Tree::Template::Declare::DAG_Node->new('Tree::DAG_Node::XPath') }; use Data::Dumper; +plan tests=>1; + sub Tree::DAG_Node::XPath::Root::xpath_get_root_node { return $_[0] } sub Tree::DAG_Node::XPath::Root::xpath_get_parent_node { return } diff --git a/t/03-html.t b/t/03-html.t index 2640a5e..8504c90 100644 --- a/t/03-html.t +++ b/t/03-html.t @@ -25,4 +25,7 @@ my $tree=tree { }; }; -diag $tree->as_HTML(); +is($tree->as_HTML(), + qq{<html><head><title>Page title</title></head><body><p>Page para</body></html>\n}, + 'HTML tree' +); @@ -5,22 +5,43 @@ use warnings; use Tree::Template::Declare options => {builder => '+LibXML'}; use Data::Dumper; -my $tree=tree { - node { - name 'stuff'; +xmlns test => 'http://test/'; + +sub make_tree { + tree { node { - name 'elem1'; - attribs id => 1; + name 'stuff'; node { - name 'sub1'; - } - }; - node { - name 'elem2'; - attribs id => 2; + name 'test:elem1'; + attribs id => 1, 'test:buh' => 'testing'; + node { + name 'test:sub1'; + } + }; + node { + name 'elem2'; + attribs id => 2; + }; }; }; -}; +} + +{ +my $tree=make_tree(); + +is($tree->serialize(0), + qq{<?xml version="1.0"?>\n<stuff><test:elem1 xmlns:test="http://test/" test:buh="testing" id="1"><test:sub1/></test:elem1><elem2 id="2"/></stuff>\n}, + 'XML document without default NS' +); +} + +xmlns ':default' => 'ftp://test/'; -diag $tree->serialize(); +{ +my $tree=make_tree(); +is($tree->serialize(0), + qq{<?xml version="1.0"?>\n<stuff xmlns="ftp://test/"><test:elem1 xmlns:test="http://test/" test:buh="testing" id="1"><test:sub1/></test:elem1><elem2 id="2"/></stuff>\n}, + 'XML document with default NS' +); +} |