--- joko/Scripts/xupdate/xupdate.pl 2003/04/24 21:07:36 1.1 +++ joko/Scripts/xupdate/xupdate.pl 2003/05/01 19:47:09 1.4 @@ -1,9 +1,19 @@ #!/usr/bin/perl ## ------------------------------------------------------------------------- -## $Id: xupdate.pl,v 1.1 2003/04/24 21:07:36 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 +## +## Revision 1.2 2003/04/25 12:35:23 joko +## added some pod +## revamped xsl +## ## Revision 1.1 2003/04/24 21:07:36 joko ## initial commit ## @@ -31,11 +41,11 @@ access to the XPath API in libxml2. -=head3 In short: +=head3 Yet another xupdate - facts in short: - S: It would be nice to have a pure perl thingy which does the same stuff.... + S: It would be nice to have a pure perl thingy which does (almost) the same stuff.... - Q: Can we achieve compliance with its API? (just a subset ....) + Q: Can we achieve compliance with its (XML::XUpdate::LibXML) API? (just a subset ....) Q: Can we achieve the processing declared as a XSL document processed using CPAN's XML::XSLT? @@ -43,6 +53,8 @@ Q: Can we mimic/use the interface of the - already established - 'xupdate' program??? + Q: Should we follow the CRUD path first? + =cut @@ -64,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 = ' @@ -100,53 +115,158 @@ - - - + + + + + + - - + - + - - + + + + + + + CREATE + callback + abc + + + + + + + - - node - begin - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + Payload injected on {timestamp} + + + + + Payload injected via callback on {$timestamp} + + + + + Cloned last element as template on {timestamp} + + - - - - - - node - end - + + + + + + + UNKOWN CRUD ACTION: "" on . + + + + + + + - - + - + - + + - content + content + + + + haha + + + + + San Francisco + + + + + + @@ -157,19 +277,32 @@ - - - - + + + + + + + + + + + node - begin + + - + + - - - + + - + + + + node - end + @@ -177,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__