I've done a bit more testing on my /usr/bin/xpathscript problem.
It appears that /usr/bin/xpathscript uses XML::LibXML as the default document type - rather than XML::XPath - which is what it uses under AxKit!
(at least those are the package names that appear in error messages.)
If I amend my code to use XML::LibXML commands then I can get the script to work OK on the command line.
But it then (obviously) doesn't run under XPathScript in AxKit.
SO - /usr/bin/xpathscript question: - why is it using XML::LibXML?
I then switched to using YPathScript for XPS files in AxKit - which I have built to use XML::LibXML.
and tried processing the same XPS that worked on the commandline
which failed with two sorts of errors
- relative paths in the XPATH 'document' function don't seem to work
- and I can't get the namespaces to work when loading another document
(The previous version of this XPS file worked fine under AXKit and XML::XPath.)
Relative Path details:
I need to load an XML document stored relative to the XPS stylesheet. Using findnodes
14 our $xpfo=findnodes("document('$xmlfile')/*")->get_node(1)
but this doesn't load anything unless I specify a full server path
14 our $xpfo=findnodes("document('http://www.datalucid.co.uk/DRE/$xmlfile')/*")->get_node(1);
Document Namespace
This $xmlfile document declares a namespace for all nodes
3 <classes xmlns="http://www.datalucid.com/" xmlns:dl='http://www.datalucid.com/'>
But I can't workout how to refer to this namespace in YPathScript as - if I don't specify a namespace on nodes - they don't get found.
But - if I do - using the 'dl:' prefix:
31 my $foclass=$xpfo->findnodes('dl:[EMAIL PROTECTED]"'.$class.'"]');
I get the following error message in the browser and the Apache error_log:
The following error occurred: Undefined namespace prefix xmlXPathCompiledEval: evaluation failed
SO - the YPathScript questions are: - what am I doing wrong with relative document paths - how do I use / set a namespace when searching another document
Again - as always - any sort of help or comments would be much appreciated.
Mike Trotman wrote:
Hi.
I've just tried using the commandline utility '/usr/bin/xpathscript' to check some of my XPS files
(and make sure I can generate output from the commandline).
I've been testing a design for an application using Axkit for the last couple of weeks - but that's the 1st time I started using it.
I've had problems and narrowed them down to the following XPS file
(which is a subset of a much larger XPS file that works fine when running under AxKit.)
Any help on how I get this to work would be greatly appreciated.
1 <%
2 my $xpfo=findnodes('document("/DRE/fostyle/dl_fostyles.xml")/classes')->get_node(1);
3 4 unless ($xpfo) { 5 print "NO XPFO\n"; 6 exit 999; 7 } 8 #------------------------------------------------------------ 9 %> 10 <%= apply_templates('/'); %>
If I run this file with
[DRE]$ xpathscript tab_0001.xml test.xps
I get output:
syntax error at stylesheet line 10, at EOF syntax error at stylesheet line 13, near "; }" (Might be a runaway multi-line || string starting on line 11)
If I change the last line to
10 <% print apply_templates('/'); %>
it sort of works and I get output:
NO XPFO
(but I really need that $xpfo document! and the full file works fine under AxKit!) If I remove the check for $xpfo then I do get the XML document output.
I think am running the latest version of Apache::AxKit::Language::XPathscript etc.
cpan> m XML::XPathScript Module id = XML::XPathScript CPAN_USERID DOMQ (Dominique Quatravaux <[EMAIL PROTECTED]>) CPAN_VERSION 0.14 CPAN_FILE D/DO/DOMQ/XML-XPathScript-0.14.tar.gz MANPAGE XML::XPathScript - a Perl framework for XML stylesheets INST_FILE /usr/lib/perl5/site_perl/5.8.3/XML/XPathScript.pm INST_VERSION 0.14
(although the /usr/bin/xpathscript says it is version 0.2)
cpan> m Apache::AxKit::Language::XPathScript
Module id = Apache::AxKit::Language::XPathScript
CPAN_USERID MSERGEANT (Matt Sergeant <[EMAIL PROTECTED]>)
CPAN_VERSION 0.05
CPAN_FILE M/MS/MSERGEANT/AxKit-1.6.2.tar.gz
MANPAGE Apache::AxKit::Language::XPathScript - An XML Stylesheet Language
INST_FILE /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi/Apache/AxKit/Language/XPathScript.pm
INST_VERSION 0.05
and - just in case ...
cpan> m Apache::AxKit::Language::YPathScript
Module id = Apache::AxKit::Language::YPathScript
CPAN_USERID DOMQ (Dominique Quatravaux <[EMAIL PROTECTED]>)
CPAN_VERSION 1.1
CPAN_FILE D/DO/DOMQ/XML-XPathScript-0.14.tar.gz
MANPAGE Apache::AxKit::Language::YPathScript - An XML Stylesheet Language
INST_FILE /usr/lib/perl5/site_perl/5.8.3/Apache/AxKit/Language/YPathScript.pm
INST_VERSION 1.1
I built YPathscript to use XML::LibXML.
Any clues, hints, suggestions, pointing out obvious mistakes most welcome.
Mike
-- Datalucid Limited
-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.3 - Release Date: 05/04/2005
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]