(Let me know if bugtracker is better to discuss the idea)

Today the XPath Ns Resolver is marked as "Experimental" and is just an
alias for TDomNode:

  TXPathNSResolver = TDOMNode {!!! experimental}; [1]

The problem happens when the Namespace definition is not at the root
of the XML being processed:

<root>
  <u1:e1 xmlns:u1="URI-1" u1:AnAttribute="AttValue"/>
  <u2:e2 xmlns:u2="URI-2"/>
</root>

Using....

    EvaluateXPathExpression('//@u1:AnAttribute', x.DocumentElement,
   x.DocumentElement);

(x is a TXmlDocument)

 Will raise an Exception due to the "Resolver" not being capable of
finding the URI when starting from root.

I think of something simple as:

TXPathNSResolver = class

   property CurrentNode: TDomNode; //Necessary??
   property xml: TXmlDocument;
   property OnNeedUri: TXPathNeedUriEvent;
end;

TXPathNeedUriEvent would be something like:

procedure (Sender: TXPathNSResolver; out AUri: String) of object;

Searching first at CurrentNode.lookupNamespaceURI and, if not found,
using OnNeedUri.

Ideas?

Should I post it at mantis, change, quit.. ?


[1] Line #352: 
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-xml/src/xpath.pp?view=markup
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to