You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dmitry Beransky <db...@biomail.ucsd.edu> on 2000/08/28 02:47:39 UTC

XML::XPath in APache::ASP -> doesn't work

Hi,

Well, it's not that it doesn't work, rather I can't get it work and this
has been driving me nuts for two weeks (on and off).  I must be missing
something obvious, but I can't figure out what it is.  Anyway, here's the
problem:

When the following asp is executed, it reports the size of the nodeset as
zero, but if I strip out all html and simply run this as a perl script
(also included below) off
a command line, I get 1, just as I would expect.  I'm using ASP v.2.03 and
Xpath v.098.  Any ideas what's going on?  Matt, Joshua...?

----- ASP:
<%@language="PerlScript"%>
<%
   use XML::XPath;
   my ($xform,$xform_xpath, $xml);
%>
<html>
<head>
<%
my $data = <<"END_XML";
<!DOCTYPE xxform [
   <!ATTLIST string name ID #REQUIRED>
   <!ATTLIST group name ID #REQUIRED>
]>
<xxform xmlns="http://www.w3.org/2000/xforms"
  action="http://www.my.com/cgi-bin/receiver.pl"
  method="post"
  id="po_xform">
  <model>
    <group name="purchaseOrder">
      <group name="shipTo">
        <string name="name"/>
        <string name="street"/>
        <string name="city"/>
        <string name="state"/>
        <string name="zip">
          <mask>ddddd</mask>
        </string>
      </group>
    </group>
  </model>
</xxform>
END_XML
%>
</head>
<body>
   <h1>Form (using XML::XPath v.<%=$XML::XPath::VERSION%>)</h1>
    <pre>
       <%
          my $xform = new XML::XPath( xml=>$data );
          my $nodeSet = $xform->find( q(id('city')) );
         
          $Response->Write( "Size: " . $nodeSet->size . "<BR>" );
       %>
    </pre>
</body>
</html>

--- SCRIPT:
#!/usr/bin/perl

   use XML::XPath;
   my ($xform,$xform_xpath, $xml);

my $data = <<"END_XML";
<!DOCTYPE xxform [
   <!ATTLIST string name ID #REQUIRED>
   <!ATTLIST group name ID #REQUIRED>
]>
<xxform xmlns="http://www.w3.org/2000/xforms"
  action="http://www.my.com/cgi-bin/receiver.pl"
  method="post"
  id="po_xform">
  <model>
    <group name="purchaseOrder">
      <group name="shipTo">
        <string name="name"/>
        <string name="street"/>
        <string name="city"/>
        <string name="state"/>
        <string name="zip">
          <mask>ddddd</mask>
        </string>
      </group>
    </group>
  </model>
</xxform>
END_XML
   print "using XML::XPath v.$XML::XPath::VERSION\n";
          my $xform = new XML::XPath( xml=>$data );
          my $nodeSet = $xform->find( q(id('city')) );

          print( "Size: " . $nodeSet->size . "\n" );


Re: XML::XPath in APache::ASP -> doesn't work

Posted by Dmitry Beransky <db...@biomail.ucsd.edu>.
> Why don't you use XMLSubs to catch the data with a custom
> tag, and then process the data with XPath... you could register
> the data in a global, and then process it later in your script
> if you like?  It just killed me to see this kind of construct
> in an ASP script:

Actually, that's exactly what I do in the real script.  What I posted was
just a simplified version (my apologies for neglecting to mention that).  
Since the "offline" version of the script did work as expected, I simply
plopped it into ASP to show off this weirdness.

> I don't know why this doesn't work for you, but I can check
> it out later if it still isn't working and no one else posts
> an answer.

thanks
Dmitry


Re: XML::XPath in APache::ASP -> doesn't work

Posted by Joshua Chamas <jo...@chamas.com>.
Dmitry Beransky wrote:
> 
> Hi,
> 
> Well, it's not that it doesn't work, rather I can't get it work and this
> has been driving me nuts for two weeks (on and off).  I must be missing
> something obvious, but I can't figure out what it is.  Anyway, here's the
> problem:
> 
> When the following asp is executed, it reports the size of the nodeset as
> zero, but if I strip out all html and simply run this as a perl script
> (also included below) off
> a command line, I get 1, just as I would expect.  I'm using ASP v.2.03 and
> Xpath v.098.  Any ideas what's going on?  Matt, Joshua...?
> 

Why don't you use XMLSubs to catch the data with a custom
tag, and then process the data with XPath... you could register
the data in a global, and then process it later in your script
if you like?  It just killed me to see this kind of construct
in an ASP script:

> my $data = <<"END_XML";
> <!DOCTYPE xxform [

I don't know why this doesn't work for you, but I can check
it out later if it still isn't working and no one else posts
an answer.

--Joshua
_________________________________________________________________
Joshua Chamas			        Chamas Enterprises Inc.
NodeWorks >> free web link monitoring	Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Re: XML::XPath in APache::ASP -> doesn't work

Posted by Dmitry Beransky <db...@ucsd.edu>.
>I'm still using good ol' 5.005 :)  I just tried your Debug=1 suggestion
>(BTW, it doesn't appear to be documented in XML::XPath) and the output
>seems identical for both the ASP and the "offline" versions of the
>script.  I guess I'll have to dive into XPath internals and place a few
>trace statements of my own...


Well, I traced it down to XML::XPath::XMLParser::parse_attlist not been 
called by Expat under Apache (the traces are included below), which results 
in IdNames array not been populated.  Before I start debugging XML::Parser, 
can anyone hypothesize why this might be happening (I'm running XML::Parser 
v2.29)?

Thanks
Dmitry


--- "offline" script trace:
using XML::XPath v.0.98
Executing parse_attlist at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 200.
adding string with type: ID at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 203.
Executing parse_attlist at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 200.
adding group with type: ID at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 203.
Key: action at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{xxform}:  at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm 
line 127.
Key: method at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{xxform}:  at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm 
line 127.
Key: id at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{xxform}:  at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm 
line 127.
Key: name at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{group}: name at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 127.
Key: name at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{group}: name at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 127.
Key: name at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{string}: name at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 127.
Key: name at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{string}: name at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 127.
Key: name at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{string}: name at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 127.
Key: name at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{string}: name at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 127.
Key: name at /usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 126.
IdNames{string}: name at 
/usr/lib/perl5/site_perl/5.005/XML/XPath/XMLParser.pm line 127.Size: 1


---- Apache trace:
using XML::XPath v.0.98
[Mon Aug 28 09:13:10 2000] null: Key: name at 
/usr/lib/perl5/site_perl/5.005/XML/X
Path/XMLParser.pm line 126.
[Mon Aug 28 09:13:10 2000] null: IdNames{group}:  at 
/usr/lib/perl5/site_perl/5.00
5/XML/XPath/XMLParser.pm line 127.
[Mon Aug 28 09:13:10 2000] null: Key: name at 
/usr/lib/perl5/site_perl/5.005/XML/X
Path/XMLParser.pm line 126.
[Mon Aug 28 09:13:10 2000] null: IdNames{string}:  at 
/usr/lib/perl5/site_perl/5.0
05/XML/XPath/XMLParser.pm line 127.
[Mon Aug 28 09:13:10 2000] null: Key: name at 
/usr/lib/perl5/site_perl/5.005/XML/X
Path/XMLParser.pm line 126.
[Mon Aug 28 09:13:10 2000] null: IdNames{string}:  at 
/usr/lib/perl5/site_perl/5.0
05/XML/XPath/XMLParser.pm line 127.
[Mon Aug 28 09:13:10 2000] null: Key: name at 
/usr/lib/perl5/site_perl/5.005/XML/X
Path/XMLParser.pm line 126.
[Mon Aug 28 09:13:10 2000] null: IdNames{string}:  at 
/usr/lib/perl5/site_perl/5.0
05/XML/XPath/XMLParser.pm line 127.
[Mon Aug 28 09:13:10 2000] null: Key: name at 
/usr/lib/perl5/site_perl/5.005/XML/X
Path/XMLParser.pm line 126.
[Mon Aug 28 09:13:10 2000] null: IdNames{string}:  at 
/usr/lib/perl5/site_perl/5.0
05/XML/XPath/XMLParser.pm line 127.
[Mon Aug 28 09:13:10 2000] null: Key: name at 
/usr/lib/perl5/site_perl/5.005/XML/X
Path/XMLParser.pm line 126.
[Mon Aug 28 09:13:10 2000] null: IdNames{string}:  at 
/usr/lib/perl5/site_perl/5.0
05/XML/XPath/XMLParser.pm line 127.
~Size: 1


Re: XML::XPath in APache::ASP -> doesn't work

Posted by Paul Lindner <pl...@redhat.com>.
On Mon, Aug 28, 2000 at 07:11:17AM -0700, Dmitry Beransky wrote:
> > I don't know why its working on the command line and not in your web
> > page. Seems very odd to me. Have you tried setting $XML::XPath::Debug=1
> > and seeing if that shows anything suspect (expect LOTS of stuff to come
> > out). Also note that XML::XPath doesn't work with Perl 5.6 yet. I'm
> > uploading XML::XPath 0.99 today to fix that.
> 
> I'm still using good ol' 5.005 :)  I just tried your Debug=1 suggestion
> (BTW, it doesn't appear to be documented in XML::XPath) and the output
> seems identical for both the ASP and the "offline" versions of the
> script.  I guess I'll have to dive into XPath internals and place a few
> trace statements of my own...
> 

You might try intentionally placing a syntax error in your asp script
so you can analyze the parsed output.  It's possible the parser is
doing something unexpected to your code.

-- 
Paul Lindner
plindner@redhat.com
Red Hat Inc.

Re: XML::XPath in APache::ASP -> doesn't work

Posted by Dmitry Beransky <db...@biomail.ucsd.edu>.
> I don't know why its working on the command line and not in your web
> page. Seems very odd to me. Have you tried setting $XML::XPath::Debug=1
> and seeing if that shows anything suspect (expect LOTS of stuff to come
> out). Also note that XML::XPath doesn't work with Perl 5.6 yet. I'm
> uploading XML::XPath 0.99 today to fix that.

I'm still using good ol' 5.005 :)  I just tried your Debug=1 suggestion
(BTW, it doesn't appear to be documented in XML::XPath) and the output
seems identical for both the ASP and the "offline" versions of the
script.  I guess I'll have to dive into XPath internals and place a few
trace statements of my own...

Thanks
Dmitry


Re: XML::XPath in APache::ASP -> doesn't work

Posted by Matt Sergeant <ma...@sergeant.org>.
On Sun, 27 Aug 2000, Dmitry Beransky wrote:

> Hi,
> 
> Well, it's not that it doesn't work, rather I can't get it work and this
> has been driving me nuts for two weeks (on and off).  I must be missing
> something obvious, but I can't figure out what it is.  Anyway, here's the
> problem:
> 
> When the following asp is executed, it reports the size of the nodeset as
> zero, but if I strip out all html and simply run this as a perl script
> (also included below) off
> a command line, I get 1, just as I would expect.  I'm using ASP v.2.03 and
> Xpath v.098.  Any ideas what's going on?  Matt, Joshua...?

I don't know why its working on the command line and not in your web
page. Seems very odd to me. Have you tried setting $XML::XPath::Debug=1
and seeing if that shows anything suspect (expect LOTS of stuff to come
out). Also note that XML::XPath doesn't work with Perl 5.6 yet. I'm
uploading XML::XPath 0.99 today to fix that.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org