We have got some strange behavior while dealing with XSP pages containing a lot of nested/scoped xml:lang attributes as well as XML-Namaspaces (which are not used for taglibs but simply to differentiate tags into the XSLT space).
I think I know what's happening.
foo.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="foo.xsl" type="text/xsl" ?>
<page version="1.0" xml:lang="en" xhtml="http://www.w3.org/1999/xhtml">
<pagetitle xml:lang="en">English</pagetitle>
<sourceLanguage>en</sourceLanguage>
<sentence>
<key xml:lang="en">key1</key><value xml:lang="en">test in
English</value>
</sentence>
</page>
This gets parsed from text, so the 'xml:' prefix gets mapped to the correct (pseudo-)namespace.
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet href="NULL" type="application/x-xsp" ?>
<?xml-stylesheet href="foo.xsl" type="text/xsl" ?>
<xsp:page
xmlns:xsp="http://apache.org/xsp/core/v1"
xmlns:param="http://axkit.org/NS/xsp/param/v1"
>
<page version="1.0" xml:lang="en"
xmlns:xhtml="http://www.w3.org/1999/xhtml" >
<pagetitle xml:lang="en">English</pagetitle>
<sourceLanguage>en</sourceLanguage>
<sentence>
<key xml:lang="en">key1</key><value xml:lang="en">test in
English</value>
</sentence>
</page>
</xsp:page>
This, on the other hand, generates a DOM tree via Perl code. In there, the 'xml:' prefix is not bound to any namespace, and so it is not recognized by the XPath selector in the XSLT.
We find that things do work if we
- remove any xmlns:foo namespace we define - put the tags in a flat namespace (we're NOT using taglibs) - and do an overall 's/xml:lang/lang/g'
I'd say you just need to move the 'xml:lang' attribute to some of your own NS, or use just 'lang'.
To us it looks like a bug into the AxKit XML NS processing code and/or in
See my comment on the Perl code.
foo.xsp.XSP package Apache::AxKit::Language::XSP::ROOT::usr::local::www::data::www_2dchinglish::mockup::login::data::tmp2::foo_2exsp; use Apache; use Apache::Constants qw(:common); use XML::LibXML; Apache::AxKit::Language::XSP::Page->import( qw(__mk_text_node __mk_comment_node __mk_ns_element_node __mk_element_node) ); use utf8;#initialize xsp namespace #initialize xsp namespace
@Apache::AxKit::Language::XSP::ROOT::usr::local::www::data::www_2dchinglish::mockup::login::data::tmp2::foo_2exsp::ISA = ('Apache::AxKit::Language::XSP::Page'); sub xml_generator { my $class = shift; my ($r, $cgi, $document, $parent) = @_;
$parent = __mk_element_node($document, $parent, q|page|); $parent->setAttribute(q|version|,q|1.0|); $parent->setAttribute(q|xml:lang|,q|en|);
This creates an attribute node with a name of 'xml:lang', but outside any namespace.
$parent->setAttribute(q|xhtml|,q|http://www.w3.org/1999/xhtml|);
BTW, this does not create a namespace declaration... and in fact your XSLT does not use this namespace for selecting parts of the source document.
$parent = __mk_element_node($document, $parent, q|pagetitle|); $parent->setAttribute(q|xml:lang|,q|en|); __mk_text_node($document, $parent, q|English|); $parent = $parent->getParentNode; $parent = __mk_element_node($document, $parent, q|sourceLanguage|); __mk_text_node($document, $parent, q|en|); $parent = $parent->getParentNode; $parent = __mk_element_node($document, $parent, q|sentence|); $parent = __mk_element_node($document, $parent, q|key|); $parent->setAttribute(q|xml:lang|,q|en|); __mk_text_node($document, $parent, q|key1|); $parent = $parent->getParentNode; $parent = __mk_element_node($document, $parent, q|value|); $parent->setAttribute(q|xml:lang|,q|en|); __mk_text_node($document, $parent, q|test in English|); $parent = $parent->getParentNode; $parent = $parent->getParentNode; $parent = $parent->getParentNode;
return OK; }
So I'd say that the XSP compiler needs to pay closer attention to namespaces and their declarations. I'm not making a patch mostly because I now rarely use AxKit...
--
Dakkar - <Mobilis in mobile>
GPG public key fingerprint = A071 E618 DD2C 5901 9574
6FE2 40EA 9883 7519 3F88
key id = 0x75193F88
signature.asc
Description: OpenPGP digital signature
