Re: [xml] Do patterns support namespaces ?



Joachim Zobel schrieb am 24.10.2011 um 07:34 (+0200):
On Sun, 2011-10-23 at 23:49 +0200, Michael Ludwig wrote:
There is a namespace prefix in your pattern that cannot be
bound to a namespace because you didn't declare any.

Yeah, missed that.

jo vostro:~$ echo '<?xml version="1.0"?><dummy xmlns:a="test"/>' |
xmllint --pattern "//a:b" -
Pattern //a:b failed to compile

To clarify:

The prefix has to be bound where the pattern using the prefix is
to be compiled.

In your example, you're declaring (but not using) it on the doc;
but that doesn't automagically provide the pattern to the bit of
code that is instructed to compile the pattern.

Check out the registerNs method (as well as the other register*
methods) in the Perl interface to libxml2 for an example of what
I'm referring to.

I still don't know what that --pattern switch is supposed to
do, but I cannot see how it is supposed to cope with namespace
prefixes; it seems to be lacking the command line equivalent of
the registerNs method.

Michael



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]