Hi

I sent this message on February 1st but I don't see it in the list archive
so I'm sending
it again in case there was some problem.

I've been using XalanC 1.4 and have the following problem:

I loaded the following XML document (which happens to be an XSD)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" attributeFormDefault="unqualified">
   <xs:annotation>
       <xs:appinfo source="my_app">my_schema</xs:appinfo>
   </xs:annotation>
</xs:schema>

Using XPathEvaluator::selectNodeList I executed the expression "/xs:schema"
and it worked fine, I got back one node.

But then I added a default namespace to the first elemennt

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="some_uri" xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" attributeFormDefault="unqualified">
   <xs:annotation>
       <xs:appinfo source="my_app">my_schema</xs:appinfo>
   </xs:annotation>
</xs:schema>

executing the spath expressions I got the following results

"/xs:schema" - the returned NodeList is empty
"/*" - the returned NodeList has one node
"/*[local-name()='schema']" - the returned NodeList has one node

So it seemed to me there was a problem resolving prefixes

I went to the source code and found the
DOMServices::getNamespaceForPrefix
The algorithm doesn't seem to take into account the presenc of a default
namespace so I patched it with this

"(equals(prefix,"")) && "

the code excerpt follows

if ( (equals(prefix,"")) && (equals(aname, s_XMLNamespace) == true))
{
      theNamespace = &attr->getNodeValue();
      break;
}
else if (startsWith(aname, s_XMLNamespaceWithSeparator) == true)
{
      if (equals(
                    prefix,
                    c_wstr(aname) + s_XMLNamespaceWithSeparatorLength) ==
true)
       {
                theNamespace = &attr->getNodeValue();
                break;
       }
}

It seems to work now but I'm not sure if this will break any other part of
the code.

Thanks in advance

Ernesto






Reply via email to