Hi

The short question is : is there an EXACT example of an
xml file and an xsp file and  a perl.conf file that work together
delivering a html page?

Arnold

This is the elaborate question:

Well, I found the example helpfull concerning XPathScript
I could play around with that to see what would happen. 
So that is a nice introduction.
But I am lost with xsp . I cannot seem to get it working so that it
delivers a html page like it does with xpathscript.
(At the bottom of this mail there is some text proving that I did some
thinking of my own.)



So I tried this piece of code that was reported to work a few days ago on
this mailinglist.  I tried a couple of myself too with no result.  

eureka:/w20/htdocs/xmltestxsp # less test.xml 
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="." type="application/x-xsp"?>

<xsp:page xmlns:xsp="http://apache.org/xsp/core/v1";
           xmlns:util="http://apache.org/xsp/util/v1";>

<sequence>
                         In case you wanted to know the time, it is
                         <util:time format="%D" />
</sequence>
</xsp:page>


perl.conf
<Location /xmltestxsp>
        SetHandler      perl-script
        PerlHandler     AxKit
        AxAddStyleMap   application/x-xsp Apache::AxKit::Language::XSP
        AxDebugLevel    11
</Location>


This is the log (no html sent to browser):

[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] handler called for 
/xmltestxsp/test.xml
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] checking if we process 
this resource
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] media: screen, 
preferred style: #default
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] Cache: key = 
b2350c14f7372420536050b38d4c99ff
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] getting styles and 
external entities from the XML
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] styles not cached - 
calling $provider->get_styles()
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] using XS get_styles 
(libxml2)

[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] calling 
xs_get_styles_fh()

[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] calling 
xs_get_styles_str()

[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] parse_pi: href = .
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] parse_pi: type = 
application/x-xsp
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] xs_get_styles 
returned: , , {http://apache.org/xsp/core/v1}page

[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] Calling 
GetMatchingProcessors with (screen, , , , {http://apache.org/xsp/core/v1}page)
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] get_styles: loading 
style modules
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] get_styles: looking 
for mapping for style type: 'application/x-xsp'
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] resetting cache with 
no preferred style (#default ne )
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] Cache: key = 
d229168c9661937a933e2ddc596337d5
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] cache doesn't exist
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] some condition failed. 
recreating output
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] styles: 
Apache::AxKit::Language::XSP(.)
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] [uri] File Provider 
looking up uri .
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] [uri] File Provider 
set filename to /usr/local/apache/htdocs/xmltestxsp
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] about to execute: 
Apache::AxKit::Language::XSP::handler
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] XSP: parsing fh
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] Recompiling XSP script
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] package 
Apache::AxKit::Language::XSP::ROOT::usr::local::apache::htdocs::xmltestxsp::test_2exml;
 
@Apache::AxKit::Language::XSP::ROOT::usr::local::apache::htdocs::xmltestxsp::test_2exml::ISA
 = ('Apache::AxKit::Language::XSP::Page');
#line 2 /usr/local/apache/htdocs/xmltestxsp/test.xml

use Apache;
use XML::LibXML;#initialize xsp namespace
#initialize xsp namespace


sub handler {
my ($r, $cgi) = @_;
my $document = XML::LibXML::Document->createDocument("1.0", "UTF-8");
my ($parent);

{ my $elem = 
$document->createElement(q(sequence));$document->setDocumentElement($elem); $parent = 
$elem; }
$parent->setAttribute("xmlns:" . q(util), q(http://apache.org/xsp/util/v1));{ my $text 
= $document->createTextNode(q|
                         In case you wanted to know the time, it is
                         |);$parent->appendChild($text); }
{ my $elem = $document->createElement(q(util:time));$parent->appendChild($elem); 
$parent = $elem; }
$parent->setAttribute(q(format), q(%D));
$parent = $parent->getParentNode;
$parent = $parent->getParentNode;

return $document
}

[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] XSP Compilation 
finished
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] Turning off cache!
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] Cache: key = 
4be3f21bf83755bb5ee9fc0ad8b50eb2
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] [Cache] writing cache 
file 
/usr/local/apache/htdocs/xmltestxsp/.xmlstyle_cache/4b/e3/f21bf83755bb5ee9fc0ad8b50eb2
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] execution of: 
Apache::AxKit::Language::XSP::handler finished
[Fri Feb  8 13:32:53 2002] [warn] [client 194.229.37.3] [AxKit] writing xml string to 
browser












<%
        $t->{'disposition'}{'pre'} = "<td>";
        $t->{'disposition'}{'post'} = "</td>";
        $t->{'species'}{testcode} = sub {
            my $node = shift;
            my $t = shift;
            $t->{pre} = '<tr><td>' . findvalue('@name', $node) ." " . findvalue('@ps', 
$node) .'</td>';
            $t->{post} = "</tr>";
            return 1;
        };

        $t->{'link'}{testcode} = sub {
            my $node = shift;
            my $t = shift;
            $t->{pre} = '<td><a href="' . findvalue('@url', $node). '">' ;
            $t->{post} = "</a></td><td>".findvalue('@url', $node)."</td>";
            return 1;
        };


        $t->{'humps'}{testcode} = sub {
                my $node = shift;
                my $t = shift;
                if (findvalue('parent::qual1', $node)) {
                            $t->{pre} = "<td><b>";
                            $t->{post} = "</b></td>";
                } 
                elsif (findvalue('parent::disposition', $node)) {
                            $t->{pre} = "<font color='red'>";
                            $t->{post} = "</font>";
                } 
                else {                          
                            $t->{pre} = "<td>";
                            $t->{post} = "</td>";
                }
                return 1;
        };

        $t->{'disposition'}{testcode} = sub {
                my $node = shift;
                my $t = shift;
                if (findvalue('parent::qual1', $node)) {
                            $t->{pre} = "<td><b>";
                            $t->{post} = "</b></td>";
                } 
                else {                          
                            $t->{pre} = "<td>";
                            $t->{post} = "</td>";
                }
                return 1;
        };
        


%>

<html>
<head>
        <title>Know Your Dromedaries</title>
</head>
<body bgcolor="white">
    <table bgcolor="eeeeee" border="1">
    <tr><th>Species</th><th>No. of 
Humps</th><th>Disposition</th><th>Link</th><th>extra</th></tr>

    <%= apply_templates('/dromedaries') %>

    </table>
        <%= 5+5 %>
<% 
        for my $bla (findnodes('/dromedaries/species')) {
                print $bla->findvalue('/humps/text()') . "<br>\n";
                print $bla->findvalue('/dispostion/text()') . "<br>\n";
                print findvalue('@name', $bla). "<br>\n";
                print findvalue('humps/text()', $bla). "<br>\n";
        }

%>
        <%= findvalue("/dromedaries/species/text()")   %>
        <br>
        <%= findvalue("/dromedaries/species/humps/text()")   %>
        <br>
        <%= findvalue("/dromedaries/species/disposition/text()")   %>
</body>
</html>


<?xml version="1.0"?>
<?xml-stylesheet href="test.xps" type="application/x-xpathscript"?>
<dromedaries>
    <species name="Camel"  ps="bla">
        <qual1>
                <humps>1 or 2</humps>
                <disposition>Cranky</disposition>
        </qual1>
        <qual2>
                <humps>1 or 2</humps>
                <disposition>Cranky</disposition>
        </qual2>
    </species>
    <species name="Llama">
      <humps>1 (sort of)</humps>
      <disposition>Aloof</disposition>
      <link url="http://www.bla.nl";>www.bla.nl</link>
    </species>
    <species name="Alpaca">
        <humps>(see Llama)</humps>
        <disposition>
                <humps>Friendly</humps>
        </disposition>

    </species>
</dromedaries>






PerlModule AxKit
<Location /xmltest>
        SetHandler      perl-script
        PerlHandler     Apache::AxKit
        AxAddStyleMap   application/x-xpathscript  Apache::AxKit::Language::XPathScript
        AxDebugLevel    10
</Location>






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to