Re: xpath_array with namespaces support

Started by Bruce Momjianover 19 years ago11 messagespatches
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Nikolay Samokhvalov wrote:

On 3/22/07, Peter Eisentraut <peter_e@gmx.net> wrote:

Bruce Momjian wrote:

Patch applied.

This code seems to think that if an xml datum starts with "<?xml" it's a
document. That is completely bogus.

Agreed. I'll fix it.

Nikolay, it has been a week, and I have see no fixes from you in
response to requests from Peter. If the patch doesn't arrive in 1-2
days, I will have to revert your patch and it will be kept for 8.4.
Feature freeze was April 1, 2007.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#2Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#1)

Nikolay Samokhvalov wrote:

I apologize for it. I was extremely busy that week.
Fixes will follow ASAP, I'm working on it. 2 days are enough, it's good
deadline for me.
Sorry for delay.

Yes, that is fine. Thanks.

---------------------------------------------------------------------------

On 4/3/07, Bruce Momjian <bruce@momjian.us> wrote:

Nikolay Samokhvalov wrote:

On 3/22/07, Peter Eisentraut <peter_e@gmx.net> wrote:

Bruce Momjian wrote:

Patch applied.

This code seems to think that if an xml datum starts with "<?xml" it's

a

document. That is completely bogus.

Agreed. I'll fix it.

Nikolay, it has been a week, and I have see no fixes from you in
response to requests from Peter. If the patch doesn't arrive in 1-2
days, I will have to revert your patch and it will be kept for 8.4.
Feature freeze was April 1, 2007.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Best regards,
Nikolay

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Nikolay Samokhvalov
samokhvalov@gmail.com
In reply to: Bruce Momjian (#1)

I've realized that Peter's criticism (concerning comparing beginning
of datum with "<?xml") is right: current approach is unable to work
with XML values such as "<?xml ...?><a /><b />".

I'll propose a modification of the patch as long as fixes for NULLs as
input and output values very soon (in a day or so).

On 4/4/07, Nikolay Samokhvalov <nikolay@samokhvalov.com> wrote:

The patch attached contains following changes:
1. The function name xmlpath() is changed to xpath();
2. Approach of passing of namepspace mappings to the function is changed:
now that array (the 3rd argument) should be a 2-dimentional array with the
length of the second axis = 2 (e.g., ARRAY[ARRAY['a1', 'http://a1&#39;],
ARRAY['a2', 'http://a2&#39;], ARRAY['a2', 'http://a2&#39;]]);
3. Description of xpath() function in docs (I'm sorry for possible
mistakes in English and docbook formatting, please check it...)

On 4/3/07, Bruce Momjian <bruce@momjian.us> wrote:

Nikolay Samokhvalov wrote:

On 3/22/07, Peter Eisentraut < peter_e@gmx.net> wrote:

Bruce Momjian wrote:

Patch applied.

This code seems to think that if an xml datum starts with "<?xml" it's

a

document. That is completely bogus.

Agreed. I'll fix it.

Nikolay, it has been a week, and I have see no fixes from you in
response to requests from Peter. If the patch doesn't arrive in 1-2
days, I will have to revert your patch and it will be kept for 8.4.
Feature freeze was April 1, 2007.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB

http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Best regards,
Nikolay

--
Best regards,
Nikolay

#4Nikolay Samokhvalov
samokhvalov@gmail.com
In reply to: Bruce Momjian (#1)

Here is new version that adds following changes:
4. Function is now strict, per discussion.
5. Return empty array in case when XPath expression detects nothing
(previously, NULL was returned in such case), per discussion.
6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).
7. Some cleanup.

On 4/4/07, Nikolay Samokhvalov <nikolay@samokhvalov.com> wrote:

The patch attached contains following changes:
1. The function name xmlpath() is changed to xpath();
2. Approach of passing of namepspace mappings to the function is changed:
now that array (the 3rd argument) should be a 2-dimentional array with the
length of the second axis = 2 (e.g., ARRAY[ARRAY['a1', 'http://a1&#39;],
ARRAY['a2', 'http://a2&#39;], ARRAY['a2', 'http://a2&#39;]]);
3. Description of xpath() function in docs (I'm sorry for possible
mistakes in English and docbook formatting, please check it...)

On 4/3/07, Bruce Momjian <bruce@momjian.us> wrote:

Nikolay Samokhvalov wrote:

On 3/22/07, Peter Eisentraut < peter_e@gmx.net> wrote:

Bruce Momjian wrote:

Patch applied.

This code seems to think that if an xml datum starts with "<?xml" it's

a

document. That is completely bogus.

Agreed. I'll fix it.

Nikolay, it has been a week, and I have see no fixes from you in
response to requests from Peter. If the patch doesn't arrive in 1-2
days, I will have to revert your patch and it will be kept for 8.4.
Feature freeze was April 1, 2007.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB

http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Best regards,
Nikolay

--
Best regards,
Nikolay

Attachments:

xpath.fixes.20070410.patchtext/x-patch; charset=ANSI_X3.4-1968; name=xpath.fixes.20070410.patchDownload+133-90
#5Andrew Dunstan
andrew@dunslane.net
In reply to: Nikolay Samokhvalov (#4)

Nikolay Samokhvalov wrote:

6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).

Is that legal XML? I though only documents could have prologs.

cheers

andrew

#6Peter Eisentraut
peter_e@gmx.net
In reply to: Andrew Dunstan (#5)

Am Dienstag, 10. April 2007 15:17 schrieb Andrew Dunstan:

Nikolay Samokhvalov wrote:

6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).

Is that legal XML? I though only documents could have prologs.

It's not a legal XML document, but it's a legal XML content fragment,
specified by SQL/XML.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#7Nikolay Samokhvalov
samokhvalov@gmail.com
In reply to: Nikolay Samokhvalov (#4)

It's also worth to take care of the very last lines of XML functions
doc (http://momjian.us/main/writings/pgsql/sgml/functions-xml.html):

"XML to SQL Mapping

This involves converting XML data to and from relational
structures. PostgreSQL has no internal support for such mapping, and
relies on external tools to do such conversions."

It's not quite rigth as of now, because "rel->XML" mapping
capabilities exist in the core: it's XML/SQL publishing functions and
alternative mapping functions (such as table_to_xml() ).

On 4/10/07, Nikolay Samokhvalov <samokhvalov@gmail.com> wrote:

Here is new version that adds following changes:
4. Function is now strict, per discussion.
5. Return empty array in case when XPath expression detects nothing
(previously, NULL was returned in such case), per discussion.
6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).
7. Some cleanup.

On 4/4/07, Nikolay Samokhvalov <nikolay@samokhvalov.com> wrote:

The patch attached contains following changes:
1. The function name xmlpath() is changed to xpath();
2. Approach of passing of namepspace mappings to the function is changed:
now that array (the 3rd argument) should be a 2-dimentional array with the
length of the second axis = 2 (e.g., ARRAY[ARRAY['a1', 'http://a1&#39;],
ARRAY['a2', 'http://a2&#39;], ARRAY['a2', 'http://a2&#39;]]);
3. Description of xpath() function in docs (I'm sorry for possible
mistakes in English and docbook formatting, please check it...)

--
Best regards,
Nikolay

#8Nikolay Samokhvalov
samokhvalov@gmail.com
In reply to: Nikolay Samokhvalov (#4)

What's with this patch?
I do not see it in unapplied patches list, neither it was commited...
What we have now in CVS is not a good thing.

On 4/10/07, Nikolay Samokhvalov <samokhvalov@gmail.com> wrote:

Here is new version that adds following changes:
4. Function is now strict, per discussion.
5. Return empty array in case when XPath expression detects nothing
(previously, NULL was returned in such case), per discussion.
6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).
7. Some cleanup.

On 4/4/07, Nikolay Samokhvalov <nikolay@samokhvalov.com> wrote:

The patch attached contains following changes:
1. The function name xmlpath() is changed to xpath();
2. Approach of passing of namepspace mappings to the function is changed:
now that array (the 3rd argument) should be a 2-dimentional array with the
length of the second axis = 2 (e.g., ARRAY[ARRAY['a1', 'http://a1&#39;],
ARRAY['a2', 'http://a2&#39;], ARRAY['a2', 'http://a2&#39;]]);
3. Description of xpath() function in docs (I'm sorry for possible
mistakes in English and docbook formatting, please check it...)

--
Best regards,
Nikolay

#9Bruce Momjian
bruce@momjian.us
In reply to: Nikolay Samokhvalov (#4)

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------

Nikolay Samokhvalov wrote:

Here is new version that adds following changes:
4. Function is now strict, per discussion.
5. Return empty array in case when XPath expression detects nothing
(previously, NULL was returned in such case), per discussion.
6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).
7. Some cleanup.

On 4/4/07, Nikolay Samokhvalov <nikolay@samokhvalov.com> wrote:

The patch attached contains following changes:
1. The function name xmlpath() is changed to xpath();
2. Approach of passing of namepspace mappings to the function is changed:
now that array (the 3rd argument) should be a 2-dimentional array with the
length of the second axis = 2 (e.g., ARRAY[ARRAY['a1', 'http://a1&#39;],
ARRAY['a2', 'http://a2&#39;], ARRAY['a2', 'http://a2&#39;]]);
3. Description of xpath() function in docs (I'm sorry for possible
mistakes in English and docbook formatting, please check it...)

On 4/3/07, Bruce Momjian <bruce@momjian.us> wrote:

Nikolay Samokhvalov wrote:

On 3/22/07, Peter Eisentraut < peter_e@gmx.net> wrote:

Bruce Momjian wrote:

Patch applied.

This code seems to think that if an xml datum starts with "<?xml" it's

a

document. That is completely bogus.

Agreed. I'll fix it.

Nikolay, it has been a week, and I have see no fixes from you in
response to requests from Peter. If the patch doesn't arrive in 1-2
days, I will have to revert your patch and it will be kept for 8.4.
Feature freeze was April 1, 2007.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB

http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Best regards,
Nikolay

--
Best regards,
Nikolay

[ Attachment, skipping... ]

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#10Bruce Momjian
bruce@momjian.us
In reply to: Nikolay Samokhvalov (#8)

Thanks, added to queue.

---------------------------------------------------------------------------

Nikolay Samokhvalov wrote:

What's with this patch?
I do not see it in unapplied patches list, neither it was commited...
What we have now in CVS is not a good thing.

On 4/10/07, Nikolay Samokhvalov <samokhvalov@gmail.com> wrote:

Here is new version that adds following changes:
4. Function is now strict, per discussion.
5. Return empty array in case when XPath expression detects nothing
(previously, NULL was returned in such case), per discussion.
6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).
7. Some cleanup.

On 4/4/07, Nikolay Samokhvalov <nikolay@samokhvalov.com> wrote:

The patch attached contains following changes:
1. The function name xmlpath() is changed to xpath();
2. Approach of passing of namepspace mappings to the function is changed:
now that array (the 3rd argument) should be a 2-dimentional array with the
length of the second axis = 2 (e.g., ARRAY[ARRAY['a1', 'http://a1&#39;],
ARRAY['a2', 'http://a2&#39;], ARRAY['a2', 'http://a2&#39;]]);
3. Description of xpath() function in docs (I'm sorry for possible
mistakes in English and docbook formatting, please check it...)

--
Best regards,
Nikolay

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#11Peter Eisentraut
peter_e@gmx.net
In reply to: Nikolay Samokhvalov (#4)

Am Dienstag, 10. April 2007 14:01 schrieb Nikolay Samokhvalov:

Here is new version that adds following changes:
4. Function is now strict, per discussion.
5. Return empty array in case when XPath expression detects nothing
(previously, NULL was returned in such case), per discussion.
6. (bugfix) Work with fragments with prologue: select xpath('/a',
'<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped
with dummy <x>...</x>, XML prologue simply goes away (if any).
7. Some cleanup.

Applied.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/