--- joko/Scripts/xupdate/xupdate.pl 2003/04/26 01:42:39 1.3 +++ joko/Scripts/xupdate/xupdate.pl 2003/05/01 19:47:09 1.4 @@ -1,9 +1,12 @@ #!/usr/bin/perl ## ------------------------------------------------------------------------- -## $Id: xupdate.pl,v 1.3 2003/04/26 01:42:39 joko Exp $ +## $Id: xupdate.pl,v 1.4 2003/05/01 19:47:09 joko Exp $ ## ------------------------------------------------------------------------- ## $Log: xupdate.pl,v $ +## Revision 1.4 2003/05/01 19:47:09 joko +## attempts to get things going +## ## Revision 1.3 2003/04/26 01:42:39 joko ## first attempt to make up a crud template ## @@ -73,7 +76,10 @@ my $file = 'c:/home/amo/develop/top-scores.net/ts/backend/var/resources/control/import_select.xml'; -my $stylesheet = ' + +#my $stylesheet_xupdate = ' + +my $stylesheet_xupdate = ' @@ -114,7 +120,7 @@ - + @@ -126,8 +132,9 @@ - 5 - ------- payload ------- + CREATE + callback + abc @@ -166,32 +173,65 @@ - - - action: - payload: - - - CRUD: CREATE - - - - + + + + + + + + - - - - - CRUD: CREATE - - - - UNKOWN CRUD ACTION! - - + - + + + + + + + + + + + + + + Payload injected on {timestamp} + + + + + Payload injected via callback on {$timestamp} + + + + + Cloned last element as template on {timestamp} + + + + + + + + + + UNKOWN CRUD ACTION: "" on . + + + + + + @@ -214,6 +254,21 @@ content + + haha + + + + + San Francisco + + + + + + + + @@ -255,26 +310,88 @@ '; + + + +# examples from http://www.xmldb.org/xupdate/xupdate-wd.html#N238f4 + +my $xml_document = qq( + +
+ Andreas Laux + + Leipzig + Germany +
+
+); + +# a stripped example (the "xupdate payload") +my $xml_xupdate_stripped = qq( + + 2 + Lars Martin + + Leizig + Germany + +); + +# a full xupdate example (including the directive) +my $xml_xupdate_full = qq( + + + + + + 2 + Lars Martin + + Leizig + Germany + + + + + +); + +sub main_old { + #$xslt->open_xml( Source => f2s($file) ); + #$xslt->open_xml( Source => $xml_xupdate_full ); + #$xslt->xsl_ns('xupdate', 'xsl'); + + #$xslt->process(); + #print $xslt->toString(), "\n"; +} + + sub main { - my $xslt = XML::XSLT->new( - Source => $stylesheet, - #debug => 1, + use XML::XUpdate::XSLT; + my $xupdate = XML::XUpdate::XSLT->new( warnings => 1 ); + + #print Dumper($xupdate); + + $xupdate->open_document( $xml_document ); + #exit; - #print f2s($file), "\n"; - - $xslt->open_xml( Source => f2s($file) ); - - $xslt->process(); - print $xslt->toString(), "\n"; - + $xupdate->open_xupdate( $xml_xupdate_full ); + + $xupdate->process(); + my $result = $xupdate->toString(); + if ($result) { + print $result, "\n"; + } else { + print "No result.", "\n"; + } + } main(); print "ready.", "\n"; - 1; __END__